Deep sleep
Deep sleep is what makes a battery-powered Inkplate sketch practical. E-paper holds its image without any power, so Inkplate 6MOTION can draw almost nothing while asleep and still keep a sketch running for months on a battery.
Simple deep sleep
The function below is a compound of all function calls required to put Inkplate 6MOTION in deep sleep mode:
void deepSleep()
{
// Disable all peripherals including WiFi, microSD card, SDRAM, sensors etc
inkplate.peripheralState(INKPLATE_PERIPHERAL_ALL, false);
// Disable USB voltage detection on USB OTG (This causes high current consumption in sleep!)
HAL_PWREx_DisableUSBVoltageDetector();
// Use different voltage scale for internal voltage regulator (lower current consumption in sleep mode)
HAL_PWREx_ControlStopModeVoltageScaling(PWR_REGULATOR_SVOS_SCALE5);
// Put every domain into standby mode
HAL_PWREx_EnterSTANDBYMode(PWR_D3_DOMAIN);
HAL_PWREx_EnterSTANDBYMode(PWR_D2_DOMAIN);
HAL_PWREx_EnterSTANDBYMode(PWR_D1_DOMAIN);
// Code does not continue past this point!
}
HAL_PWREx_EnterSTANDBYMode!peripheralState, see this pageIn a sketch built around deep sleep, it's common practice to put all your code in setup() and then put Inkplate to sleep at the end.
Wake on button press
To wake on button press of the WAKE button, use the STM32 function HAL_PWR_EnableWakeUpPin after resetting the wakeup flags:
// Check if the wake up from sleep did reset the board. If so, clear the flags
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
// Clear Standby flag
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
// Wake-up button on Inkplate 6MOTION is PC13 = WAKEUP PIN 4.
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4);
}
// Enable wake up button. By setting PC13 to low (button press), Inkplate will wake up
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN4_LOW);
Wake on timer
The most common usage of deep sleep is to periodically wake Inkplate to refresh the display with new data, this is documented in the RTC section of the documentation:
RTC deep sleep wakeup
How to use the built-in RTC to set a timer wake up from deep sleep
Full examples
Inkplate 6MOTION deep sleep example
This example demonstrates a sketch structured around deep sleep, it's an overview of all the deep sleep possibilities on Inkplate 6MOTION, with waking on timer or pushbutton