Scrolling text selectable font.

This commit is contained in:
Blaz Kristan 2022-06-17 21:19:12 +02:00
parent 36503f0417
commit 041426fecb
3 changed files with 3094 additions and 12 deletions

View File

@ -5866,7 +5866,7 @@ uint16_t WS2812FX::mode_2Dscrollingtext(void) {
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
const int letterWidth = 6;
const int letterWidth = SEGMENT.custom2 > 128 ? 6 : 5;
const int letterHeight = 8;
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;
const char *text = PSTR("Use segment name"); // fallback if empty segment name
@ -5889,7 +5889,7 @@ uint16_t WS2812FX::mode_2Dscrollingtext(void) {
if (SEGENV.step < millis()) {
if ((numberOfLetters * letterWidth) > cols) ++SEGENV.aux0 %= (numberOfLetters * letterWidth) + cols; // offset
else SEGENV.aux0 = (cols - (numberOfLetters * letterWidth))/2;
else SEGENV.aux0 = (cols + (numberOfLetters * letterWidth))/2;
++SEGENV.aux1 &= 0xFF; // color shift
SEGENV.step = millis() + map(SEGMENT.speed, 0, 255, 10*FRAMETIME_FIXED, 2*FRAMETIME_FIXED);
}
@ -5899,12 +5899,12 @@ uint16_t WS2812FX::mode_2Dscrollingtext(void) {
for (uint16_t i = 0; i < numberOfLetters; i++) {
if (int(cols) - int(SEGENV.aux0) + letterWidth*(i+1) < 0) continue; // don't draw characters off-screen
if (text[i]<32 || text[i]>126) continue; // skip non-ANSII characters (may add UTF translation at some point)
drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0));
drawCharacter(text[i], int(cols) - int(SEGENV.aux0) + letterWidth*i, yoffset, letterWidth, letterHeight, color_from_palette(SEGENV.aux1, false, PALETTE_SOLID_WRAP, 0));
}
return FRAMETIME;
}
static const char *_data_FX_MODE_SCROLL_TEXT PROGMEM = "2D Scrolling Text@!,Y Offset,Trail;!,!;!";
static const char *_data_FX_MODE_SCROLL_TEXT PROGMEM = "2D Scrolling Text@!,Y Offset,Trail=0,Font size;!,!;!";
////////////////////////////

View File

@ -1023,7 +1023,7 @@ class WS2812FX {
nscale8(CRGB* leds, uint8_t scale),
setPixels(CRGB* leds),
drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c, CRGB *leds = nullptr),
drawCharacter(unsigned char chr, int16_t x, int16_t y, CRGB color, CRGB *leds = nullptr),
drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color, CRGB *leds = nullptr),
wu_pixel(CRGB *leds, uint32_t x, uint32_t y, CRGB c);
inline void setPixelColorXY(uint16_t x, uint16_t y, uint32_t c) { setPixelColorXY(x, y, byte(c>>16), byte(c>>8), byte(c), byte(c>>24)); }
@ -1031,7 +1031,7 @@ class WS2812FX {
inline void setPixelColorXY(float x, float y, uint32_t c, bool aa) { setPixelColorXY(x, y, byte(c>>16), byte(c>>8), byte(c), byte(c>>24), aa); }
inline void setPixelColorXY(float x, float y, CRGB c, bool aa) { setPixelColorXY(x, y, c.red, c.green, c.blue, 0, aa); }
inline void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c) { drawLine(x0, y0, x1, y1, CRGB(byte(c>>16), byte(c>>8), byte(c))); }
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint32_t c) { drawCharacter(chr, x, y, CRGB(byte(c>>16), byte(c>>8), byte(c))); }
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t c) { drawCharacter(chr, x, y, w, h, CRGB(byte(c>>16), byte(c>>8), byte(c))); }
uint16_t
XY(uint16_t, uint16_t),

File diff suppressed because it is too large Load Diff