Low-power¶
Critical
The EXT3 and EXT3.1 boards do not feature the panelPower
signal required for low-power mode.
The low-power profile includes mode and scope.
Mode can be automatic or manual.
-
With automatic mode
POWER_MODE_AUTO
, power is managed directly at the screen library when callingflush()
orflushFast()
orflushMode()
. -
With manual mode
POWER_MODE_MANUAL
, power is managed explicitely at the application level withsuspend()
andresume()
.
Scope can include GPIO only, GPIO and SPI bus, or none.
-
With GPIO only scope
POWER_SCOPE_GPIO_ONLY
, only the power and GPIOs are turned off. -
With GPIO and bus scope
POWER_SCOPE_GPIO_BUS
, power, GPIOs and SPI bus are turned off. -
With none scope
POWER_SCOPE_NONE
, none are turned off.
The Basic edition does not feature the GPIO and bus scope.
Warning
When turning the SPI bus off, all the other devices connected to the SPI bus are unresponsive.
Example
In the case of the EXT3 and EXT3.1 extension boards, turning the SPI bus off prevents any access to the SPI Flash memory.
Configure¶
Ensure the panelPower
signal is set to a value other than NOT_CONNECTED
.
const pins_t myBoard =
{
// ...
.panelPower = 12, ///< Optional power circuit
// ...
};
Warning
The power functions requires the panelPower
signal to be set in the board configuration.
Configuration is optional, as the screen library defines a default power profile.
myScreen.begin();
begin()
resets and configures the screen, defines the GPIOs and the SPI bus, powers the panel, and sets the power profile according to the screen family.
-
Default profile includes automatic mode
POWER_MODE_AUTO
and GPIO scopePOWER_SCOPE_GPIO_ONLY
for screens with global update, of which black-white-red and black-white-red-yellow; and -
Default profile includes manual mode
POWER_MODE_MANUAL
and GPIO scopePOWER_SCOPE_GPIO_ONLY
for screens with embedded fast update, of which wide temeprature and touch.
If the panelPower
signal is not defined, the power profile defaults to manual mode POWER_MODE_MANUAL
and scope none POWER_SCOPE_NONE
.
myScreen.setPowerProfile(POWER_MODE_AUTO, POWER_SCOPE_GPIO_ONLY);
setPowerProfile()
customises the power profile.
The optional parameters are
- The first parameter sets the mode.
Default mode is POWER_MODE_AUTO
for automatic management, otherwise POWER_MODE_MANUAL
for manual management;
- The second parameter defines the scope.
Default scope is POWER_SCOPE_GPIO_ONLY
for GPIO only, otherwise POWER_SCOPE_GPIO_BUS
for GPIO and bus, or POWER_SCOPE_NONE
for none.
The scope is only used in automatic mode.
If the panelPower
signal is not defined, the power profile defaults to manual mode POWER_MODE_MANUAL
and scope none POWER_SCOPE_NONE
.
Use¶
Automatic mode¶
In automatic mode and with the panelPower
signal defined, when a refresh function like flush()
or flushFast()
or flushMode()
is called, the screen powers on, performs the refresh, then powers off.
The SPI bus is kept active if the selected scope is POWER_SCOPE_GPIO_ONLY
.
Manual mode¶
In manual mode, the application code should call explicitely suspend()
and resume()
.
myScreen.suspend();
myScreen.suspend(POWER_SCOPE_GPIO_ONLY);
myScreen.suspend(POWER_SCOPE_GPIO_BUS);
suspend()
enters low-power mode. According to the parameter, it turns the GPIOs only or also the SPI bus off.
- The optional parameter defines the scope.
With default scope POWER_SCOPE_GPIO_ONLY
, the function turns the power of the panel off and sets all the GPIOs to LOW
if the panelPower
signal is defined.
With scope POWER_SCOPE_GPIO_BUS
, the function also turns the SPI bus off.
With scope POWER_SCOPE_NONE
, the function performs nothing.
If the panelPower
signal is not defined, the scope defaults to none POWER_SCOPE_NONE
.
myScreen.resume()
resume()
exits low-power mode. Based on the elements previously turned off, it restores all the GPIOs, turns the power on, reactivates the SPI bus, resets and configures the panel.
Warning
The functions suspend()
and resume()
should not be used if other devices share the same SPI bus.
Example¶
The example below shows three states: panel is powered on for 4 seconds; panel is refreshed; panel is powered off for 4 seconds.
void displayPower()
{
myScreen.setOrientation(myOrientation);
myScreen.setPowerProfile(POWER_MODE_MANUAL, POWER_SCOPE_GPIO_ONLY);
hV_HAL_Serial_printf("Power on");
hV_HAL_Serial_crlf();
hV_HAL_delayMilliseconds(4000);
hV_HAL_Serial_printf("Refresh");
hV_HAL_Serial_crlf();
myScreen.clear();
myScreen.gText(4, 4, "Refresh");
myScreen.flush();
hV_HAL_Serial_printf("Power off");
hV_HAL_Serial_crlf();
myScreen.suspend(POWER_SCOPE_GPIO_BUS);
hV_HAL_delayMilliseconds(4000);
myScreen.resume();
hV_HAL_Serial_printf("End");
hV_HAL_Serial_crlf();
myScreen.regenerate();
}