Add command `SetOption161 1` to disable display of state text (#22515)

This commit is contained in:
Theo Arends 2024-11-21 12:13:14 +01:00
parent fe658424b8
commit 6d0467489a
4 changed files with 89 additions and 45 deletions

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## [14.3.0.7]
### Added
- Support for TM1640 based IoTTimer by Stefan Oskamp (#21376)
- Command `SetOption161 1` to disable display of state text (#22515)
### Breaking Changed

View File

@ -116,7 +116,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
## Changelog v14.3.0.7
### Added
- Add command ``WebColor20`` to control color of Button when Off
- Command `WebColor20` to control color of Button when Off
- Command `SetOption161 1` to disable display of state text (#22515)
- DALI support for short addresses (gear) and groups
- DALI command `DaliGear` to set max found gear to speed up scan response
- DALI command `DaliGroup` to add gear to groups

View File

@ -195,7 +195,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t mqtt_disable_modbus : 1; // bit 12 (v13.3.0.5) - SetOption158 - (MQTT) Disable publish ModbusReceived MQTT messages (1), you must use event trigger rules instead
uint32_t counter_both_edges : 1; // bit 13 (v13.3.0.5) - SetOption159 - (Counter) Enable counting on both rising and falling edge (1)
uint32_t ld2410_use_pin : 1; // bit 14 (v14.3.0.2) - SetOption160 - (LD2410) Disable generate moving event by sensor report - use LD2410 out pin for events (1)
uint32_t spare15 : 1; // bit 15
uint32_t gui_no_state_text : 1; // bit 15 (v14.3.0.7) - SetOption161 - (GUI) Disable display of state text (1)
uint32_t spare16 : 1; // bit 16
uint32_t spare17 : 1; // bit 17
uint32_t spare18 : 1; // bit 18

View File

@ -1238,6 +1238,53 @@ void HandleWifiLogin(void) {
WSContentStop();
}
#ifdef USE_SHUTTER
/*-------------------------------------------------------------------------------------------*/
int32_t IsShutterWebButton(uint32_t idx) {
/* 0: Not a shutter, 1..4: shutter up idx, -1..-4: shutter down idx */
int32_t ShutterWebButton = 0;
if (Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present ; i++) {
if (ShutterGetStartRelay(i) && ((ShutterGetStartRelay(i) == idx) || (ShutterGetStartRelay(i) == (idx-1)))) {
ShutterWebButton = (ShutterGetStartRelay(i) == idx) ? (i+1): (-1-i);
break;
}
}
}
return ShutterWebButton;
}
#endif // USE_SHUTTER
/*-------------------------------------------------------------------------------------------*/
void WebGetDeviceCounts(uint32_t &buttons_non_light, uint32_t &buttons_non_light_non_shutter, uint32_t &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;
}
#endif // USE_LIGHT
buttons_non_light_non_shutter = buttons_non_light;
shutter_button = 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 |= (1 << (button_idx -1)); // Set button bit in bitmask
}
}
}
#endif // USE_SHUTTER
}
#ifdef USE_LIGHT
/*-------------------------------------------------------------------------------------------*/
@ -1318,33 +1365,12 @@ void HandleRoot(void) {
#ifndef FIRMWARE_MINIMAL
if (TasmotaGlobal.devices_present) {
uint32_t buttons_non_light = TasmotaGlobal.devices_present;
uint32_t buttons_non_light;
uint32_t buttons_non_light_non_shutter;
uint32_t shutter_button;
WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button);
uint32_t button_idx = 1;
#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;
}
#endif // USE_LIGHT
uint32_t buttons_non_light_non_shutter = buttons_non_light;
#ifdef USE_SHUTTER
// Chk for reduced toggle buttons used by shutters
uint32_t shutter_button = 0; // Bitmask for each button
// Find and skip dedicated shutter buttons
if (buttons_non_light && Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (button_idx = 1; button_idx <= buttons_non_light; button_idx++) {
if (IsShutterWebButton(button_idx) != 0) {
buttons_non_light_non_shutter--;
shutter_button |= (1 << (button_idx -1)); // Set button bit in bitmask
}
}
}
#endif // USE_SHUTTER
if (buttons_non_light_non_shutter) { // Any non light AND non shutter button
// Display toggle buttons
WSContentSend_P(HTTP_TABLE100); // "<table style='width:100%%'>"
@ -1428,6 +1454,10 @@ void HandleRoot(void) {
}
WSContentSend_P(PSTR("</table>"));
if (1 == button_idx) {
button_idx = shutter_button_idx;
}
}
#endif // USE_SHUTTER
@ -1625,24 +1655,6 @@ void HandleRoot(void) {
* HandleRootStatusRefresh
\*-------------------------------------------------------------------------------------------*/
#ifdef USE_SHUTTER
int32_t IsShutterWebButton(uint32_t idx) {
/* 0: Not a shutter, 1..4: shutter up idx, -1..-4: shutter down idx */
int32_t ShutterWebButton = 0;
if (Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present ; i++) {
if (ShutterGetStartRelay(i) && ((ShutterGetStartRelay(i) == idx) || (ShutterGetStartRelay(i) == (idx-1)))) {
ShutterWebButton = (ShutterGetStartRelay(i) == idx) ? (i+1): (-1-i);
break;
}
}
}
return ShutterWebButton;
}
#endif // USE_SHUTTER
/*-------------------------------------------------------------------------------------------*/
bool WebUpdateSliderTime(void) {
uint32_t slider_update_time = millis();
if (0 == Web.slider_update_time) {
@ -1879,6 +1891,36 @@ 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)
bool show_state = (TasmotaGlobal.devices_present);
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) { show_state = false; }
#endif // USE_SONOFF_IFAN
if (show_state) {
uint32_t buttons_non_light;
uint32_t buttons_non_light_non_shutter;
uint32_t shutter_button;
WebGetDeviceCounts(buttons_non_light, buttons_non_light_non_shutter, shutter_button);
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, idx -1)) { continue; } // Skip non-sequential shutter button
#endif // USE_SHUTTER
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);
}
WSContentSend_P(PSTR("</tr></table>"));
}
}
}
if (1 == Web.slider_update_time) {
Web.slider_update_time = 0;
}