Skip to content

Commit

Permalink
Fix GUI display power button regression from v14.3.0.5 (#15788)
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Dec 12, 2024
1 parent 7834dbf commit 9650d0f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.

### Fixed
- ESP32 rules operation priority regression from v13.3.0.4 (#22636)
- GUI display power button regression from v14.3.0.5 (#15788)

### Removed

Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
### Changed

### Fixed
- GUI display power button regression from v14.3.0.5 [#15788](https://github.com/arendst/Tasmota/issues/15788)
- ESP32 rules operation priority regression from v13.3.0.4 [#22636](https://github.com/arendst/Tasmota/issues/22636)

### Removed
46 changes: 21 additions & 25 deletions tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1257,33 +1257,39 @@ int32_t IsShutterWebButton(uint32_t idx) {

/*-------------------------------------------------------------------------------------------*/

void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light_non_shutter, uint32_t &shutter_button_mask) {
void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light_non_shutter, uint32_t &light_shutter_button_mask) {
light_shutter_button_mask = 0; // Bitmask for each light and/or shutter button
buttons_non_light = TasmotaGlobal.devices_present;

#ifdef USE_LIGHT
// Chk for reduced toggle buttons used by lights
if (TasmotaGlobal.light_type) {
// Find and skip light buttons (Lights are controlled by the last TasmotaGlobal.devices_present (or 2))
buttons_non_light = LightDevice() -1;
uint32_t light_device = LightDevice();
uint32_t light_devices = LightDevices();
buttons_non_light -= light_devices;
for (uint32_t button_idx = light_device; button_idx < (light_device + light_devices); button_idx++) {
light_shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask
}
}
#endif // USE_LIGHT

buttons_non_light_non_shutter = buttons_non_light;
shutter_button_mask = 0; // Bitmask for each button
#ifdef USE_SHUTTER
// Chk for reduced toggle buttons used by shutters
// Find and skip dedicated shutter buttons
if (buttons_non_light && Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (uint32_t button_idx = 1; button_idx <= buttons_non_light; button_idx++) {
if (IsShutterWebButton(button_idx) != 0) {
buttons_non_light_non_shutter--;
shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask
light_shutter_button_mask |= (1 << (button_idx -1)); // Set button bit in bitmask
}
}
}
#endif // USE_SHUTTER

// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HTP: DP %d, BNL %d, BNLNS %d, SB %08X"), TasmotaGlobal.devices_present, buttons_non_light, buttons_non_light_non_shutter, shutter_button);
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HTP: DP %d, BNL %d, BNLNS %d, SB %08X"),
// TasmotaGlobal.devices_present, buttons_non_light, buttons_non_light_non_shutter, light_shutter_button_mask);
}

#ifdef USE_LIGHT
Expand Down Expand Up @@ -1368,8 +1374,8 @@ void HandleRoot(void) {
if (TasmotaGlobal.devices_present) {
uint32_t buttons_non_light;
uint32_t buttons_non_light_non_shutter;
uint32_t shutter_button_mask;
WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button_mask);
uint32_t light_shutter_button_mask;
WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, light_shutter_button_mask);
uint32_t button_idx = 1;

if (buttons_non_light_non_shutter) { // Any non light AND non shutter button - Show toggle buttons
Expand Down Expand Up @@ -1397,12 +1403,8 @@ void HandleRoot(void) {
if (buttons_non_light_non_shutter % rows) { cols++; }

uint32_t button_ptr = 0;
for (button_idx = 1; button_idx <= buttons_non_light; button_idx++) {

#ifdef USE_SHUTTER
if (bitRead(shutter_button_mask, button_idx -1)) { continue; } // Skip non-sequential shutter button
#endif // USE_SHUTTER

for (button_idx = 1; button_idx <= TasmotaGlobal.devices_present; button_idx++) {
if (bitRead(light_shutter_button_mask, button_idx -1)) { continue; } // Skip non-sequential light and/or shutter button
bool set_button = ((button_idx <= MAX_BUTTON_TEXT) && strlen(GetWebButton(button_idx -1)));
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), button_idx);
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / cols, button_idx, button_idx,
Expand Down Expand Up @@ -1451,15 +1453,13 @@ void HandleRoot(void) {
WSContentSend_P(PSTR("</tr>"));
}
WSContentSend_P(PSTR("</table>"));

if (1 == button_idx) { // No power/display button
button_idx = shutter_button_idx +2;
}
}
#endif // USE_SHUTTER

#ifdef USE_LIGHT
if (TasmotaGlobal.light_type) { // Any light - Show light button and slider(s)
button_idx = LightDevice();

WSContentSend_P(HTTP_TABLE100); // "<table style='width:100%%'>"

uint8_t light_subtype = TasmotaGlobal.light_type &7;
Expand Down Expand Up @@ -1904,19 +1904,15 @@ bool HandleRootStatusRefresh(void) {

uint32_t buttons_non_light;
uint32_t buttons_non_light_non_shutter;
uint32_t shutter_button_mask;
WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button_mask);
uint32_t light_shutter_button_mask;
WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, light_shutter_button_mask);

if (buttons_non_light_non_shutter <= 8) { // Any non light AND non shutter button
WSContentSend_P(PSTR("{t}<tr>"));
uint32_t cols = buttons_non_light_non_shutter;
uint32_t fontsize = (cols < 5) ? 70 - (cols * 8) : 32;
for (uint32_t idx = 1; idx <= buttons_non_light; idx++) {

#ifdef USE_SHUTTER
if (bitRead(shutter_button_mask, idx -1)) { continue; } // Skip non-sequential shutter button
#endif // USE_SHUTTER

for (uint32_t idx = 1; idx <= TasmotaGlobal.devices_present; idx++) {
if (bitRead(light_shutter_button_mask, idx -1)) { continue; } // Skip non-sequential shutter button
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(TasmotaGlobal.power, idx -1));
WSContentSend_P(HTTP_DEVICE_STATE, 100 / cols, (bitRead(TasmotaGlobal.power, idx -1)) ? PSTR("bold") : PSTR("normal"), fontsize,
(cols < 5) ? GetStateText(bitRead(TasmotaGlobal.power, idx -1)) : svalue);
Expand Down
10 changes: 6 additions & 4 deletions tasmota/tasmota_xdrv_driver/xdrv_04_light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct LIGHT {
uint8_t random = 0;
uint8_t subtype = 0; // LST_ subtype
uint8_t device = 0;
uint8_t devices = 0;
uint8_t old_power = 1;
uint8_t wakeup_active = 0; // 0=inctive, 1=on-going, 2=about to start, 3=will be triggered next cycle
uint8_t fixed_color_index = 1;
Expand Down Expand Up @@ -294,10 +295,7 @@ uint8_t LightDevice(void)
}

uint32_t LightDevices(void) {
if (0 == Light.device) {
return 0;
}
return TasmotaGlobal.devices_present - Light.device +1; // Make external
return Light.devices; // Make external
}

static uint32_t min3(uint32_t a, uint32_t b, uint32_t c) {
Expand Down Expand Up @@ -1182,6 +1180,8 @@ void LightSetScheme(uint32_t scheme) {

void LightInit(void)
{
uint32_t devices_present = TasmotaGlobal.devices_present;

// move white blend mode from deprecated `RGBWWTable` to `SetOption105`
if (0 == Settings->rgbwwTable[4]) {
Settings->flag4.white_blend_mode = true;
Expand Down Expand Up @@ -1256,6 +1256,8 @@ void LightInit(void)
Light.fade_initialized = true; // consider fade intialized starting from black
}

Light.devices = TasmotaGlobal.devices_present - Light.device +1; // Last time that devices_present is not increments by display

LightUpdateColorMapping();
}

Expand Down

0 comments on commit 9650d0f

Please sign in to comment.