-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from echavet/cycle_mgmt_refactor
Cycle management refactor
- Loading branch information
Showing
3 changed files
with
46 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "cn105.h" | ||
|
||
|
||
bool CN105Climate::isCycleRunning() { | ||
return cycleRunning; | ||
} | ||
|
||
void CN105Climate::deferCycle() { | ||
|
||
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG | ||
uint32_t delay = DEFER_SCHEDULE_UPDATE_LOOP_DELAY * 3; | ||
#else | ||
uint32_t delay = DEFER_SCHEDULE_UPDATE_LOOP_DELAY; | ||
#endif | ||
|
||
ESP_LOGI(LOG_CYCLE_TAG, "Defering cycle trigger of %d ms", delay); | ||
// forces the lastCompleteCycle offset of delay ms to allow a longer rest time | ||
this->lastCompleteCycle += delay; | ||
|
||
} | ||
void CN105Climate::cycleStarted() { | ||
ESP_LOGI(LOG_CYCLE_TAG, "1: Cycle start"); | ||
this->lastRequestInfo = CUSTOM_MILLIS; | ||
cycleRunning = true; | ||
} | ||
void CN105Climate::cycleEnded() { | ||
ESP_LOGI(LOG_CYCLE_TAG, "6: Cycle ends"); | ||
cycleRunning = false; | ||
// a complete cycle is done | ||
this->lastCompleteCycle = CUSTOM_MILLIS; | ||
} | ||
|
||
bool CN105Climate::hasUpdateIntervalPassed() { | ||
return (CUSTOM_MILLIS - this->lastCompleteCycle) > this->update_interval_; | ||
} | ||
|
||
bool CN105Climate::didCycleTimeOut() { | ||
return (CUSTOM_MILLIS - this->lastRequestInfo) > (5 * this->update_interval_) + 4000; | ||
} |