Commit ade3dd2f 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 c16833ae
......@@ -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(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment