Text entfernt - nun in Matrix hinterlegt

This commit is contained in:
starcalc 2018-12-07 00:37:23 +01:00
parent c9fd65440b
commit 51d621526b
2 changed files with 0 additions and 178 deletions

View File

@ -46,9 +46,6 @@ void NeoPatterns::Update() {
case ICON:
IconUpdate();
break;
case TEXT:
TextUpdate();
break;
case PLASMA:
PlasmaUpdate();
break;
@ -474,177 +471,6 @@ void NeoPatterns::IconComplete()
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()-1 ) * 9;
Index = TotalSteps;
// Index = 0;
Text1 = text;
// FontChar = fontchar;
Direction = REVERSE;
Color1 = 16711680;
textposition = 0;
charposition = 8;
// charposition = 0;
}
void NeoPatterns::TextUpdate()
{
/*
uint8_t _r = (uint8_t)(Color1 >> 16);
uint8_t _g = (uint8_t)(Color1 >> 8);
uint8_t _b = (uint8_t)Color1;
Direction = FORWARD;
Serial.println(Index);
setPixelColor(xyToSimplePos(0,Index), Color(100, 0, 0));
TotalSteps = 8;
Increment();
show();
return;
*/
// textposition++;
uint8_t FontChar = Text1[textposition];
uint8_t FontCharNext = Text1[textposition + 1];
// This will only work for 8*8-Pixel Displays, 64 Pixels
// The pixel 0,0 is on the lower right (the control access is there)
// textposition: position within text
// charposition: position of the current ("textposition") character, what is being shown of "this" character
int charx = 0;
// Walk through the whole matrix and display the matching pixel of the character which is supposed to be on charposition
// _ _ _
// _ _ _
// _ _ _
//
// I _ _
// I _ _
// I _ _
//
// _ I _
// _ I _
// _ I _
//
// 2,2 1,2 0,2
// 2,1 1,1 0,1
// 2,0 1,0 0,0
//
// 8 7 6
// 3 4 5
// 2 1 0
//
clear();
for (int x = 0; x < 8; x++) {
//charx = 8 - x;
for (int y = 0; y < 8; y++) {
int currentpos = xyToSimplePos(x,y);
// if (charx > charposition) {
// x > 8-charposition
if (8-x>charposition) {
// Display the second character
uint64_t mask = 1LL << (uint64_t)charxyToPos(charposition+x, y);
if ( (font[FontCharNext]&mask) == 0) {
setPixelColor(currentpos, Color(0, 0, 100)); //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(currentpos, Color(_r, _g, _b)); //bit is 1 at pos i
}
} else {
// Display the first character
uint64_t mask = 1LL << (uint64_t)charxyToPos(charposition+x-8, y);
if ( (font[FontChar]&mask) == 0) {
setPixelColor(currentpos, Color(0, 100, 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(currentpos, Color(_r, _g, _b)); //bit is 1 at pos i
}
}
}
}
Serial.println();
/*
// First char
for (int x = 0; x < 8-charposition; x++) { // Scroll the first char from right to left
for (int y = 0; y < 8; y++) {
uint64_t mask = 1LL << (uint64_t)charxyToPos(x, y);
if ( (font[FontChar]&mask) == 0) {
setPixelColor(xyToSimplePos(x, y), Color(0, 0, 100)); //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(xyToSimplePos(x, y), Color(_r, _g, _b)); //bit is 1 at pos i
}
}
}
// Second char
for (int x = 8-charposition; x < 8; x++) {
for (int y = 0; y < 8; y++) {
uint64_t mask = 1LL << (uint64_t)charxyToPos(x, y);
// uint64_t mask = 1LL << (uint64_t)(x+y);
if ( (font[FontCharNext]&mask) == 0) {
setPixelColor(xyToSimplePos(x, y), Color(0, 100, 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(xyToSimplePos(x, y), Color(_r, _g, _b)); //bit is 1 at pos i
}
}
}
*/
show();
charposition--;
if (charposition == 0)
{
charposition = 8;
textposition++;
}
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

View File

@ -36,9 +36,6 @@ class NeoPatterns : public Adafruit_NeoPixel
void Icon(uint8_t fontchar, String iconcolor = "#FFFFFF", uint8_t interval = 30);
void IconUpdate();
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 PlasmaUpdate();
@ -107,7 +104,6 @@ class NeoPatterns : public Adafruit_NeoPixel
float PlasmaColorStretch;
float SavedPlasmaColorStretch;
uint32_t DimColor(uint32_t color);
void Increment();
void (*OnComplete)(); // Callback on completion of pattern