4LD + rotary hotfix: corrupted display on esp32

This s a temporary fix for display problems (corrupted display, sometimes crash). These problems exists since 0.14. as display updates are now running in a separate task.
The fix is still incomplete.

If nothing else works, you can use the 0.13.x behavior by compiling with `-D FLD_ESP32_NO_THREADS`

* fixing a few unsafe string operations and non-initialized strings
* fix max length for "two lines" names
* make sure that display methods are exiting early if display is not configured
* rotary_ALT : additional checks to ensure that drawing on the display does not overlap with redraw
* added some safeguards to prevent overlapping display redraw operations
--> Actually this should use semaphore/mutex instead of global booleans -> Still on my toDo list.
This commit is contained in:
Frank
2023-02-02 18:37:13 +01:00
parent b01893e8fe
commit e1f14628b0
4 changed files with 134 additions and 46 deletions

View File

@@ -383,7 +383,7 @@ public:
buttonWaitTime = 0;
char newState = select_state + 1;
bool changedState = false;
char lineBuffer[64];
char lineBuffer[64] = { '\0' };
do {
// finde new state
switch (newState) {
@@ -525,7 +525,8 @@ public:
bri = max(min((increase ? bri+fadeAmount : bri-fadeAmount), 255), 0);
lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY
display->updateBrightness();
if (display->canDraw()) // only draw if nothing else is drawing
display->updateBrightness();
#endif
}
@@ -554,7 +555,8 @@ public:
}
lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY
display->showCurrentEffectOrPalette(effectCurrent, JSON_mode_names, 3);
if (display->canDraw()) // only draw if nothing else is drawing
display->showCurrentEffectOrPalette(effectCurrent, JSON_mode_names, 3);
#endif
}
@@ -582,7 +584,8 @@ public:
}
lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY
display->updateSpeed();
if (display->canDraw()) // only draw if nothing else is drawing
display->updateSpeed();
#endif
}
@@ -610,7 +613,8 @@ public:
}
lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY
display->updateIntensity();
if (display->canDraw()) // only draw if nothing else is drawing
display->updateIntensity();
#endif
}
@@ -688,7 +692,8 @@ public:
}
lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY
display->showCurrentEffectOrPalette(effectPalette, JSON_palette_names, 2);
if (display->canDraw()) // only draw if nothing else is drawing
display->showCurrentEffectOrPalette(effectPalette, JSON_palette_names, 2);
#endif
}
@@ -764,7 +769,7 @@ public:
if (presetHigh && presetLow && presetHigh > presetLow) {
StaticJsonDocument<64> root;
char str[64] = { '\0' };
sprintf_P(str, PSTR("%d~%d~%s"), presetLow, presetHigh, increase?"":"-");
snprintf_P(str, 64, PSTR("%d~%d~%s"), presetLow, presetHigh, increase?"":"-");
root["ps"] = str;
deserializeState(root.as<JsonObject>(), CALL_MODE_BUTTON_PRESET);
/*