Skip to content

Commit 06f2f9a

Browse files
authored
Merge pull request wled#1771 from Aircoookie/mergedev_210222
Update dev
2 parents 5c6cb41 + 37d5b91 commit 06f2f9a

File tree

14 files changed

+367
-2956
lines changed

14 files changed

+367
-2956
lines changed

package-lock.json

Lines changed: 6 additions & 2881 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platformio.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ default_envs = travis_esp8266, travis_esp32
3030
; default_envs = d1_mini_5CH_Shojo_PCB
3131
; default_envs = wemos_shield_esp32
3232
; default_envs = m5atom
33-
; default_envs = esp32_poe
33+
; default_envs = esp32_eth
3434

3535
src_dir = ./wled00
3636
data_dir = ./wled00/data
@@ -279,12 +279,12 @@ lib_ignore =
279279
ESPAsyncTCP
280280
ESPAsyncUDP
281281

282-
[env:esp32_poe]
282+
[env:esp32_eth]
283283
board = esp32-poe
284284
285285
upload_speed = 921600
286286
build_unflags = ${common.build_unflags}
287-
build_flags = ${common.build_flags_esp32} -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1
287+
build_flags = ${common.build_flags_esp32} -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1
288288
lib_ignore =
289289
ESPAsyncTCP
290290
ESPAsyncUDP

platformio_override.ini.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ default_envs = WLED_tasmota_1M
1111
board = esp01_1m
1212
platform = ${common.platform_wled_default}
1313
platform_packages = ${common.platform_packages}
14-
board_build.ldscript = ${common.ldscript_1m0m}
14+
board_build.ldscript = ${common.ldscript_1m128k}
1515
build_unflags = ${common.build_unflags}
1616
build_flags = ${common.build_flags_esp8266}
1717
; *********************************************************************

usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
// OLED displays to provide a four line display
1111
// for WLED.
1212
//
13-
// This Usermod works best, by far, when coupled with RotaryEncoderUIUsermod.
13+
// Dependencies
14+
// * This usermod REQURES the ModeSortUsermod
15+
// * This Usermod works best, by far, when coupled
16+
// with RotaryEncoderUIUsermod.
1417
//
1518
// Make sure to enable NTP and set your time zone in WLED Config | Time.
1619
//
@@ -124,6 +127,9 @@ class FourLineDisplayUsermod : public Usermod {
124127

125128
char lineBuffer[LINE_BUFFER_SIZE];
126129

130+
char **modes_qstrings = nullptr;
131+
char **palettes_qstrings = nullptr;
132+
127133
// If display does not work or looks corrupted check the
128134
// constructor reference:
129135
// https://github.com/olikraus/u8g2/wiki/u8x8setupcpp
@@ -140,6 +146,10 @@ class FourLineDisplayUsermod : public Usermod {
140146
u8x8.setContrast(10); //Contrast setup will help to preserve OLED lifetime. In case OLED need to be brighter increase number up to 255
141147
u8x8.setFont(u8x8_font_chroma48medium8_r);
142148
u8x8.DRAW_STRING(0, 0*LINE_HEIGHT, "Loading...");
149+
150+
ModeSortUsermod *modeSortUsermod = (ModeSortUsermod*) usermods.lookup(USERMOD_ID_MODE_SORT);
151+
modes_qstrings = modeSortUsermod->getModesQStrings();
152+
palettes_qstrings = modeSortUsermod->getPalettesQStrings();
143153
}
144154

145155
// gets called every time WiFi is (re-)connected. Initialize own network
@@ -254,7 +264,7 @@ class FourLineDisplayUsermod : public Usermod {
254264
}
255265

256266
// Third row with mode name
257-
showCurrentEffectOrPalette(JSON_mode_names, 2, knownMode);
267+
showCurrentEffectOrPalette(modes_qstrings[knownMode], 2);
258268

259269
switch(lineThreeType) {
260270
case FLD_LINE_3_BRIGHTNESS:
@@ -270,7 +280,7 @@ class FourLineDisplayUsermod : public Usermod {
270280
u8x8.DRAW_STRING(1, 3*LINE_HEIGHT, lineBuffer);
271281
break;
272282
case FLD_LINE_3_PALETTE:
273-
showCurrentEffectOrPalette(JSON_palette_names, 3, knownPalette);
283+
showCurrentEffectOrPalette(palettes_qstrings[knownPalette], 3);
274284
break;
275285
}
276286

@@ -289,35 +299,21 @@ class FourLineDisplayUsermod : public Usermod {
289299
* TODO: Should we cache the current effect and
290300
* TODO: palette name? This seems expensive.
291301
*/
292-
void showCurrentEffectOrPalette(const char json[], uint8_t row, uint8_t desiredEntry) {
293-
uint8_t qComma = 0;
294-
bool insideQuotes = false;
295-
// advance past the mark for markLineNum that may exist.
302+
void showCurrentEffectOrPalette(char *qstring, uint8_t row) {
296303
uint8_t printedChars = 1;
297304
char singleJsonSymbol;
298-
299-
// Find the mode name in JSON
300-
for (size_t i = 0; i < strlen_P(json); i++) {
301-
singleJsonSymbol = pgm_read_byte_near(json + i);
302-
switch (singleJsonSymbol) {
303-
case '"':
304-
insideQuotes = !insideQuotes;
305-
break;
306-
case '[':
307-
case ']':
305+
int i = 0;
306+
while (true) {
307+
singleJsonSymbol = pgm_read_byte_near(qstring + i);
308+
if (singleJsonSymbol == '"' || singleJsonSymbol == '\0' ) {
308309
break;
309-
case ',':
310-
qComma++;
311-
default:
312-
if (!insideQuotes || (qComma != desiredEntry)) {
313-
break;
314-
}
315-
u8x8.DRAW_GLYPH(printedChars, row * LINE_HEIGHT, singleJsonSymbol);
316-
printedChars++;
317310
}
318-
if ((qComma > desiredEntry) || (printedChars > u8x8.getCols() - 2)) {
311+
u8x8.DRAW_GLYPH(printedChars, row * LINE_HEIGHT, singleJsonSymbol);
312+
printedChars++;
313+
if ( (printedChars > u8x8.getCols() - 2)) {
319314
break;
320315
}
316+
i++;
321317
}
322318
}
323319

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Mode Sort
2+
3+
v2 usermod that provides data about modes and
4+
palettes to other usermods. Notably it provides:
5+
* A direct method for a mode or palette name
6+
* Ability to retrieve mode and palette names in
7+
alphabetical order
8+
9+
```char **getModesQStrings()```
10+
11+
Provides an array of char* (pointers) to the names of the
12+
palettes within JSON_mode_names, in the same order as
13+
JSON_mode_names. These strings end in double quote (")
14+
(or \0 if there is a problem).
15+
16+
```byte *getModesAlphaIndexes()```
17+
18+
An array of byte designating the indexes of names of the
19+
modes in alphabetical order. "Solid" will always remain
20+
at the front of the list.
21+
22+
```char **getPalettesQStrings()```
23+
24+
Provides an array of char* (pointers) to the names of the
25+
palettes within JSON_palette_names, in the same order as
26+
JSON_palette_names. These strings end in double quote (")
27+
(or \0 if there is a problem).
28+
29+
```byte *getPalettesAlphaIndexes()```
30+
31+
An array of byte designating the indexes of names of the
32+
palettes in alphabetical order. "Default" and those
33+
starting with "(" will always remain at the front of the list.

0 commit comments

Comments
 (0)