From d736bf3b05d7e36b290e3fc5372569dea629d051 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Thu, 21 Nov 2024 12:29:46 +0100 Subject: [PATCH] upd --- CHANGELOG.md | 2 + RELEASENOTES.md | 4 +- tasmota/include/tasmota_types.h | 2 +- .../xdrv_01_9_webserver.ino | 128 ++++++++++++------ 4 files changed, 91 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cef53e8b5c0..5563006e8bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ 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 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ee2aaedf125b..c1707f58ef8f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -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 @@ -130,6 +131,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Support for HLK-LD2410S 24GHz smart wave motion sensor [#22253](https://github.com/arendst/Tasmota/issues/22253) - Support for US AQI and EPA AQI in PMS5003x sensors [#22294](https://github.com/arendst/Tasmota/issues/22294) - Support for MS5837 pressure and temperature sensor [#22376](https://github.com/arendst/Tasmota/issues/22376) +- Support for TM1640 based IoTTimer by Stefan Oskamp [#21376](https://github.com/arendst/Tasmota/issues/21376) - HLK-LD2410 Engineering mode [#21880](https://github.com/arendst/Tasmota/issues/21880) - Mitsubishi Electric HVAC Operation time for MiElHVAC [#22334](https://github.com/arendst/Tasmota/issues/22334) - Mitsubishi Electric HVAC Outdoor Temperature for MiElHVAC [#22345](https://github.com/arendst/Tasmota/issues/22345) diff --git a/tasmota/include/tasmota_types.h b/tasmota/include/tasmota_types.h index df347846ce7d..dceb236ecad6 100644 --- a/tasmota/include/tasmota_types.h +++ b/tasmota/include/tasmota_types.h @@ -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 diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 3bc5634c5d89..86a88d6d4c99 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -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); // "" @@ -1428,6 +1454,10 @@ void HandleRoot(void) { } WSContentSend_P(PSTR("
")); + + 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("")); + 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}")); + 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("")); + } + } + } + if (1 == Web.slider_update_time) { Web.slider_update_time = 0; }