Skip to content

Commit

Permalink
Fix GUI timing related divide by zero exception
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Dec 15, 2024
1 parent b3b9699 commit 6fbf8c5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
- MCP23xxx, PCF8574 and Shift595 power control when a display is configured regression from v14.3.0.7
- Display DisplayMode adds a display device while not configured
- GUI intermittent exception on screen updates due to flash access
- GUI timing related divide by zero exception

### Removed

Expand Down
36 changes: 18 additions & 18 deletions tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1885,21 +1885,23 @@ bool HandleRootStatusRefresh(void) {
XsnsXdrvCall(FUNC_WEB_SENSOR);
WSContentSend_P(PSTR("</table>"));

if (!Settings->flag6.gui_no_state_text && // SetOption161 - (GUI) Disable display of state text (1)
TasmotaGlobal.devices_present) {
if (!Settings->flag6.gui_no_state_text) { // SetOption161 - (GUI) Disable display of state text (1)
if (!Web.buttons_non_light_non_shutter) { // Might still be zero on restart so chk if we have at least one
WebGetDeviceCounts();
}
if ((Web.buttons_non_light_non_shutter > 0) &&
( Web.buttons_non_light_non_shutter <= 8)) { // We need at least one non light AND non shutter button

#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
WSContentSend_P(PSTR("{t}<tr>"));
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(TasmotaGlobal.power, 0)) ? PSTR("bold") : PSTR("normal"), 54, GetStateText(bitRead(TasmotaGlobal.power, 0)));
uint32_t fanspeed = GetFanspeed();
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed);
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? PSTR("bold") : PSTR("normal"), 54, (fanspeed) ? svalue : GetStateText(0));
WSContentSend_P(PSTR("</tr></table>"));
} else {
if (IsModuleIfan()) {
WSContentSend_P(PSTR("{t}<tr>"));
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(TasmotaGlobal.power, 0)) ? PSTR("bold") : PSTR("normal"), 54, GetStateText(bitRead(TasmotaGlobal.power, 0)));
uint32_t fanspeed = GetFanspeed();
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed);
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? PSTR("bold") : PSTR("normal"), 54, (fanspeed) ? svalue : GetStateText(0));
WSContentSend_P(PSTR("</tr></table>"));
} else {
#endif // USE_SONOFF_IFAN

if (Web.buttons_non_light_non_shutter <= 8) { // Any non light AND non shutter button
WSContentSend_P(PSTR("{t}<tr>"));
uint32_t cols = Web.buttons_non_light_non_shutter;
uint32_t fontsize = (cols < 5) ? 70 - (cols * 8) : 32;
Expand All @@ -1908,17 +1910,15 @@ bool HandleRootStatusRefresh(void) {
if (bitRead(Web.light_shutter_button_mask, button_idx -1)) { continue; } // Skip non-sequential shutter button
bool power_state = bitRead(TasmotaGlobal.power, button_idx -1);
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), power_state);
WSContentSend_P(HTTP_DEVICE_STATE, 100 / cols, (power_state) ? "bold" : "normal", fontsize, (cols < 5) ? GetStateText(power_state) : svalue);
WSContentSend_P(HTTP_DEVICE_STATE, 100 / cols, (power_state) ? PSTR("bold") : PSTR("normal"), fontsize, (cols < 5) ? GetStateText(power_state) : svalue);
button_ptr++;
if (button_ptr == Web.buttons_non_light_non_shutter) { break; }
if (button_ptr >= Web.buttons_non_light_non_shutter) { break; }
}
WSContentSend_P(PSTR("</tr></table>"));
}

#ifdef USE_SONOFF_IFAN
}
}
#endif // USE_SONOFF_IFAN

}
}

if (1 == Web.slider_update_time) {
Expand Down
18 changes: 5 additions & 13 deletions tasmota/tasmota_xdrv_driver/xdrv_13_display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1852,11 +1852,12 @@ void DisplayLocalSensor(void)
\*********************************************************************************************/

void DisplayInitDriver(void) {
Settings->display_model = 0;
uint32_t display_model = Settings->display_model;
Settings->display_model = 0; // Test if any display_model is available
XdspCall(FUNC_DISPLAY_INIT_DRIVER);

// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings->display_model);

if (Settings->display_model) { // If model found keep using user configured one for backward compatibility
Settings->display_model = display_model;
}
if (!Settings->display_model) { return; }

// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("DSP: Model %d"), Settings->display_model);
Expand Down Expand Up @@ -1891,15 +1892,6 @@ void DisplayInitDriver(void) {
#endif

UpdateDevicesPresent(1);
if (!PinUsed(GPIO_BACKLIGHT)) {
if ((LT_PWM1 == TasmotaGlobal.light_type) && // Single PWM light channel
(4 == Settings->display_model) // ILI9341 legacy
// ((4 == Settings->display_model) || // ILI9341 legacy
// (17 == Settings->display_model)) // Universal - Too invasive in case displays have no backlight pin
) {
UpdateDevicesPresent(-1); // Assume PWM channel is used for backlight
}
}
disp_device = TasmotaGlobal.devices_present;

#ifndef USE_DISPLAY_MODES1TO5
Expand Down

0 comments on commit 6fbf8c5

Please sign in to comment.