Class Sleep
- Namespace
- nanoFramework.Hardware.Esp32
- Assembly
- nanoFramework.Hardware.Esp32.dll
Encapsulates ESP32 sleep functions.
public class Sleep
- Inheritance
-
Sleep
- Inherited Members
- Extension Methods
Constructors
Sleep()
public Sleep()
Methods
EnableWakeupByMultiPins(WakeupGpioPin, WakeupMode)
Enable wakeup using multiple pins.
public static EspNativeError EnableWakeupByMultiPins(Sleep.WakeupGpioPin pins, Sleep.WakeupMode mode)
Parameters
pins
Sleep.WakeupGpioPinCombination of pins that are enabled for wakeup.
mode
Sleep.WakeupModeLogical mode used for wakeup to occur.
Returns
- EspNativeError
Returns ESP32 native error enumeration.
Remarks
Only pins that are RTC connected.
EnableWakeupByPin(WakeupGpioPin, int)
Enable wakeup using a gpio pin.
public static EspNativeError EnableWakeupByPin(Sleep.WakeupGpioPin pin, int level)
Parameters
pin
Sleep.WakeupGpioPinGPIO number used as wakeup source. Only pins that have RTC functionality can be used. 0,2,4,12->15,25->27,32->39
level
intAnalog threshold at or above which pin causes wake up, or zero if pin is not active for wakeup.
Returns
- EspNativeError
Returns ESP32 native error enumeration.
EnableWakeupByTimer(TimeSpan)
Enable Wakeup by Timer.
public static EspNativeError EnableWakeupByTimer(TimeSpan time)
Parameters
time
TimeSpanPeriod after which wakeup occurs.
Returns
- EspNativeError
returns ESP32 native error enumeration.
EnableWakeupByTouchPad(int, int, byte)
Enable wakeup by Touchpad.
public static EspNativeError EnableWakeupByTouchPad(int padNumber1, int padNumber2 = -1, byte thresholdCoefficient = 80)
Parameters
padNumber1
intA valid pad number to wake up the device.
padNumber2
intIf a valid pad number, will be used in comibation of the first pad number.
thresholdCoefficient
byteThreshold coefficient for automatic calibration. Percentage from 0 to 100. Default value is 80% seems to work in most cases.
Returns
- EspNativeError
Returns ESP32 native error enumeration.
Remarks
See GetGpioNumberFromTouchNumber(int) to understand which GPIO maps with which pad.
EnableWakeupByUart(WakeUpPort, int)
Enable wakeup by UART.
public static EspNativeError EnableWakeupByUart(Sleep.WakeUpPort portNumber, int edgeCount)
Parameters
portNumber
Sleep.WakeUpPortThe port to use, only COM1 and COM2 are supported. Pins MUST be properly configured for COM2 for this to work.
edgeCount
intThe number of changes in the RX pin to wakeup the ESP.
Returns
- EspNativeError
Returns ESP32 native error enumeration.
GetWakeupCause()
Get the cause for waking up.
public static Sleep.WakeupCause GetWakeupCause()
Returns
- Sleep.WakeupCause
Returns the wakeup cause.
GetWakeupGpioPin()
Returns a combination of pins that caused the wakeup.
public static Sleep.WakeupGpioPin GetWakeupGpioPin()
Returns
- Sleep.WakeupGpioPin
Returns a combination of the pins that caused the wakeup.
GetWakeupTouchpad()
Get the Touchpad which caused the wakeup.
public static int GetWakeupTouchpad()
Returns
StartDeepSleep()
Enter deep sleep using configured wakeup sources.
public static void StartDeepSleep()
Remarks
After a call to this method the device enters deep sleep, a wakeup source will wake the device and the execution will start as if it was a reset. After this occurs the cause can be queried using GetWakeupCause(). Keep in mind that the execution WILL NOT continue after the call to this method. This call never returns. If no wakeup sources are configured then the device enters an indefinite sleep.
- See Also
StartLightSleep()
Enter light sleep with the configured wakeup options.
public static EspNativeError StartLightSleep()
Returns
- EspNativeError
Returns ESP32 native error enumeration, ESP_ERR_INVALID_STATE if Wifi or BT is not stopped.