From 4196f753c8ddd469dc1b58357058a1ee82b3ec4a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 6 Oct 2024 22:40:28 +0200 Subject: [PATCH] Update changelogs --- CHANGELOG.md | 2 +- RELEASENOTES.md | 1 + tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino | 55 +++++++++++++++----- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83ea2fc91..c3497842a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. ### Changed - ESP32 platform update from 2024.09.10 to 2024.09.30 and Framework (Arduino Core) from v3.0.5 to v3.1.0.240926 (#22203) -- Berry improve `persist` dirty data handling +- Berry improve `persist` dirty data handling (#22246) ### Fixed - ESP32 Range Extender compile error with core 3.0.0 (#22205) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 254ea05bf..d35e804a0 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -178,6 +178,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Berry avoid `readbytes()` from crashing when file is too large [#22057](https://github.com/arendst/Tasmota/issues/22057) - Berry energy missing attributes [#22116](https://github.com/arendst/Tasmota/issues/22116) - Berry I2C to prepare M5Stack I2C STM32 based devices [#22143](https://github.com/arendst/Tasmota/issues/22143) +- Berry improve `persist` dirty data handling [#22246](https://github.com/arendst/Tasmota/issues/22246) - ESP32-S3 uDisplay force cache writes to RGB display [#22222](https://github.com/arendst/Tasmota/issues/22222) - LVGL Added OpenHASP icons to font `montserrat-28` [#22048](https://github.com/arendst/Tasmota/issues/22048) - LVGL compilation of lv_menu [#22188](https://github.com/arendst/Tasmota/issues/22188) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino b/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino index 2614ffe0b..992ce549f 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino @@ -65,6 +65,8 @@ struct DALI { uint16_t received_dali_data; // Data received from DALI bus uint8_t pin_rx; uint8_t pin_tx; + uint8_t address; + uint8_t command; uint8_t dimmer; bool power; bool input_ready; @@ -138,6 +140,8 @@ void DaliDigitalWrite(bool pin_value) { } void DaliSendData(uint8_t firstByte, uint8_t secondByte) { + Dali->address = firstByte; + Dali->command = secondByte; if (BROADCAST_DP == firstByte) { Dali->power = (secondByte); // State Dali->dimmer = secondByte; // Value @@ -184,25 +188,31 @@ void DaliPower(uint8_t val) { /***********************************************************/ +void ResponseAppendDali(void) { + ResponseAppend_P(PSTR("\"" D_NAME_DALI "\":{\"Power\":\"%s\",\"Dimmer\":%d,\"Address\":%d,\"Command\":%d}"), + GetStateText(Dali->power), Dali->dimmer, Dali->address, Dali->command); +} + void DaliInput(void) { if (Dali->input_ready) { - uint8_t DALIaddr = Dali->received_dali_data >> 8; - uint8_t DALIcmnd = Dali->received_dali_data; - if (BROADCAST_DP == DALIaddr) { - Dali->power = (DALIcmnd); // State - Dali->dimmer = DALIcmnd; // Value + Dali->address = Dali->received_dali_data >> 8; + Dali->command = Dali->received_dali_data; + if (BROADCAST_DP == Dali->address) { + Dali->power = (Dali->command); // State + Dali->dimmer = Dali->command; // Value } // AddLog(LOG_LEVEL_DEBUG, PSTR("DLI: Received 0x%04X"), Dali->received_dali_data); - Response_P(PSTR("{\"" D_NAME_DALI "\":{\"Power\":\"%s\",\"Dimmer\":%d,\"Address\":%d,\"Command\":%d}}"), - GetStateText(Dali->power), Dali->dimmer, DALIaddr, DALIcmnd); + Response_P(PSTR("{")); + ResponseAppendDali(); + ResponseJsonEnd(); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_NAME_DALI)); Dali->input_ready = false; } } -void DaliPreInit(void) { +void DaliInit(void) { if (!PinUsed(GPIO_DALI_TX) || !PinUsed(GPIO_DALI_RX)) { return; } Dali = (DALI*)calloc(sizeof(DALI), 1); @@ -226,6 +236,10 @@ void DaliPreInit(void) { DaliEnableRxInterrupt(); } +/*********************************************************************************************\ + * Experimental - Not functioning +\*********************************************************************************************/ + bool DaliMqtt(void) { /* XdrvMailbox.topic = topic; @@ -300,6 +314,10 @@ bool DaliMqtt(void) { return true; } +/*********************************************************************************************\ + * Commands +\*********************************************************************************************/ + bool DaliJsonParse(void) { // {"addr":254,"cmd":100} // {"addr":2} @@ -347,10 +365,6 @@ bool DaliJsonParse(void) { return served; } -/*********************************************************************************************\ - * Commands -\*********************************************************************************************/ - void CmndDali(void) { if (XdrvMailbox.data_len > 0) { if (DaliJsonParse()) { @@ -377,7 +391,12 @@ void CmndDaliDimmer(void) { * Presentation \*********************************************************************************************/ - +void DaliShow(bool json) { + if (json) { + ResponseAppend_P(PSTR(",")); + ResponseAppendDali(); + } +} /*********************************************************************************************\ * Interface @@ -387,7 +406,7 @@ bool Xdrv75(uint32_t function) { bool result = false; if (FUNC_INIT == function) { - DaliPreInit(); + DaliInit(); } else if (Dali) { switch (function) { @@ -397,6 +416,14 @@ bool Xdrv75(uint32_t function) { case FUNC_MQTT_DATA: result = DaliMqtt(); break; + case FUNC_JSON_APPEND: + DaliShow(true); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + DaliShow(false); + break; +#endif // USE_WEBSERVER case FUNC_COMMAND: result = DecodeCommand(kDALICommands, DALICommand); break;