Skip to content
Snippets Groups Projects
Commit 2696bf82 authored by rahix's avatar rahix
Browse files

feat(display): Sleep display if backlight is off

Adapted from previous implementation in !476.  To quote:

> This saves about 1 mA when the display is off.
parent 60b80c24
No related branches found
No related tags found
No related merge requests found
......@@ -339,6 +339,11 @@ int epic_disp_framebuffer(union disp_framebuffer *fb)
int epic_disp_backlight(uint16_t brightness)
{
/* TODO: lock? */
if (brightness == 0) {
lcd_set_sleep(true);
} else {
lcd_set_sleep(false);
}
LCD_SetBacklight(brightness);
return 0;
}
......
......@@ -86,6 +86,8 @@ static void lcd_delay(size_t millis)
/* HAL Interfaces }}} */
enum lcd_commands {
/** Sleep In */
LCD_SLPIN = 0x10,
/** Sleep Out */
LCD_SLPOUT = 0x11,
/** Display Inversion On */
......@@ -157,6 +159,15 @@ static void lcd_hard_reset(void)
lcd_delay(20);
}
void lcd_set_sleep(bool sleep)
{
if (sleep) {
lcd_send_command(LCD_SLPIN, NULL, 0);
} else {
lcd_send_command(LCD_SLPOUT, NULL, 0);
}
}
/**
* Perform a minimal initialization under the assumption that the bootloader has
* already turned on the display. This is faster and prevents visible
......
......@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdint.h>
void lcd_set_sleep(bool sleep);
void lcd_reconfigure(void);
void lcd_initialize(void);
void lcd_write_fb_partial(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment