Skip to content

Commit 0775ace

Browse files
authored
Merge pull request wled#2250 from Proto-molecule/master
Fix Glyphs for 4 line display
2 parents b750f82 + 6457314 commit 0775ace

File tree

1 file changed

+96
-44
lines changed

1 file changed

+96
-44
lines changed

usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h

Lines changed: 96 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,50 @@ typedef enum {
9696
SSD1306_SPI64 // U8X8_SSD1306_128X64_NONAME_HW_SPI
9797
} DisplayType;
9898

99+
/*
100+
Fontname: benji_custom_icons_1x
101+
Copyright:
102+
Glyphs: 1/1
103+
BBX Build Mode: 3
104+
* 4 = custom palette
105+
*/
106+
const uint8_t u8x8_font_benji_custom_icons_1x1[13] U8X8_FONT_SECTION("u8x8_font_benji_custom_icons_1x1") =
107+
"\4\4\1\1<n\372\377\275\277\26\34";
108+
99109
/*
100110
Fontname: benji_custom_icons_2x
101111
Copyright:
102-
Glyphs: 1/1
112+
Glyphs: 8/8
103113
BBX Build Mode: 3
104-
* 2x2 custom icons that are not available in the U8X8 library
105-
* 64 = custom palette
114+
// all the icons uses are consolidated into a single library to simplify code
115+
// these are just the required icons stripped from the U8x8 libraries in addition to a few new custom icons
116+
* 1 = sun
117+
* 2 = skip forward
118+
* 3 = fire
119+
* 4 = custom palette
120+
* 5 = puzzle piece
121+
* 6 = moon
122+
* 7 = brush
123+
* 8 = custom saturation
106124
*/
107-
const uint8_t u8x8_font_benji_custom_icons_2x2[37] U8X8_FONT_SECTION("u8x8_font_benji_custom_icons_2x2") =
108-
"@@\2\2\360\370\234\236\376\363\363\377\377\363\363\376><\370\360\3\17\77yy\377\377\377\377\317\17\17"
109-
"\17\17\7\3";
125+
const uint8_t u8x8_font_benji_custom_icons_2x2[261] U8X8_FONT_SECTION("u8x8_font_benji_custom_icons_2x2") =
126+
"\1\10\2\2\200\200\14\14\300\340\360\363\363\360\340\300\14\14\200\200\1\1\60\60\3\7\17\317\317\17\7\3"
127+
"\60\60\1\1\374\370\360\340\340\300\200\0\374\370\360\340\340\300\200\0\77\37\17\7\7\3\1\0\77\37\17\7"
128+
"\7\3\1\0\0\200\340\360\377\376\374\360\0\0\300\200\0\0\0\0\17\77\177\377\17\7\301\340\370\374\377\377"
129+
"\377|\0\0\360\370\234\236\376\363\363\377\377\363\363\376><\370\360\3\17\77yy\377\377\377\377\317\17\17"
130+
"\17\17\7\3\360\360\360\360\366\377\377\366\360\360\360\360\0\0\0\0\377\377\377\377\237\17\17\237\377\377\377\377"
131+
"\6\17\17\6\340\370\374\376\377\340\200\0\0\0\0\0\0\0\0\0\3\17\37\77\177\177\177\377\376|||"
132+
"\70\30\14\0\0\0\0\0\0\0\0``\360\370|<\36\7\2\0\300\360\376\377\177\77\36\0\1\1\0"
133+
"\0\0\0\0\200\200\14\14\300\340\360\363\363\360\340\300\14\14\200\200\1\1\60\60\3\4\10\310\310\10\4\3"
134+
"\60\60\1\1";
110135

111136
/*
112137
Fontname: benji_custom_icons_6x
113138
Copyright:
114139
Glyphs: 8/8
115140
BBX Build Mode: 3
116-
* 6x6 icons take up a lot of memory, theres not enough momory for the required librries
117-
* these are just the ruquired icons stripped for the U8x8 libraries in addition to a few new custom icons
141+
// 6x6 icons libraries take up a lot of memory thus all the icons uses are consolidated into a single library
142+
// these are just the required icons stripped from the U8x8 libraries in addition to a few new custom icons
118143
* 1 = sun
119144
* 2 = skip forward
120145
* 3 = fire
@@ -569,11 +594,20 @@ class FourLineDisplayUsermod : public Usermod {
569594
}
570595

571596
void draw2x2GlyphIcons(){
572-
drawGlyph(1, 0, 69, u8x8_font_open_iconic_weather_2x2, true);//brightness icon
573-
drawGlyph(5, 0, 72, u8x8_font_open_iconic_play_2x2, true);//speed icon
574-
drawGlyph(9, 0, 78, u8x8_font_open_iconic_thing_2x2, true);//intensity icon
575-
drawGlyph(14, 2*lineHeight, 64, u8x8_font_benji_custom_icons_2x2,true);//palette icon
576-
drawGlyph(14, 3*lineHeight, 70, u8x8_font_open_iconic_thing_2x2,true);//effect icon
597+
if(lineHeight == 2){
598+
drawGlyph(1, 0, 1, u8x8_font_benji_custom_icons_2x2, true);//brightness icon
599+
drawGlyph(5, 0, 2, u8x8_font_benji_custom_icons_2x2, true);//speed icon
600+
drawGlyph(9, 0, 3, u8x8_font_benji_custom_icons_2x2, true);//intensity icon
601+
drawGlyph(14, 2*lineHeight, 4, u8x8_font_benji_custom_icons_2x2, true);//palette icon
602+
drawGlyph(14, 3*lineHeight, 5, u8x8_font_benji_custom_icons_2x2, true);//effect icon
603+
}
604+
else{
605+
drawGlyph(2, 0, 69, u8x8_font_open_iconic_weather_1x1);//brightness icon
606+
drawGlyph(6, 0, 72, u8x8_font_open_iconic_play_1x1);//speed icon
607+
drawGlyph(10, 0, 78, u8x8_font_open_iconic_thing_1x1);//intensity icon
608+
drawGlyph(15, 2*lineHeight, 4, u8x8_font_benji_custom_icons_1x1);//palette icon
609+
drawGlyph(15, 3*lineHeight, 70, u8x8_font_open_iconic_thing_1x1);//effect icon
610+
}
577611
}
578612

579613
void drawStatusIcons(){
@@ -606,17 +640,19 @@ class FourLineDisplayUsermod : public Usermod {
606640
char lineBuffer[MAX_JSON_CHARS];
607641
char smallBuffer1[MAX_MODE_LINE_SPACE];
608642
char smallBuffer2[MAX_MODE_LINE_SPACE];
643+
char smallBuffer3[MAX_MODE_LINE_SPACE+1];
609644
uint8_t qComma = 0;
610645
bool insideQuotes = false;
611646
bool spaceHit = false;
612647
uint8_t printedChars = 0;
613648
uint8_t smallChars1 = 0;
614649
uint8_t smallChars2 = 0;
650+
uint8_t smallChars3 = 0;
615651
uint8_t totalCount = 0;
616652
char singleJsonSymbol;
617653

618654
// Find the mode name in JSON
619-
for (size_t i = 0; i < strlen_P(qstring); i++) {
655+
for (size_t i = 0; i < strlen_P(qstring); i++) { //find and get the full text for printing
620656
singleJsonSymbol = pgm_read_byte_near(qstring + i);
621657
if (singleJsonSymbol == '\0') break;
622658
switch (singleJsonSymbol) {
@@ -636,34 +672,47 @@ class FourLineDisplayUsermod : public Usermod {
636672
if ((qComma > inputEffPal)) break;
637673
}
638674

639-
if(printedChars < (MAX_MODE_LINE_SPACE)){
640-
for (;printedChars < (MAX_MODE_LINE_SPACE-1); printedChars++) {lineBuffer[printedChars]=' '; }
641-
lineBuffer[printedChars] = 0;
642-
drawString(1, row*lineHeight, lineBuffer);
643-
lastRedraw = millis();
644-
}else{
645-
for (uint8_t i = 0; i < printedChars; i++){
646-
switch (lineBuffer[i]){
647-
case ' ':
648-
if(i > 4 && !spaceHit) {
649-
spaceHit = true;
650-
break;}
651-
if(!spaceHit) smallBuffer1[smallChars1++] = lineBuffer[i];
652-
if (spaceHit) smallBuffer2[smallChars2++] = lineBuffer[i];
653-
break;
654-
default:
655-
if(!spaceHit) smallBuffer1[smallChars1++] = lineBuffer[i];
656-
if (spaceHit) smallBuffer2[smallChars2++] = lineBuffer[i];
657-
break;
675+
if(lineHeight ==2){ // use this code for 8 line display
676+
if(printedChars < (MAX_MODE_LINE_SPACE)){ // use big font if the text fits
677+
for (;printedChars < (MAX_MODE_LINE_SPACE-1); printedChars++) {lineBuffer[printedChars]=' '; }
678+
lineBuffer[printedChars] = 0;
679+
drawString(1, row*lineHeight, lineBuffer);
680+
lastRedraw = millis();
681+
}else{ // for long names divide the text into 2 lines and print them small
682+
for (uint8_t i = 0; i < printedChars; i++){
683+
switch (lineBuffer[i]){
684+
case ' ':
685+
if(i > 4 && !spaceHit) {
686+
spaceHit = true;
687+
break;}
688+
if(!spaceHit) smallBuffer1[smallChars1++] = lineBuffer[i];
689+
if (spaceHit) smallBuffer2[smallChars2++] = lineBuffer[i];
690+
break;
691+
default:
692+
if(!spaceHit) smallBuffer1[smallChars1++] = lineBuffer[i];
693+
if (spaceHit) smallBuffer2[smallChars2++] = lineBuffer[i];
694+
break;
695+
}
658696
}
659-
}
660-
for (; smallChars1 < (MAX_MODE_LINE_SPACE-1); smallChars1++) smallBuffer1[smallChars1]=' ';
661-
smallBuffer1[smallChars1] = 0;
662-
drawString(1, row*lineHeight, smallBuffer1, true);
663-
for (; smallChars2 < (MAX_MODE_LINE_SPACE-1); smallChars2++) smallBuffer2[smallChars2]=' ';
664-
smallBuffer2[smallChars2] = 0;
665-
drawString(1, row*lineHeight+1, smallBuffer2, true);
666-
lastRedraw = millis();
697+
for (; smallChars1 < (MAX_MODE_LINE_SPACE-1); smallChars1++) smallBuffer1[smallChars1]=' ';
698+
smallBuffer1[smallChars1] = 0;
699+
drawString(1, row*lineHeight, smallBuffer1, true);
700+
for (; smallChars2 < (MAX_MODE_LINE_SPACE-1); smallChars2++) smallBuffer2[smallChars2]=' ';
701+
smallBuffer2[smallChars2] = 0;
702+
drawString(1, row*lineHeight+1, smallBuffer2, true);
703+
lastRedraw = millis();
704+
}
705+
}
706+
else{ // use this code for 4 ling displays
707+
if (printedChars > MAX_MODE_LINE_SPACE) printedChars = MAX_MODE_LINE_SPACE;
708+
for (uint8_t i = 0; i < printedChars; i++){
709+
smallBuffer3[smallChars3++] = lineBuffer[i];
710+
}
711+
712+
for (; smallChars3 < (MAX_MODE_LINE_SPACE); smallChars3++) smallBuffer3[smallChars3]=' ';
713+
smallBuffer3[smallChars3] = 0;
714+
drawString(1, row*lineHeight, smallBuffer3, true);
715+
lastRedraw = millis();
667716
}
668717
}
669718
}
@@ -686,9 +735,9 @@ class FourLineDisplayUsermod : public Usermod {
686735
}
687736

688737
/**
689-
* Allows you to show up to two lines as overlay for a
738+
* Allows you to show one line and a glyph as overlay for a
690739
* period of time.
691-
* Clears the screen and prints on the middle two lines.
740+
* Clears the screen and prints.
692741
*/
693742
void overlay(const char* line1, long showHowLong, byte glyphType) {
694743
if (displayTurnedOff) {
@@ -698,7 +747,10 @@ class FourLineDisplayUsermod : public Usermod {
698747

699748
// Print the overlay
700749
clear();
701-
if (glyphType > 0)drawGlyph(5, 0, glyphType, u8x8_font_benji_custom_icons_6x6, true);
750+
if (glyphType > 0){
751+
if ( lineHeight == 2) drawGlyph(5, 0, glyphType, u8x8_font_benji_custom_icons_6x6, true);
752+
else drawGlyph(7, lineHeight, glyphType, u8x8_font_benji_custom_icons_2x2, true);
753+
}
702754
if (line1) drawString(0, 3*lineHeight, line1);
703755
overlayUntil = millis() + showHowLong;
704756
}

0 commit comments

Comments
 (0)