libPocuter  1.0
Support library for programming the Pocuter
PocuterSleep Class Referenceabstract

Pocuter Sleep settings. More...

#include <PocuterSleep.h>

Public Types

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 *)
 

Public Member Functions

virtual void registerEventHandler (sleepEventHandler *e, void *u)=0
 register an event callback More...
 
virtual void unregisterEventHandler ()=0
 unregister the event handler More...
 
virtual SLEEPERROR setSleepMode (SLEEP_MODE sm)=0
 net the sleep mode More...
 
virtual SLEEPERROR setWakeUpModes (WAKEUP_MODES wm)=0
 set the wake up mode More...
 
virtual SLEEPERROR setWakeUpTimer (uint32_t sec)=0
 set the wake up timer More...
 
virtual SLEEPERROR doSleepNow ()=0
 sleep now More...
 
virtual SLEEPERROR setInactivitySleep (uint32_t sec, SLEEPTIMER_INTERRUPTS cause, bool saveTimeout=false)=0
 set the behavior of the device More...
 
virtual WAKEUP_CAUSE getWakeUpCause ()=0
 why did the device waked up? More...
 

Detailed Description

Pocuter Sleep settings.

Member Typedef Documentation

◆ 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

Member Enumeration Documentation

◆ 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

Member Function Documentation

◆ doSleepNow()

virtual SLEEPERROR PocuterSleep::doSleepNow ( )
pure virtual

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()

virtual WAKEUP_CAUSE PocuterSleep::getWakeUpCause ( )
pure virtual

why did the device waked up?

Note
wake up by WAKEUP_CAUSE_GPIO could also mean by a button.
Returns
  • WAKEUP_CAUSE

◆ registerEventHandler()

virtual void PocuterSleep::registerEventHandler ( sleepEventHandler e,
void *  u 
)
pure virtual

register an event callback

Note
the event handler is called every time the device is going to sleep or wakes up
Parameters
ea pointer to the callback function
ua pointer to user data sent to the event handler on each event

◆ setInactivitySleep()

virtual SLEEPERROR PocuterSleep::setInactivitySleep ( uint32_t  sec,
SLEEPTIMER_INTERRUPTS  cause,
bool  saveTimeout = false 
)
pure virtual

set the behavior of the device

Parameters
secwait sec before go to sleep. 0 will never sleep.
causewait could cause a sleep timer interrupt
saveTimeoutsave the sec value as default. It will restore the default after reboot (saved on SD)
Returns
  • SLEEPERROR_OK

◆ setSleepMode()

virtual SLEEPERROR PocuterSleep::setSleepMode ( SLEEP_MODE  sm)
pure virtual

net the sleep mode

Note
depending on the sleep mode selected, only certain wake up modes are available
Parameters
smthe choosen SLEEP_MODE
Returns
  • SLEEPERROR_OK or an error

◆ setWakeUpModes()

virtual SLEEPERROR PocuterSleep::setWakeUpModes ( WAKEUP_MODES  wm)
pure virtual

set the wake up mode

Note
depending on the sleep mode selected, only certain wake up modes are available
Parameters
wmhere 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
secmax sleep seconds
Returns
  • SLEEPERROR_OK

◆ unregisterEventHandler()

virtual void PocuterSleep::unregisterEventHandler ( )
pure virtual

unregister the event handler


The documentation for this class was generated from the following file: