Text hinzugefuegt. Noch ohne Scrollen und nacheinander jeden Buchstaben
This commit is contained in:
parent
ffa2363be4
commit
fab3b693aa
|
@ -46,6 +46,9 @@ void NeoPatterns::Update() {
|
||||||
case ICON:
|
case ICON:
|
||||||
IconUpdate();
|
IconUpdate();
|
||||||
break;
|
break;
|
||||||
|
case TEXT:
|
||||||
|
TextUpdate();
|
||||||
|
break;
|
||||||
case PLASMA:
|
case PLASMA:
|
||||||
PlasmaUpdate();
|
PlasmaUpdate();
|
||||||
break;
|
break;
|
||||||
|
@ -471,6 +474,76 @@ void NeoPatterns::IconComplete()
|
||||||
PlasmaColorStretch = SavedPlasmaColorStretch;
|
PlasmaColorStretch = SavedPlasmaColorStretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************** Text ******************/
|
||||||
|
|
||||||
|
void NeoPatterns::Text(String text, uint8_t interval)
|
||||||
|
{
|
||||||
|
// Save last effect, should be called after completion again
|
||||||
|
SavedPattern = ActivePattern;
|
||||||
|
SavedInterval = Interval;
|
||||||
|
SavedTotalSteps = TotalSteps;
|
||||||
|
SavedIndex = Index;
|
||||||
|
SavedColor1 = Color1;
|
||||||
|
SavedDirection = Direction;
|
||||||
|
SavedPlasmaPhase = PlasmaPhase;
|
||||||
|
SavedPlasmaPhaseIncrement = PlasmaPhaseIncrement;
|
||||||
|
SavedPlasmaColorStretch = PlasmaColorStretch;
|
||||||
|
ActivePattern = TEXT;
|
||||||
|
Interval = interval;
|
||||||
|
// textlength*8
|
||||||
|
TotalSteps = text.length()*8;
|
||||||
|
Index = TotalSteps;
|
||||||
|
Text1 = text;
|
||||||
|
// FontChar = fontchar;
|
||||||
|
Direction = REVERSE;
|
||||||
|
Color1 = 255*255*255;
|
||||||
|
textposition=0;
|
||||||
|
charposition=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeoPatterns::TextUpdate()
|
||||||
|
{
|
||||||
|
// textposition++;
|
||||||
|
charposition++;
|
||||||
|
if (charposition == 9)
|
||||||
|
{
|
||||||
|
charposition = 0;
|
||||||
|
textposition++;
|
||||||
|
}
|
||||||
|
uint8_t FontChar = Text1[textposition];
|
||||||
|
|
||||||
|
for (int i = 0; i < numPixels(); i++) {
|
||||||
|
uint64_t mask = 1LL << (uint64_t)i;
|
||||||
|
if ( (font[FontChar]&mask) == 0) {
|
||||||
|
setPixelColor(numToPos(i), Color(0, 0, 0)); //bit is 0 at pos i
|
||||||
|
} else {
|
||||||
|
uint8_t _r = (uint8_t)(Color1 >> 16);
|
||||||
|
uint8_t _g = (uint8_t)(Color1 >> 8);
|
||||||
|
uint8_t _b = (uint8_t)Color1;
|
||||||
|
setPixelColor(numToPos(i), Color(_r, _g, _b)); //bit is 1 at pos i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
show();
|
||||||
|
Increment();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeoPatterns::TextComplete()
|
||||||
|
{
|
||||||
|
// Reload last effect
|
||||||
|
ActivePattern = SavedPattern;
|
||||||
|
Interval = SavedInterval;
|
||||||
|
TotalSteps = SavedTotalSteps;
|
||||||
|
Index = SavedIndex;
|
||||||
|
Color1 = SavedColor1;
|
||||||
|
Direction = SavedDirection;
|
||||||
|
PlasmaPhase = SavedPlasmaPhase;
|
||||||
|
PlasmaPhaseIncrement = SavedPlasmaPhaseIncrement;
|
||||||
|
PlasmaColorStretch = SavedPlasmaColorStretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************** Plasma ******************/
|
||||||
|
|
||||||
// Based upon https://github.com/johncarl81/neopixelplasma
|
// Based upon https://github.com/johncarl81/neopixelplasma
|
||||||
void NeoPatterns::Plasma(float phase, float phaseIncrement, float colorStretch, uint8_t interval)
|
void NeoPatterns::Plasma(float phase, float phaseIncrement, float colorStretch, uint8_t interval)
|
||||||
{
|
{
|
||||||
|
@ -708,7 +781,3 @@ uint32_t NeoPatterns::parseColor(String value) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
// Pattern types supported:
|
// Pattern types supported:
|
||||||
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, RANDOM_FADE, SMOOTH, ICON, RANDOM_FADE_SINGLE, PLASMA, FILL, RANDOM };
|
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, RANDOM_FADE, SMOOTH, ICON, TEXT, RANDOM_FADE_SINGLE, PLASMA, FILL, RANDOM };
|
||||||
// Patern directions supported:
|
// Patern directions supported:
|
||||||
enum direction { FORWARD, REVERSE };
|
enum direction { FORWARD, REVERSE };
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
void Icon(uint8_t fontchar, String iconcolor = "#FFFFFF", uint8_t interval = 30);
|
void Icon(uint8_t fontchar, String iconcolor = "#FFFFFF", uint8_t interval = 30);
|
||||||
void IconUpdate();
|
void IconUpdate();
|
||||||
void IconComplete();
|
void IconComplete();
|
||||||
|
void Text(String text, uint8_t interval = 80);
|
||||||
|
void TextUpdate();
|
||||||
|
void TextComplete();
|
||||||
void Plasma(float phase = 0, float phaseIncrement = 0.08, float colorStretch = 0.11, uint8_t interval = 60); // 0.08 and 0.11 // 0.03 und 0.3
|
void Plasma(float phase = 0, float phaseIncrement = 0.08, float colorStretch = 0.11, uint8_t interval = 60); // 0.08 and 0.11 // 0.03 und 0.3
|
||||||
void PlasmaUpdate();
|
void PlasmaUpdate();
|
||||||
|
|
||||||
|
@ -89,6 +92,10 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
uint8_t *pixelG_buffer;
|
uint8_t *pixelG_buffer;
|
||||||
uint8_t *pixelB_buffer;
|
uint8_t *pixelB_buffer;
|
||||||
|
|
||||||
|
uint8_t textposition;
|
||||||
|
uint8_t charposition;
|
||||||
|
String Text1;
|
||||||
|
|
||||||
uint8_t FontChar;
|
uint8_t FontChar;
|
||||||
|
|
||||||
float PlasmaPhase;
|
float PlasmaPhase;
|
||||||
|
|
|
@ -152,7 +152,6 @@ bool onSetEffect(const HomieRange& range, const String& value) {
|
||||||
|
|
||||||
bool onSetIcon(const HomieRange& range, const String& value) {
|
bool onSetIcon(const HomieRange& range, const String& value) {
|
||||||
stopAfterCompletion = true;
|
stopAfterCompletion = true;
|
||||||
String _iconname = value;
|
|
||||||
if (value[0] == '#') { //color given
|
if (value[0] == '#') { //color given
|
||||||
strip.Icon(value.substring(7)[0], value.substring(0, 6));
|
strip.Icon(value.substring(7)[0], value.substring(0, 6));
|
||||||
}
|
}
|
||||||
|
@ -162,6 +161,13 @@ bool onSetIcon(const HomieRange& range, const String& value) {
|
||||||
homieNode.setProperty("icon").send(value);
|
homieNode.setProperty("icon").send(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool onSetText(const HomieRange& range, const String& value) {
|
||||||
|
stopAfterCompletion = true;
|
||||||
|
strip.Text(value);
|
||||||
|
homieNode.setProperty("text").send(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool onSetClear(const HomieRange& range, const String& value) {
|
bool onSetClear(const HomieRange& range, const String& value) {
|
||||||
strip.None();
|
strip.None();
|
||||||
strip.clear();
|
strip.clear();
|
||||||
|
@ -194,6 +200,7 @@ void setup() {
|
||||||
homieNode.advertiseRange("color", 0, 1).settable(onSetColor);
|
homieNode.advertiseRange("color", 0, 1).settable(onSetColor);
|
||||||
homieNode.advertise("brightness").settable(onSetBrightness);
|
homieNode.advertise("brightness").settable(onSetBrightness);
|
||||||
homieNode.advertise("effect").settable(onSetEffect);
|
homieNode.advertise("effect").settable(onSetEffect);
|
||||||
|
homieNode.advertise("text").settable(onSetText);
|
||||||
homieNode.advertise("clear").settable(onSetClear);
|
homieNode.advertise("clear").settable(onSetClear);
|
||||||
homieNode.advertise("length").settable(onSetLength);
|
homieNode.advertise("length").settable(onSetLength);
|
||||||
homieNode.advertise("icon").settable(onSetIcon);
|
homieNode.advertise("icon").settable(onSetIcon);
|
||||||
|
@ -229,5 +236,3 @@ void loop() {
|
||||||
Homie.loop();
|
Homie.loop();
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue