libPocuter 1.0 Support library for programming the Pocuter

PocuterSleep.h
Go to the documentation of this file.
1
2 #ifndef POCUTERSLEEP_H
3 #define POCUTERSLEEP_H
4 #include <stddef.h>
9 class PocuterSleep {
10 public:
11 enum SLEEPERROR {
12 SLEEPERROR_OK,
13 SLEEPERROR_MODE_TIMER_NOT_SET,
14 SLEEPERROR_MODE_NOT_POSSIBLE,
15 SLEEPERROR_COULD_NOT_SET_TIMER_WAKEUP,
16 SLEEPERROR_COULD_NOT_SET_GPIO_WAKEUP,
17 SLEEPERROR_COULD_NOT_SET_WLAN_WAKEUP,
18 SLEEPERROR_SLEEP_INTERRUPTED,
19 SLEEPERROR_UNKNOWN
20
21 };
22 enum SLEEPTIMER_INTERRUPT {
23 SLEEPTIMER_INTERRUPT_BY_BUTTON = 0x01,
24 SLEEPTIMER_INTERRUPT_BY_SHAKE = 0x02
25 };
26 enum SLEEP_MODE{
27 SLEEP_MODE_LIGHT,
28 SLEEP_MODE_DEEP,
29 };
30 enum WAKEUP_MODE{
31 WAKEUP_MODE_USERPORT_0_LOW = 0x01,
32 WAKEUP_MODE_USERPORT_5_LOW = 0x02,
33 WAKEUP_MODE_USERPORT_0_HIGH = 0x04,
34 WAKEUP_MODE_USERPORT_5_HIGH = 0x08,
35 WAKEUP_MODE_ANY_BUTTON = 0x10,
36 WAKEUP_MODE_SHAKE = 0x20,
37 WAKEUP_MODE_TIMER = 0x40,
38 WAKEUP_MODE_WIFI = 0x80
39 };
40 enum WAKEUP_CAUSE{
41 WAKEUP_CAUSE_POWER_ON,
42 WAKEUP_CAUSE_GPIO,
43 WAKEUP_CAUSE_TIMER,
44 WAKEUP_CAUSE_WIFI
45 };
46 enum SLEEP_EVENT{
47 SLEEP_EVENT_ENTER_SLEEP,
48 SLEEP_EVENT_WAKEUP
49 };
50
51 typedef int WAKEUP_MODES;
52 typedef int SLEEPTIMER_INTERRUPTS;
53 typedef bool (sleepEventHandler)(SLEEP_EVENT, void*);
66 virtual void registerEventHandler(sleepEventHandler* e, void* u) = 0;
67
72 virtual void unregisterEventHandler() = 0;
73
86 virtual SLEEPERROR setSleepMode(SLEEP_MODE sm) = 0;
87
100 virtual SLEEPERROR setWakeUpModes(WAKEUP_MODES wm) = 0;
101
102
114 virtual SLEEPERROR setWakeUpTimer(uint32_t sec) = 0;
115
116
129 virtual SLEEPERROR doSleepNow() = 0;
130
131
143 virtual SLEEPERROR setInactivitySleep(uint32_t sec, SLEEPTIMER_INTERRUPTS cause, bool saveTimeout = false) = 0;
144
152 virtual WAKEUP_CAUSE getWakeUpCause() = 0;
153
154
155
156
157 };
158
159
160 #endif /* POCUTERSLEEP_H */
161
PocuterSleep::SLEEPERROR_COULD_NOT_SET_WLAN_WAKEUP
@ SLEEPERROR_COULD_NOT_SET_WLAN_WAKEUP
Definition: PocuterSleep.h:17
PocuterSleep::doSleepNow
virtual SLEEPERROR doSleepNow()=0
sleep now
PocuterSleep::SLEEP_MODE_LIGHT
@ SLEEP_MODE_LIGHT
Definition: PocuterSleep.h:27
PocuterSleep::WAKEUP_CAUSE
WAKEUP_CAUSE
Definition: PocuterSleep.h:40
PocuterSleep
Pocuter Sleep settings.
Definition: PocuterSleep.h:9
PocuterSleep::WAKEUP_CAUSE_POWER_ON
@ WAKEUP_CAUSE_POWER_ON
Definition: PocuterSleep.h:41
PocuterSleep::SLEEPTIMER_INTERRUPT_BY_BUTTON
@ SLEEPTIMER_INTERRUPT_BY_BUTTON
Definition: PocuterSleep.h:23
PocuterSleep::WAKEUP_MODE_WIFI
@ WAKEUP_MODE_WIFI
Definition: PocuterSleep.h:38
PocuterSleep::SLEEP_EVENT
SLEEP_EVENT
Definition: PocuterSleep.h:46
PocuterSleep::SLEEPERROR_SLEEP_INTERRUPTED
@ SLEEPERROR_SLEEP_INTERRUPTED
Definition: PocuterSleep.h:18
PocuterSleep::SLEEPERROR_OK
@ SLEEPERROR_OK
Definition: PocuterSleep.h:12
PocuterSleep::setWakeUpTimer
virtual SLEEPERROR setWakeUpTimer(uint32_t sec)=0
set the wake up timer
PocuterSleep::WAKEUP_CAUSE_GPIO
@ WAKEUP_CAUSE_GPIO
Definition: PocuterSleep.h:42
PocuterSleep::WAKEUP_MODE_TIMER
@ WAKEUP_MODE_TIMER
Definition: PocuterSleep.h:37
PocuterSleep::SLEEP_EVENT_WAKEUP
@ SLEEP_EVENT_WAKEUP
Definition: PocuterSleep.h:48
PocuterSleep::WAKEUP_CAUSE_TIMER
@ WAKEUP_CAUSE_TIMER
Definition: PocuterSleep.h:43
PocuterSleep::WAKEUP_MODE
WAKEUP_MODE
Definition: PocuterSleep.h:30
PocuterSleep::unregisterEventHandler
virtual void unregisterEventHandler()=0
unregister the event handler
PocuterSleep::SLEEPTIMER_INTERRUPT_BY_SHAKE
@ SLEEPTIMER_INTERRUPT_BY_SHAKE
Definition: PocuterSleep.h:24
PocuterSleep::SLEEP_MODE
SLEEP_MODE
Definition: PocuterSleep.h:26
PocuterSleep::WAKEUP_MODES
int WAKEUP_MODES
Definition: PocuterSleep.h:51
PocuterSleep::WAKEUP_MODE_USERPORT_5_LOW
@ WAKEUP_MODE_USERPORT_5_LOW
Definition: PocuterSleep.h:32
PocuterSleep::SLEEPERROR_MODE_NOT_POSSIBLE
@ SLEEPERROR_MODE_NOT_POSSIBLE
Definition: PocuterSleep.h:14
PocuterSleep::WAKEUP_CAUSE_WIFI
@ WAKEUP_CAUSE_WIFI
Definition: PocuterSleep.h:44
PocuterSleep::registerEventHandler
virtual void registerEventHandler(sleepEventHandler *e, void *u)=0
register an event callback
PocuterSleep::SLEEP_EVENT_ENTER_SLEEP
@ SLEEP_EVENT_ENTER_SLEEP
Definition: PocuterSleep.h:47
PocuterSleep::WAKEUP_MODE_ANY_BUTTON
@ WAKEUP_MODE_ANY_BUTTON
Definition: PocuterSleep.h:35
PocuterSleep::WAKEUP_MODE_SHAKE
@ WAKEUP_MODE_SHAKE
Definition: PocuterSleep.h:36
PocuterSleep::SLEEPERROR_COULD_NOT_SET_TIMER_WAKEUP
@ SLEEPERROR_COULD_NOT_SET_TIMER_WAKEUP
Definition: PocuterSleep.h:15
PocuterSleep::WAKEUP_MODE_USERPORT_0_LOW
@ WAKEUP_MODE_USERPORT_0_LOW
Definition: PocuterSleep.h:31
PocuterSleep::WAKEUP_MODE_USERPORT_5_HIGH
@ WAKEUP_MODE_USERPORT_5_HIGH
Definition: PocuterSleep.h:34
PocuterSleep::setWakeUpModes
virtual SLEEPERROR setWakeUpModes(WAKEUP_MODES wm)=0
set the wake up mode
PocuterSleep::WAKEUP_MODE_USERPORT_0_HIGH
@ WAKEUP_MODE_USERPORT_0_HIGH
Definition: PocuterSleep.h:33
PocuterSleep::setSleepMode
virtual SLEEPERROR setSleepMode(SLEEP_MODE sm)=0
net the sleep mode
PocuterSleep::SLEEPERROR_MODE_TIMER_NOT_SET
@ SLEEPERROR_MODE_TIMER_NOT_SET
Definition: PocuterSleep.h:13
PocuterSleep::SLEEP_MODE_DEEP
@ SLEEP_MODE_DEEP
Definition: PocuterSleep.h:28
PocuterSleep::SLEEPTIMER_INTERRUPTS
int SLEEPTIMER_INTERRUPTS
Definition: PocuterSleep.h:52
PocuterSleep::SLEEPERROR
SLEEPERROR
Definition: PocuterSleep.h:11
PocuterSleep::getWakeUpCause
virtual WAKEUP_CAUSE getWakeUpCause()=0
why did the device waked up?
PocuterSleep::sleepEventHandler
bool() sleepEventHandler(SLEEP_EVENT, void *)
Definition: PocuterSleep.h:53
PocuterSleep::SLEEPTIMER_INTERRUPT
SLEEPTIMER_INTERRUPT
Definition: PocuterSleep.h:22
PocuterSleep::SLEEPERROR_UNKNOWN
@ SLEEPERROR_UNKNOWN
Definition: PocuterSleep.h:19
PocuterSleep::SLEEPERROR_COULD_NOT_SET_GPIO_WAKEUP
@ SLEEPERROR_COULD_NOT_SET_GPIO_WAKEUP
Definition: PocuterSleep.h:16
PocuterSleep::setInactivitySleep
virtual SLEEPERROR setInactivitySleep(uint32_t sec, SLEEPTIMER_INTERRUPTS cause, bool saveTimeout=false)=0
set the behavior of the device