Optimizations

This commit is contained in:
Blaz Kristan 2022-01-17 20:29:14 +01:00
parent 0259e78b2f
commit 75098d8b3e
2 changed files with 19 additions and 17 deletions

View File

@ -5,7 +5,7 @@
/* /*
Fontname: wled_logo_akemi_4x4 Fontname: wled_logo_akemi_4x4
Copyright: Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 3/3 Glyphs: 3/3
BBX Build Mode: 3 BBX Build Mode: 3
* this logo ...WLED/images/wled_logo_akemi.png * this logo ...WLED/images/wled_logo_akemi.png
@ -29,7 +29,7 @@ const uint8_t u8x8_wled_logo_akemi_4x4[388] U8X8_FONT_SECTION("u8x8_wled_logo_ak
/* /*
Fontname: wled_logo_akemi_5x5 Fontname: wled_logo_akemi_5x5
Copyright: Created with Fony 1.4.7 Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 3/3 Glyphs: 3/3
BBX Build Mode: 3 BBX Build Mode: 3
* this logo ...WLED/images/wled_logo_akemi.png * this logo ...WLED/images/wled_logo_akemi.png
@ -60,7 +60,7 @@ const uint8_t u8x8_wled_logo_akemi_5x5[604] U8X8_FONT_SECTION("u8x8_wled_logo_ak
/* /*
Fontname: wled_logo_2x2 Fontname: wled_logo_2x2
Copyright: Created with Fony 1.4.7 Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 4/4 Glyphs: 4/4
BBX Build Mode: 3 BBX Build Mode: 3
* this logo https://cdn.discordapp.com/attachments/706623245935444088/927361780613799956/wled_scaled.png * this logo https://cdn.discordapp.com/attachments/706623245935444088/927361780613799956/wled_scaled.png
@ -106,7 +106,7 @@ const uint8_t u8x8_wled_logo_4x4[517] U8X8_FONT_SECTION("u8x8_wled_logo_4x4") =
/* /*
Fontname: 4LineDisplay_WLED_icons_1x Fontname: 4LineDisplay_WLED_icons_1x
Copyright: Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 13/13 Glyphs: 13/13
BBX Build Mode: 3 BBX Build Mode: 3
* 1 = sun * 1 = sun
@ -136,7 +136,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_1x1[172] U8X8_FONT_SECTION("u8x8_4Lin
/* /*
Fontname: 4LineDisplay_WLED_icons_2x1 Fontname: 4LineDisplay_WLED_icons_2x1
Copyright: Created with Fony 1.4.7 Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 11/11 Glyphs: 11/11
BBX Build Mode: 3 BBX Build Mode: 3
* 1 = sun * 1 = sun
@ -197,7 +197,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_2x2[389] U8X8_FONT_SECTION("u8x8_4Lin
/* /*
Fontname: 4LineDisplay_WLED_icons_3x Fontname: 4LineDisplay_WLED_icons_3x
Copyright: Created with Fony 1.4.7 Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 11/11 Glyphs: 11/11
BBX Build Mode: 3 BBX Build Mode: 3
* 1 = sun * 1 = sun
@ -247,7 +247,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_3x3[868] U8X8_FONT_SECTION("u8x8_4Lin
/* /*
Fontname: 4LineDisplay_WLED_icons_4x Fontname: 4LineDisplay_WLED_icons_4x
Copyright: Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 11/11 Glyphs: 11/11
BBX Build Mode: 3 BBX Build Mode: 3
* 1 = sun * 1 = sun
@ -318,7 +318,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_4x4[1540] U8X8_FONT_SECTION("u8x8_4Li
/* /*
Fontname: 4LineDisplay_WLED_icons_6x Fontname: 4LineDisplay_WLED_icons_6x
Copyright: Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 11/11 Glyphs: 11/11
BBX Build Mode: 3 BBX Build Mode: 3
* 1 = sun * 1 = sun
@ -334,6 +334,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_4x4[1540] U8X8_FONT_SECTION("u8x8_4Li
* 11 = heart * 11 = heart
* 12 = Akemi * 12 = Akemi
*/ */
// you can replace this (wasteful) font by using 3x3 variant with draw2x2Glyph()
const uint8_t u8x8_4LineDisplay_WLED_icons_6x6[3460] U8X8_FONT_SECTION("u8x8_4LineDisplay_WLED_icons_6x6") = const uint8_t u8x8_4LineDisplay_WLED_icons_6x6[3460] U8X8_FONT_SECTION("u8x8_4LineDisplay_WLED_icons_6x6") =
"\1\14\6\6\0\0\0\0\0\0\200\300\300\300\300\200\0\0\0\0\0\0\0\0\0\36\77\77\77\77\36\0" "\1\14\6\6\0\0\0\0\0\0\200\300\300\300\300\200\0\0\0\0\0\0\0\0\0\36\77\77\77\77\36\0"
"\0\0\0\0\0\0\0\0\200\300\300\300\300\200\0\0\0\0\0\0\0\0\0\0\0\0\7\17\17\17\17\7" "\0\0\0\0\0\0\0\0\200\300\300\300\300\200\0\0\0\0\0\0\0\0\0\0\0\0\7\17\17\17\17\7"
@ -449,7 +450,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_6x6[3460] U8X8_FONT_SECTION("u8x8_4Li
/* /*
Fontname: akemi_8x8 Fontname: akemi_8x8
Copyright: Created with Fony 1.4.7 Copyright: Benji (https://github.com/proto-molecule)
Glyphs: 1/1 Glyphs: 1/1
BBX Build Mode: 3 BBX Build Mode: 3
* 12 = Akemi * 12 = Akemi

View File

@ -259,7 +259,7 @@ class FourLineDisplayUsermod : public Usermod {
initDone = true; initDone = true;
DEBUG_PRINTLN(F("Starting display.")); DEBUG_PRINTLN(F("Starting display."));
/*if (!(type == SSD1306_SPI || type == SSD1306_SPI64))*/ u8x8->setBusClock(ioFrequency); // can be used for SPI too u8x8->setBusClock(ioFrequency); // can be used for SPI too
u8x8->begin(); u8x8->begin();
setFlipMode(flip); setFlipMode(flip);
setContrast(contrast); //Contrast setup will help to preserve OLED lifetime. In case OLED need to be brighter increase number up to 255 setContrast(contrast); //Contrast setup will help to preserve OLED lifetime. In case OLED need to be brighter increase number up to 255
@ -539,6 +539,7 @@ class FourLineDisplayUsermod : public Usermod {
// Find the mode name in JSON // Find the mode name in JSON
uint8_t printedChars = extractModeName(inputEffPal, qstring, lineBuffer, MAX_JSON_CHARS-1); uint8_t printedChars = extractModeName(inputEffPal, qstring, lineBuffer, MAX_JSON_CHARS-1);
if (lineBuffer[0]=='*' && lineBuffer[1]==' ') { if (lineBuffer[0]=='*' && lineBuffer[1]==' ') {
// remove "* " from dynamic palettes
for (byte i=2; i<=printedChars; i++) lineBuffer[i-2] = lineBuffer[i]; //include '\0' for (byte i=2; i<=printedChars; i++) lineBuffer[i-2] = lineBuffer[i]; //include '\0'
printedChars -= 2; printedChars -= 2;
} }
@ -548,7 +549,7 @@ class FourLineDisplayUsermod : public Usermod {
uint8_t smallChars1 = 0; uint8_t smallChars1 = 0;
uint8_t smallChars2 = 0; uint8_t smallChars2 = 0;
if (printedChars < MAX_MODE_LINE_SPACE) { // use big font if the text fits if (printedChars < MAX_MODE_LINE_SPACE) { // use big font if the text fits
for (;printedChars < (MAX_MODE_LINE_SPACE-1); printedChars++) lineBuffer[printedChars]=' '; while (printedChars < (MAX_MODE_LINE_SPACE-1)) lineBuffer[printedChars++]=' ';
lineBuffer[printedChars] = 0; lineBuffer[printedChars] = 0;
drawString(1, row*lineHeight, lineBuffer); drawString(1, row*lineHeight, lineBuffer);
} else { // for long names divide the text into 2 lines and print them small } else { // for long names divide the text into 2 lines and print them small
@ -569,10 +570,10 @@ class FourLineDisplayUsermod : public Usermod {
break; break;
} }
} }
for (; smallChars1 < (MAX_MODE_LINE_SPACE-1); smallChars1++) smallBuffer1[smallChars1]=' '; while (smallChars1 < (MAX_MODE_LINE_SPACE-1)) smallBuffer1[smallChars1++]=' ';
smallBuffer1[smallChars1] = 0; smallBuffer1[smallChars1] = 0;
drawString(1, row*lineHeight, smallBuffer1, true); drawString(1, row*lineHeight, smallBuffer1, true);
for (; smallChars2 < (MAX_MODE_LINE_SPACE-1); smallChars2++) smallBuffer2[smallChars2]=' '; while (smallChars2 < (MAX_MODE_LINE_SPACE-1)) smallBuffer2[smallChars2++]=' ';
smallBuffer2[smallChars2] = 0; smallBuffer2[smallChars2] = 0;
drawString(1, row*lineHeight+1, smallBuffer2, true); drawString(1, row*lineHeight+1, smallBuffer2, true);
} }
@ -614,7 +615,7 @@ class FourLineDisplayUsermod : public Usermod {
if (!wakeDisplay()) clear(); if (!wakeDisplay()) clear();
// Print the overlay // Print the overlay
if (glyphType>0 && glyphType<255) { if (glyphType>0 && glyphType<255) {
if (lineHeight == 2) drawGlyph(5, 0, glyphType, u8x8_4LineDisplay_WLED_icons_6x6, true); if (lineHeight == 2) drawGlyph(5, 0, glyphType, u8x8_4LineDisplay_WLED_icons_6x6, true); // use 3x3 font with draw2x2Glyph() if flash runs short and comment out 6x6 font
else drawGlyph(6, 0, glyphType, u8x8_4LineDisplay_WLED_icons_3x3, true); else drawGlyph(6, 0, glyphType, u8x8_4LineDisplay_WLED_icons_3x3, true);
} }
if (line1) { if (line1) {
@ -651,7 +652,7 @@ class FourLineDisplayUsermod : public Usermod {
break; break;
case 2: case 2:
//Akemi //Akemi
//draw2x2Glyph( 4, 0, 12, u8x8_4LineDisplay_WLED_icons_4x4); //draw2x2Glyph( 5, 0, 12, u8x8_4LineDisplay_WLED_icons_3x3); // use this if flash runs short and comment out 6x6 font
drawGlyph( 5, 0, 12, u8x8_4LineDisplay_WLED_icons_6x6, true); drawGlyph( 5, 0, 12, u8x8_4LineDisplay_WLED_icons_6x6, true);
drawString(6, 6, "WLED"); drawString(6, 6, "WLED");
break; break;
@ -673,7 +674,7 @@ class FourLineDisplayUsermod : public Usermod {
break; break;
case 2: case 2:
//Akemi //Akemi
//drawGlyph( 6, 0, 12, u8x8_4LineDisplay_WLED_icons_4x4); //drawGlyph( 6, 0, 12, u8x8_4LineDisplay_WLED_icons_4x4); // a bit nicer, but uses extra 1.5k flash
draw2x2Glyph( 6, 0, 12, u8x8_4LineDisplay_WLED_icons_2x2); draw2x2Glyph( 6, 0, 12, u8x8_4LineDisplay_WLED_icons_2x2);
break; break;
} }
@ -953,4 +954,4 @@ const char FourLineDisplayUsermod::_sleepMode[] PROGMEM = "sleepMode";
const char FourLineDisplayUsermod::_clockMode[] PROGMEM = "clockMode"; const char FourLineDisplayUsermod::_clockMode[] PROGMEM = "clockMode";
const char FourLineDisplayUsermod::_showSeconds[] PROGMEM = "showSeconds"; const char FourLineDisplayUsermod::_showSeconds[] PROGMEM = "showSeconds";
const char FourLineDisplayUsermod::_busClkFrequency[] PROGMEM = "i2c-freq-kHz"; const char FourLineDisplayUsermod::_busClkFrequency[] PROGMEM = "i2c-freq-kHz";
const char FourLineDisplayUsermod::_contrastFixForType3[] PROGMEM = "contrastFixForType3"; const char FourLineDisplayUsermod::_contrastFixForType3[] PROGMEM = "contrastFixForType3";