Custom font

This commit is contained in:
Blaž Kristan 2022-01-04 12:10:11 +01:00
parent eb08129226
commit 2f8ba75970
2 changed files with 33 additions and 68 deletions

View File

@ -311,7 +311,7 @@ const uint8_t u8x8_4LineDisplay_WLED_icons_6x6[2596] U8X8_FONT_SECTION("u8x8_4Li
"\0\200\200\300\340\370\374\377\377\377\177\37\7\0\0\0\0\0\0\0\0\0\0\0\0\1\3\7\17\37\37\77" "\0\200\200\300\340\370\374\377\377\377\177\37\7\0\0\0\0\0\0\0\0\0\0\0\0\1\3\7\17\37\37\77"
"\77\177~~~\374\374\374\374\374\374\374\374~~~\177\77\77\37\37\17\7\3\1\0\0\0\0\0\0\0" "\77\177~~~\374\374\374\374\374\374\374\374~~~\177\77\77\37\37\17\7\3\1\0\0\0\0\0\0\0"
"\0\0\0"; "\0\0\0";
*/
class FourLineDisplayUsermod : public Usermod { class FourLineDisplayUsermod : public Usermod {
@ -463,7 +463,7 @@ class FourLineDisplayUsermod : public Usermod {
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
setPowerSave(0); setPowerSave(0);
//drawString(0, 0, "Loading..."); //drawString(0, 0, "Loading...");
overlay(PSTR("Loading..."),3000,0); overlay(PSTR("Loading..."),3000,9);
} }
// gets called every time WiFi is (re-)connected. Initialize own network // gets called every time WiFi is (re-)connected. Initialize own network
@ -681,24 +681,24 @@ class FourLineDisplayUsermod : public Usermod {
void draw2x2GlyphIcons() { void draw2x2GlyphIcons() {
if (lineHeight == 2) { if (lineHeight == 2) {
drawGlyph( 1, 0, 0x45, u8x8_font_open_iconic_weather_2x2, true); //brightness icon drawGlyph( 1, 0, 1, u8x8_4LineDisplay_WLED_icons_2x2, true); //brightness icon
drawGlyph( 5, 0, 0x48, u8x8_font_open_iconic_play_2x2, true); //speed icon drawGlyph( 5, 0, 2, u8x8_4LineDisplay_WLED_icons_2x2, true); //speed icon
drawGlyph( 9, 0, 0x4e, u8x8_font_open_iconic_thing_2x2, true); //intensity icon drawGlyph( 9, 0, 3, u8x8_4LineDisplay_WLED_icons_2x2, true); //intensity icon
drawGlyph(14, 2*lineHeight, 0x48, u8x8_font_open_iconic_thing_2x2, true); //palette icon drawGlyph(14, 2*lineHeight, 4, u8x8_4LineDisplay_WLED_icons_2x2, true); //palette icon
drawGlyph(14, 3*lineHeight, 0x46, u8x8_font_open_iconic_thing_2x2, true); //effect icon drawGlyph(14, 3*lineHeight, 5, u8x8_4LineDisplay_WLED_icons_2x2, true); //effect icon
} else { } else {
drawGlyph( 2, 0, 0x45, u8x8_font_open_iconic_weather_1x1); //brightness icon drawGlyph( 2, 0, 1, u8x8_4LineDisplay_WLED_icons_1x1); //brightness icon
drawGlyph( 6, 0, 0x48, u8x8_font_open_iconic_play_1x1); //speed icon drawGlyph( 6, 0, 2, u8x8_4LineDisplay_WLED_icons_1x1); //speed icon
drawGlyph(10, 0, 0x4e, u8x8_font_open_iconic_thing_1x1); //intensity icon drawGlyph(10, 0, 3, u8x8_4LineDisplay_WLED_icons_1x1); //intensity icon
drawGlyph(15, 2*lineHeight, 0x48, u8x8_font_open_iconic_thing_1x1); //palette icon drawGlyph(15, 2*lineHeight, 4, u8x8_4LineDisplay_WLED_icons_1x1); //palette icon
drawGlyph(15, 3*lineHeight, 0x46, u8x8_font_open_iconic_thing_1x1); //effect icon drawGlyph(15, 3*lineHeight, 5, u8x8_4LineDisplay_WLED_icons_1x1); //effect icon
} }
} }
void drawStatusIcons() { void drawStatusIcons() {
drawGlyph(14, 0, 80 + (wificonnected?0:1), u8x8_font_open_iconic_embedded_1x1, true); // wifi icon drawGlyph(14, 0, (wificonnected ? 10 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // wifi icon
drawGlyph(15, 0, 78 + (bri > 0 ? 0 : 3), u8x8_font_open_iconic_embedded_1x1, true); // power icon drawGlyph(15, 0, (bri > 0 ? 9 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // power icon
drawGlyph(13, 0, 66 + (nightlightActive?0:4), u8x8_font_open_iconic_weather_1x1, true); // moon icon for nighlight mode drawGlyph(13, 0, (nightlightActive ? 6 : 0), u8x8_4LineDisplay_WLED_icons_1x1, true); // moon icon for nighlight mode
} }
/** /**
@ -799,45 +799,10 @@ class FourLineDisplayUsermod : public Usermod {
// Turn the display back on // Turn the display back on
if (!wakeDisplay()) clear(); if (!wakeDisplay()) clear();
// Print the overlay // Print the overlay
switch (glyphType) { if (glyphType>0 && glyphType<255) {
case 0: if (lineHeight == 2) drawGlyph(5, 0, glyphType, u8x8_4LineDisplay_WLED_icons_6x6, true);
if (lineHeight == 2) drawGlyph(6, 1, 0x4e, u8x8_font_open_iconic_embedded_4x4, true); else drawGlyph(7, lineHeight, glyphType, u8x8_4LineDisplay_WLED_icons_2x2, true);
else drawGlyph(7, lineHeight, 0x4e, u8x8_font_open_iconic_embedded_2x2, true);
break;
case 1:
if (lineHeight == 2) drawGlyph(6, 1, 0x45, u8x8_font_open_iconic_weather_4x4, true);
else drawGlyph(7, lineHeight, 0x45, u8x8_font_open_iconic_weather_2x2, true);
break;
case 2:
if (lineHeight == 2) drawGlyph(6, 1, 0x48, u8x8_font_open_iconic_play_4x4, true);
else drawGlyph(7, lineHeight, 0x48, u8x8_font_open_iconic_play_2x2, true);
break;
case 3:
if (lineHeight == 2) drawGlyph(6, 1, 0x4e, u8x8_font_open_iconic_thing_4x4, true);
else drawGlyph(7, lineHeight, 0x4e, u8x8_font_open_iconic_thing_2x2, true);
break;
case 4:
if (lineHeight == 2) drawGlyph(6, 1, 0x48, u8x8_font_open_iconic_thing_4x4, true);
else drawGlyph(7, lineHeight, 0x48, u8x8_font_open_iconic_thing_2x2, true);
break;
case 5:
if (lineHeight == 2) drawGlyph(6, 1, 0x46, u8x8_font_open_iconic_thing_4x4, true);
else drawGlyph(7, lineHeight, 0x46, u8x8_font_open_iconic_thing_2x2, true);
break;
case 6:
if (lineHeight == 2) drawGlyph(6, 1, 0x47, u8x8_font_open_iconic_thing_4x4, true);
else drawGlyph(7, lineHeight, 0x47, u8x8_font_open_iconic_thing_2x2, true);
break;
case 7:
if (lineHeight == 2) drawGlyph(6, 1, 0x4b, u8x8_font_open_iconic_embedded_4x4, true);
else drawGlyph(7, lineHeight, 0x4b, u8x8_font_open_iconic_embedded_2x2, true);
break;
case 8:
if (lineHeight == 2) drawGlyph(6, 1, 0x44, u8x8_font_open_iconic_weather_4x4, true);
else drawGlyph(7, lineHeight, 0x44, u8x8_font_open_iconic_weather_2x2, true);
break;
} }
if (line1) { if (line1) {
String buf = line1; String buf = line1;
center(buf, getCols()); center(buf, getCols());

View File

@ -341,14 +341,14 @@ public:
bool changedState = true; bool changedState = true;
if (display != nullptr) { if (display != nullptr) {
switch(newState) { switch(newState) {
case 0: changedState = changeState(PSTR("Brightness"), 1, 0, 1); break; case 0: changedState = changeState(PSTR("Brightness"), 1, 0, 1); break; //1 = sun
case 1: changedState = changeState(PSTR("Speed"), 1, 4, 2); break; case 1: changedState = changeState(PSTR("Speed"), 1, 4, 2); break; //2 = skip forward
case 2: changedState = changeState(PSTR("Intensity"), 1, 8, 3); break; case 2: changedState = changeState(PSTR("Intensity"), 1, 8, 3); break; //3 = fire
case 3: changedState = changeState(PSTR("Color Palette"), 2, 0, 4); break; case 3: changedState = changeState(PSTR("Color Palette"), 2, 0, 4); break; //4 = custom palette
case 4: changedState = changeState(PSTR("Effect"), 3, 0, 5); break; case 4: changedState = changeState(PSTR("Effect"), 3, 0, 5); break; //5 = puzzle piece
case 5: changedState = changeState(PSTR("Main Color"), 255, 255, 6); break; case 5: changedState = changeState(PSTR("Main Color"), 255, 255, 7); break; //7 = brush
case 6: changedState = changeState(PSTR("Saturation"), 255, 255, 7); break; case 6: changedState = changeState(PSTR("Saturation"), 255, 255, 8); break; //8 = contrast
case 7: changedState = changeState(PSTR("Preset"), 255, 255, 8); break; case 7: changedState = changeState(PSTR("Preset"), 255, 255, 6); break; //6 = moon
} }
} }
if (changedState) { if (changedState) {