diff --git a/source/shoh/src/threads/relay/Relay.cpp b/source/shoh/src/threads/relay/Relay.cpp index d6013f8..0f90beb 100644 --- a/source/shoh/src/threads/relay/Relay.cpp +++ b/source/shoh/src/threads/relay/Relay.cpp @@ -83,6 +83,7 @@ void Relay::taskFunction() { _qm->receive(ThreadCommon::QueueManager::relay_event_master, &data, portMAX_DELAY); parseEvent(&data); + utilizeEventData(); } } @@ -111,6 +112,37 @@ void Relay::parseEvent(Event* d) } } +void Relay::utilizeEventData() +{ + PowerMode pm = POWER_0; + /* If setpoint is lower than ext_temp, + * none of below checks will pass and function + * shall turn OFF the heater. + * When setpoint is always higher than ext_temp, + * we can use up to three stages determine how + * powerful the output of the signal should be. + */ + int8_t diff = setpoint - ext_temp; + + if (diff >= 10) + { + pm = POWER_3; + } + + if (diff >= 5) + { + pm = POWER_2; + } + + if (diff >= 1) + { + pm = POWER_1; + } + + setPowerMode(pm); + return; +} + void thread_relay(void * pvParams) { ThreadCommon::CommonManagers * manager = static_cast(pvParams); diff --git a/source/shoh/src/threads/relay/Relay.h b/source/shoh/src/threads/relay/Relay.h index 7f92424..5ee61d4 100644 --- a/source/shoh/src/threads/relay/Relay.h +++ b/source/shoh/src/threads/relay/Relay.h @@ -45,6 +45,7 @@ public: virtual ~Relay(); void taskFunction(); void setPowerMode(PowerMode pm); + void utilizeEventData(); private: ThreadCommon::QueueManager* _qm; RelayDevice relays [2] = {{0, 24, 0},