Pocuter Sleep settings.
More...
#include <PocuterSleep.h>
|
| enum | SLEEPERROR {
SLEEPERROR_OK,
SLEEPERROR_MODE_TIMER_NOT_SET,
SLEEPERROR_MODE_NOT_POSSIBLE,
SLEEPERROR_COULD_NOT_SET_TIMER_WAKEUP,
SLEEPERROR_COULD_NOT_SET_GPIO_WAKEUP,
SLEEPERROR_COULD_NOT_SET_WLAN_WAKEUP,
SLEEPERROR_SLEEP_INTERRUPTED,
SLEEPERROR_UNKNOWN
} |
| |
| enum | SLEEPTIMER_INTERRUPT { SLEEPTIMER_INTERRUPT_BY_BUTTON = 0x01,
SLEEPTIMER_INTERRUPT_BY_SHAKE = 0x02
} |
| |
| enum | SLEEP_MODE { SLEEP_MODE_LIGHT,
SLEEP_MODE_DEEP
} |
| |
| enum | WAKEUP_MODE {
WAKEUP_MODE_USERPORT_0_LOW = 0x01,
WAKEUP_MODE_USERPORT_5_LOW = 0x02,
WAKEUP_MODE_USERPORT_0_HIGH = 0x04,
WAKEUP_MODE_USERPORT_5_HIGH = 0x08,
WAKEUP_MODE_ANY_BUTTON = 0x10,
WAKEUP_MODE_SHAKE = 0x20,
WAKEUP_MODE_TIMER = 0x40,
WAKEUP_MODE_WIFI = 0x80
} |
| |
| enum | WAKEUP_CAUSE { WAKEUP_CAUSE_POWER_ON,
WAKEUP_CAUSE_GPIO,
WAKEUP_CAUSE_TIMER,
WAKEUP_CAUSE_WIFI
} |
| |
| enum | SLEEP_EVENT { SLEEP_EVENT_ENTER_SLEEP,
SLEEP_EVENT_WAKEUP
} |
| |
| typedef int | WAKEUP_MODES |
| |
| typedef int | SLEEPTIMER_INTERRUPTS |
| |
| typedef bool() | sleepEventHandler(SLEEP_EVENT, void *) |
| |
◆ sleepEventHandler
| typedef bool() PocuterSleep::sleepEventHandler(SLEEP_EVENT, void *) |
type definition of the event callback function. If you return false, going to sleep or wake up will be interrupted
◆ SLEEPTIMER_INTERRUPTS
◆ WAKEUP_MODES
◆ SLEEP_EVENT
| Enumerator |
|---|
| SLEEP_EVENT_ENTER_SLEEP | |
| SLEEP_EVENT_WAKEUP | |
◆ SLEEP_MODE
| Enumerator |
|---|
| SLEEP_MODE_LIGHT | light sleep mode needs more power but the program can be continued after waking up
|
| SLEEP_MODE_DEEP | The deep sleep mode needs less power, but the program restarts after waking up. Only a maximum of 8kb of the RTC memory declared with "DEEP_SLEEP_MEMORY" is kept.
|
◆ SLEEPERROR
| Enumerator |
|---|
| SLEEPERROR_OK | everything went well
|
| SLEEPERROR_MODE_TIMER_NOT_SET | could not set the timer
|
| SLEEPERROR_MODE_NOT_POSSIBLE | cannot set this sleep mode
|
| SLEEPERROR_COULD_NOT_SET_TIMER_WAKEUP | cannot set the sleep timer
|
| SLEEPERROR_COULD_NOT_SET_GPIO_WAKEUP | cannot set the gpios for wake up
|
| SLEEPERROR_COULD_NOT_SET_WLAN_WAKEUP | cannot set WLAN for wake up
|
| SLEEPERROR_SLEEP_INTERRUPTED | going to sleep was interrupted by the eventhandler
|
| SLEEPERROR_UNKNOWN | |
◆ SLEEPTIMER_INTERRUPT
| Enumerator |
|---|
| SLEEPTIMER_INTERRUPT_BY_BUTTON | interrupt sleep timer by a button
|
| SLEEPTIMER_INTERRUPT_BY_SHAKE | interrupt sleep timer by shaking
|
◆ WAKEUP_CAUSE
| Enumerator |
|---|
| WAKEUP_CAUSE_POWER_ON | waked up by powering the device
|
| WAKEUP_CAUSE_GPIO | waked up by gpio (als0 a button is possible)
|
| WAKEUP_CAUSE_TIMER | waked up by timer
|
| WAKEUP_CAUSE_WIFI | waked up by WIFI
|
◆ WAKEUP_MODE
| Enumerator |
|---|
| WAKEUP_MODE_USERPORT_0_LOW | available in deep sleep and light sleep
|
| WAKEUP_MODE_USERPORT_5_LOW | available in deep sleep and light sleep
|
| WAKEUP_MODE_USERPORT_0_HIGH | available in deep sleep and light sleep
|
| WAKEUP_MODE_USERPORT_5_HIGH | available in deep sleep and light sleep
|
| WAKEUP_MODE_ANY_BUTTON | available in light sleep only
|
| WAKEUP_MODE_SHAKE | available in light sleep only
|
| WAKEUP_MODE_TIMER | available in deep sleep and light sleep
|
| WAKEUP_MODE_WIFI | available in light sleep only
|
◆ doSleepNow()
sleep now
- Note
- the device will go to sleep, immediately
- Returns
- SLEEPERROR_OK
- SLEEPERROR_COULD_NOT_SET_GPIO_WAKEUP could not set the wake up gpios
- SLEEPERROR_COULD_NOT_SET_TIMER_WAKEUP could not set the wake up timer
- SLEEPERROR_COULD_NOT_SET_WLAN_WAKEUP could not set WLAN wake up
◆ getWakeUpCause()
why did the device waked up?
- Note
- wake up by WAKEUP_CAUSE_GPIO could also mean by a button.
- Returns
-
◆ registerEventHandler()
register an event callback
- Note
- the event handler is called every time the device is going to sleep or wakes up
- Parameters
-
| e | a pointer to the callback function |
| u | a pointer to user data sent to the event handler on each event |
◆ setInactivitySleep()
set the behavior of the device
- Parameters
-
| sec | wait sec before go to sleep. 0 will never sleep. |
| cause | wait could cause a sleep timer interrupt |
| saveTimeout | save the sec value as default. It will restore the default after reboot (saved on SD) |
- Returns
-
◆ setSleepMode()
net the sleep mode
- Note
- depending on the sleep mode selected, only certain wake up modes are available
- Parameters
-
- Returns
- SLEEPERROR_OK or an error
◆ setWakeUpModes()
set the wake up mode
- Note
- depending on the sleep mode selected, only certain wake up modes are available
- Parameters
-
| wm | here you can choose multiple modes linked with an or. (e.g. WAKEUP_MODE_ANY_BUTTON | WAKEUP_MODE_SHAKE) |
- Returns
- SLEEPERROR_OK
- SLEEPERROR_MODE_NOT_POSSIBLE in the chosen sleep mode there is one or wake up option not available
◆ setWakeUpTimer()
| virtual SLEEPERROR PocuterSleep::setWakeUpTimer |
( |
uint32_t |
sec | ) |
|
|
pure virtual |
set the wake up timer
- Note
- set a wake up timer in seconds. You have also to set the WAKEUP_MODE_TIMER with setWakeUpModes.
- Parameters
-
- Returns
-
◆ unregisterEventHandler()
| virtual void PocuterSleep::unregisterEventHandler |
( |
| ) |
|
|
pure virtual |
unregister the event handler
The documentation for this class was generated from the following file: