From e1587feb607ccb344353454f5f8d4f7be899e0be Mon Sep 17 00:00:00 2001 From: loetmeister Date: Wed, 30 Jun 2021 22:17:14 +0200 Subject: [PATCH] allow to set idle HBWDeltaT output manually added option for error state --- HBW-CC-DT3-T6/HBW-CC-DT3-T6.ino | 5 ++++- HBW-CC-DT3-T6/HBWDeltaT.cpp | 18 ++++++++++++++++-- HBW-CC-DT3-T6/HBWDeltaT.h | 5 +++-- HBW-CC-DT3-T6/HBW_CC_DT3_T6.xml | 11 ++++++++++- HBW-CC-DT3-T6/readme.txt | 13 +++++++------ 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/HBW-CC-DT3-T6/HBW-CC-DT3-T6.ino b/HBW-CC-DT3-T6/HBW-CC-DT3-T6.ino index a08695f..100c5c5 100644 --- a/HBW-CC-DT3-T6/HBW-CC-DT3-T6.ino +++ b/HBW-CC-DT3-T6/HBW-CC-DT3-T6.ino @@ -20,10 +20,13 @@ // - add config for output change frequency (CYCLE_TIME) // v0.45 // - using config LED for Tx & Rx indicator +// v0.50 +// - allow to set HBWDeltaT output when mode is IDLE/inactive (no temperature received) +// - option for error state (set OFF/ON), when error_temperature is received #define HARDWARE_VERSION 0x01 -#define FIRMWARE_VERSION 0x002D +#define FIRMWARE_VERSION 0x0032 #define HMW_DEVICETYPE 0x9C //device ID (make sure to import .xml into FHEM) #define NUMBER_OF_TEMP_CHAN 6 // input channels - 1-wire temperature sensors diff --git a/HBW-CC-DT3-T6/HBWDeltaT.cpp b/HBW-CC-DT3-T6/HBWDeltaT.cpp index c55021e..5c6c056 100644 --- a/HBW-CC-DT3-T6/HBWDeltaT.cpp +++ b/HBW-CC-DT3-T6/HBWDeltaT.cpp @@ -96,6 +96,17 @@ uint8_t HBWDeltaTx::get(uint8_t* data) }; +void HBWDeltaT::set(HBWDevice* device, uint8_t length, uint8_t const * const data) +{ + // allow to set manually, only when 'mode' is inactive (i.e. no T1 & T2 temperature received) + // output will change not faster than "output_change_wait_time" + if (!stateFlags.element.mode) + { + nextState = *data == 0 ? OFF : ON; + } +}; + + /* standard public function - returns length of data array. Data array contains current channel reading */ uint8_t HBWDeltaT::get(uint8_t* data) { @@ -188,8 +199,11 @@ bool HBWDeltaT::calculateNewState() int16_t t2 = deltaT2->currentTemperature; // check if valid temps are available - if (t1 <= ERROR_TEMP || t2 <= ERROR_TEMP) { - nextState = OFF; + if (t1 == DEFAULT_TEMP || t2 == DEFAULT_TEMP) { // don't overwrite 'nextState' (keep manual state) if no temp was ever received + return false; + } + if (t1 == ERROR_TEMP || t2 == ERROR_TEMP) { // set output to error state, when sensor got lost (error_temperature is received) + nextState = config->error_state ? OFF : ON; return false; } diff --git a/HBW-CC-DT3-T6/HBWDeltaT.h b/HBW-CC-DT3-T6/HBWDeltaT.h index 030a609..e86ad5e 100644 --- a/HBW-CC-DT3-T6/HBWDeltaT.h +++ b/HBW-CC-DT3-T6/HBWDeltaT.h @@ -42,7 +42,8 @@ struct hbw_config_DeltaT { uint8_t n_enableHysMaxT1:1; // apply hysteresis on maxT1, 1=off (default) 0=on uint8_t n_enableHysMinT2:1; // apply hysteresis on minT2, 1=off (default) 0=on uint8_t n_enableHysOFF:1; // apply hysteresis on OFF transition, too. 1=off (default) 0=on - uint8_t :2; //fillup + uint8_t error_state:1; // set output OFF or ON at error state (defaut OFF) + uint8_t :1; //fillup }; // config of one DeltaTx channel, address step 1 @@ -74,7 +75,7 @@ class HBWDeltaT : public HBWChannel { HBWDeltaT(uint8_t _pin, HBWDeltaTx* _delta_t1, HBWDeltaTx* _delta_t2, hbw_config_DeltaT* _config); virtual void loop(HBWDevice*, uint8_t channel); virtual uint8_t get(uint8_t* data); - //virtual void set(HBWDevice*, uint8_t length, uint8_t const * const data); //TODO: allow to set when mode inactive? + virtual void set(HBWDevice*, uint8_t length, uint8_t const * const data); virtual void afterReadConfig(); private: diff --git a/HBW-CC-DT3-T6/HBW_CC_DT3_T6.xml b/HBW-CC-DT3-T6/HBW_CC_DT3_T6.xml index 20a4433..9d42cc7 100644 --- a/HBW-CC-DT3-T6/HBW_CC_DT3_T6.xml +++ b/HBW-CC-DT3-T6/HBW_CC_DT3_T6.xml @@ -4,7 +4,7 @@ - + @@ -297,6 +297,15 @@ + + + + +
+ +