Changes requested before pull request can get merged.

This commit is contained in:
Paul Wasmund 2023-08-24 12:07:50 -05:00
parent 9eceb8b051
commit caff0fabe1
4 changed files with 40 additions and 28 deletions

View File

@ -5847,17 +5847,24 @@ uint16_t mode_2Dscrollingtext(void) {
int letterWidth; int letterWidth;
int letterHeight; int letterHeight;
switch (map(SEGMENT.custom2, 0, 255, 1, 9)) { #ifdef WLED_ENABLE_LARGE_FONTS
#define WLED_NUMBER_OF_FONTS 8
#else
#define WLED_NUMBER_OF_FONTS 5
#endif // WLED_ENABLE_LARGE_FONTS
switch (map(SEGMENT.custom2, 0, 255, 1, WLED_NUMBER_OF_FONTS)) {
default: default:
case 1: letterWidth = 4; letterHeight = 6; break; case 1: letterWidth = 4; letterHeight = 6; break;
case 2: letterWidth = 5; letterHeight = 8; break; case 2: letterWidth = 5; letterHeight = 8; break;
case 3: letterWidth = 6; letterHeight = 8; break; case 3: letterWidth = 6; letterHeight = 8; break;
case 4: letterWidth = 7; letterHeight = 9; break; case 4: letterWidth = 7; letterHeight = 9; break;
case 5: letterWidth = 5; letterHeight = 12; break; case 5: letterWidth = 5; letterHeight = 12; break;
#ifdef WLED_ENABLE_LARGE_FONTS
case 6: letterWidth = 12; letterHeight = 16; break; case 6: letterWidth = 12; letterHeight = 16; break;
case 7: letterWidth = 12; letterHeight = 24; break; case 7: letterWidth = 12; letterHeight = 24; break;
case 8: letterWidth = 16; letterHeight = 32; break; case 8: letterWidth = 16; letterHeight = 32; break;
case 9: letterWidth = 25; letterHeight = 57; break; #endif // WLED_ENABLE_LARGE_FONTS
} }
const bool zero = SEGMENT.check3; const bool zero = SEGMENT.check3;
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2; const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;

View File

@ -604,7 +604,7 @@ typedef struct Segment {
void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c); void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c); void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { drawLine(x0, y0, x1, y1, RGBW32(c.r,c.g,c.b,0)); } // automatic inline void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { drawLine(x0, y0, x1, y1, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2 = 0); void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2 = 0, uint8_t rotate = 0);
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0)); } // automatic inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0), RGBW32(c2.r,c2.g,c2.b,0)); } // automatic inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0), RGBW32(c2.r,c2.g,c2.b,0)); } // automatic inline
void wu_pixel(uint32_t x, uint32_t y, CRGB c); void wu_pixel(uint32_t x, uint32_t y, CRGB c);

View File

@ -568,8 +568,9 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3
#include "src/font/console_font_25x57.h" #include "src/font/console_font_25x57.h"
// draws a raster font character on canvas // draws a raster font character on canvas
// only supports: 4x6=24, 5x8=40, 5x12=60, 6x8=48, 7x9=63, 12x16=192, 16x24=288, 16x32=512 and 25x57=1425 fonts ATM // only supports: 4x6=24, 5x8=40, 5x12=60, 6x8=48, 7x9=63, 12x16=192, 12x24=288 and 16x32=512 fonts ATM
void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2) { void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2, uint8_t rotate) {
if (!isActive()) return; // not active
if (chr < 32 || chr > 126) return; // only ASCII 32-126 supported if (chr < 32 || chr > 126) return; // only ASCII 32-126 supported
chr -= 32; // align with font table entries chr -= 32; // align with font table entries
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
@ -580,15 +581,11 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
if (w <= 8) { if (w <= 8) {
num_bytes = 1; num_bytes = 1;
} }
#ifdef WLED_ENABLE_LARGE_FONTS
else if(w <= 16){ else if(w <= 16){
num_bytes = 2; num_bytes = 2;
} }
else if (w <= 24){ #endif // WLED_ENABLE_LARGE_FONTS
num_bytes = 3;
}
else if (w <= 32){
num_bytes = 4;
}
else { else {
return; return;
} }
@ -599,22 +596,22 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
// modifications to support characters whose width is > 8 bits // modifications to support characters whose width is > 8 bits
//if (w<5 || w>6 || h!=8) return; //if (w<5 || w>6 || h!=8) return;
for (int i = 0; i<h; i++) { // character height for (int i = 0; i<h; i++) { // character height
int16_t y0 = y + i; uint8_t bits[2] = {0};
if (y0 < 0) continue; // drawing off-screen for ( int j = 0; j < num_bytes; j++){
if (y0 >= rows) break; // drawing off-screen
const uint8_t *bits = 0;
switch (font) { switch (font) {
case 24: bits = &console_font_4x6[(chr * h * num_bytes) + (i * num_bytes)]; break; // 5x8 font case 24: bits[0] = pgm_read_byte_near(&console_font_4x6[(chr * h) + i]); break; // 4x6 font
case 40: bits = &console_font_5x8[(chr * h * num_bytes) + (i * num_bytes)]; break; // 5x8 font case 40: bits[0] = pgm_read_byte_near(&console_font_5x8[(chr * h) + i]); break; // 5x8 font
case 48: bits = &console_font_6x8[(chr * h * num_bytes) + (i * num_bytes)]; break; // 6x8 font case 48: bits[0] = pgm_read_byte_near(&console_font_6x8[(chr * h) + i]); break; // 6x8 font
case 63: bits = &console_font_7x9[(chr * h * num_bytes) + (i * num_bytes)]; break; // 7x9 font case 63: bits[0] = pgm_read_byte_near(&console_font_7x9[(chr * h) + i]); break; // 7x9 font
case 60: bits = &console_font_5x12[(chr * h * num_bytes) + (i * num_bytes)]; break; // 5x12 font case 60: bits[0] = pgm_read_byte_near(&console_font_5x12[(chr * h) + i]); break; // 5x12 font
case 192: bits = &console_font_12x16[(chr * h * num_bytes) + (i * num_bytes)]; break; // 12x16 font #ifdef WLED_ENABLE_LARGE_FONTS
case 288: bits = &console_font_12x24[(chr * h * num_bytes) + (i * num_bytes)]; break; // 16x24 font case 192: bits[j] = pgm_read_byte_near(&console_font_12x16[(chr * h * num_bytes) + (i * num_bytes) + j]); break; // 12x16 font
case 512: bits = &console_font_16x32[(chr * h * num_bytes) + (i * num_bytes)]; break; // 16x32 font case 288: bits[j] = pgm_read_byte_near(&console_font_12x24[(chr * h * num_bytes) + (i * num_bytes) + j]); break; // 12x24 font
case 1425: bits = &console_font_25x57[(chr * h * num_bytes) + (i * num_bytes)]; break; // 25x57 font case 512: bits[j] = pgm_read_byte_near(&console_font_16x32[(chr * h * num_bytes) + (i * num_bytes) + j]); break; // 16x32 font
#endif // WLED_ENABLE_LARGE_FONTS
default: return; default: return;
} }
}
int j1 = 0; int j1 = 0;
int wb = w % 8; int wb = w % 8;
@ -623,8 +620,15 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
for (int k = 1; k <= num_bytes; k++) { // loop through all bytes of the character for (int k = 1; k <= num_bytes; k++) { // loop through all bytes of the character
col = ColorFromPalette(grad, (i+1)*255/h, 255, NOBLEND); col = ColorFromPalette(grad, (i+1)*255/h, 255, NOBLEND);
for (int j = 0; j<wb; j++) { // character width in this byte for (int j = 0; j<wb; j++) { // character width in this byte
int16_t x0 = x + w - j1++; // run through pixels of font right to left int x0, y0; // incorporate fx-blending branch changes
if ((x0 >= 0 || x0 < cols) && ((bits[num_bytes - k]>>(j+(8-wb))) & 0x01)) { // bit set & drawing on-screen switch (rotate) {
case 3: x0 = x + (h-1) - i; y0 = y + (w-1) - j; break;
case 2: x0 = x + j1; y0 = y + (h-1) - i; break;
case 1: x0 = x + i; y0 = y + j; break;
default: x0 = x + (w-1) - j1++; y0 = y + i; break;
}
if (x0 < 0 || x0 >= cols || y0 < 0 || y0 >= rows) continue; // drawing off-screen
if (((bits[num_bytes - k]>>(j+(8-wb))) & 0x01)) { // bit set
setPixelColorXY(x0, y0, col); setPixelColorXY(x0, y0, col);
} }
} }

View File

@ -27,6 +27,7 @@
//#define WLED_DISABLE_ALEXA // saves 11kb //#define WLED_DISABLE_ALEXA // saves 11kb
//#define WLED_DISABLE_HUESYNC // saves 4kb //#define WLED_DISABLE_HUESYNC // saves 4kb
//#define WLED_DISABLE_INFRARED // saves 12kb, there is no pin left for this on ESP8266-01 //#define WLED_DISABLE_INFRARED // saves 12kb, there is no pin left for this on ESP8266-01
//#define WLED_ENABLE_LARGE_FONTS //
#ifndef WLED_DISABLE_MQTT #ifndef WLED_DISABLE_MQTT
#define WLED_ENABLE_MQTT // saves 12kb #define WLED_ENABLE_MQTT // saves 12kb
#endif #endif