#ifndef _MODULE_POWER_h #define _MODULE_POWER_h #include #include "watchos_consts.h" //#include "watchos_hw.h" //#include "watchos_types.h" #include "EventListener.h" #define MODULE_POWER_INTERACTIVE_LIGHT_SLEEP_DELAY_MS 200 #define MODULE_POWER_INTERACTIVE_DEEP_SLEEP_DELAY_MS 500 #define MODULE_POWER_NONINTERACTIVE_LIGHT_SLEEP_DELAY_MS 200 #define MODULE_POWER_NONINTERACTIVE_DEEP_SLEEP_DELAY_MS 500 /// /// Module responsible for monitoring activity, wake causes, timeouts, etc and deciding when /// to put the system into light/deep sleep. /// class Module_Power : public Task, public IRunnable, public EventListener { /// /// How many milliseconds to wait before entering light sleep /// int m_light_sleep_delay = 0; /// /// How many milliseconds to wait before entering deep sleep /// int m_deep_sleep_delay = 0; /// /// How many milliseconds of inactivity have elapsed while light sleep is enabled /// int m_light_sleep_accumulator = 0; /// /// How many milliseconds of inactivity have elapsed while deep sleep is enabled /// int m_deep_sleep_accumulator = 0; /// /// Timestamp of the last time the module updated the accumulators /// unsigned long m_last_tick; /// /// Track whether we have entered light sleep; if we have we need to disable the internal RTC /// before deep sleep. /// bool m_did_light_sleep; /// /// Whether the system is eligible to enter light sleep /// bool m_light_sleep_enabled = true; /// /// Whether the system is eligible to enter deep sleep /// bool m_deep_sleep_enabled = true; public: void start(); void tick(); /// /// Disable light sleep /// void disableLightSleep(); /// /// Enable light sleep /// void enableLightSleep(); /// /// Disable deep sleep /// void disableDeepSleep(); /// /// Enable light sleep /// void enableDeepSleep(); }; #endif