#include <DeepSleep.h>
Public Member Functions | |
MyDeepSleep (MyOptions &options, MyData &data) | |
bool | begin () |
bool | haveToSleep () |
void | sleep (bool start=true) |
Protected Attributes | |
MyOptions & | myOptions |
Reference to the options. | |
MyData & | myData |
Reference to the data. | |
Class to read/save a deepsleep counter and start the deepsleep mode if the voltage is too low.
Definition at line 30 of file DeepSleep.h.
bool MyDeepSleep::begin | ( | ) |
Read the deepsleep counter from the RTC memory. Use a simple random value variable to identify if the counter is still initialized
Definition at line 59 of file DeepSleep.h.
References MyData::RtcData::deepSleepStartSec, MyOptions::deepSleepTimeSec, MyOptions::isDeepSleepEnabled, MyData::RtcData::isValid(), myData, MyDbg(), myOptions, NO_DEEP_SLEEP_STARTUP_TIME, MyOptions::powerSaveModeVoltage, MyData::rtcData, secondsSincePowerOn(), sleep(), and MyData::voltage.
Referenced by setup().
bool MyDeepSleep::haveToSleep | ( | ) |
Check if the configured time has elapsed and the voltage is too low then go into deep sleep.
Definition at line 90 of file DeepSleep.h.
References MyOptions::activeTimeSec, MyData::awakeTimeOffsetSec, MyOptions::isDeepSleepEnabled, myData, myOptions, NO_DEEP_SLEEP_STARTUP_TIME, MyOptions::powerSaveModeVoltage, secondsSincePowerOn(), MyData::secondsToDeepSleep, and MyData::voltage.
Referenced by loop().
void MyDeepSleep::sleep | ( | bool | start = true | ) |
Entering the DeepSleep mode. Be sure we have connected the RST pin to the D0 pin for wakeup.
Definition at line 106 of file DeepSleep.h.
References MyData::RtcData::aktiveTimeSec, MyData::RtcData::deepSleepStartSec, MyData::RtcData::deepSleepTimeSec, myData, MyDbg(), myOptions, MyOptions::powerCheckIntervalSec, MyData::rtcData, secondsSincePowerOn(), and MyData::RtcData::setCRC().
Referenced by begin(), and loop().