Added lcd off and lcd power down functions to the API. This improves sleep current which is around 4.5mA instead of 12mA

This commit is contained in:
Th3maz1ng 2023-01-08 22:16:37 +01:00
parent 1fe8e03a13
commit 0ec9b4246b
4 changed files with 61 additions and 2 deletions

View File

@ -382,11 +382,39 @@ void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness)
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
{
if(!LCDConfig) return;
tls_gpio_write(LCDConfig->LCDResetPin, 0);
tls_os_time_delay(1);
tls_gpio_write(LCDConfig->LCDResetPin, 1);
}
void lcd_on(LCDConfig_t *const LCDConfig, bool state)
{
if(!LCDConfig) return;
lcd_set_data_command(LCDConfig, LCD_COMMAND);
lcd_set_cs(LCDConfig, LCD_SELECTED);
mmc_sdio_driver_write_one(state ? 0x29 : 0x28);
lcd_set_cs(LCDConfig, LCD_RELEASED);
lcd_set_data_command(LCDConfig, LCD_DATA);
}
void lcd_sleep(LCDConfig_t *const LCDConfig, bool state)
{
if(!LCDConfig) return;
lcd_set_data_command(LCDConfig, LCD_COMMAND);
lcd_set_cs(LCDConfig, LCD_SELECTED);
mmc_sdio_driver_write_one(state ? 0x10 : 0x11);
lcd_set_cs(LCDConfig, LCD_RELEASED);
lcd_set_data_command(LCDConfig, LCD_DATA);
}
static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_t *cmdAndData, uint32_t dataLengthInBytes)
{
// Select the slave CS line and tell him that he will receive a command !

View File

@ -92,7 +92,7 @@ void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, uint16_t x, uint16_t y,
/**
* @brief Sets the backlight to the specified brightness value
*
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
* @param brightness a value from 0 (backlight off) to 255 backlight fully on.
*/
void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness);
@ -100,8 +100,25 @@ void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness);
/**
* @brief Issues a hardware reset of the lcd display
*
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
*/
void lcd_hardware_reset(LCDConfig_t * const LCDConfig);
/**
* @brief Turns the LCD on or off, /!\ not the same as sleep mode !
*
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
* @param state true to turn the LCD on or false to turn it off
*/
void lcd_on(LCDConfig_t * const LCDConfig, bool state);
/**
* @brief Puts the LCD in power down mode (sleep) or power up mode (active)
* Sleep mode puts the LCD in it's lowest power state
*
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
* @param state true to put the LCD in sleep mode or false to put it in active mode
*/
void lcd_sleep(LCDConfig_t * const LCDConfig, bool state);
#endif //LCD_H

View File

@ -98,6 +98,9 @@ void mmc_sdio_driver_write_dma_async(uint32_t *data, uint32_t dataLengthInBytes)
void mmc_sdio_driver_write_one(uint8_t data)
{
/* Wait for MMC device to be ready to send the data */
while (SDIO_HOST->MMC_IO & 0x01);
SDIO_HOST->BUF_CTL = 0x4820;
SDIO_HOST->DATA_BUF[0] = (uint32_t)data;
SDIO_HOST->MMC_BYTECNTL = 1U;
@ -109,6 +112,9 @@ void mmc_sdio_driver_write_one(uint8_t data)
void mmc_sdio_driver_write(const uint8_t *data, uint16_t dataLengthInBytes)
{
/* Wait for MMC device to be ready to send the data */
while (SDIO_HOST->MMC_IO & 0x01);
SDIO_HOST->BUF_CTL = 0x4820;
memcpy((void *)SDIO_HOST->DATA_BUF, (void *)data, dataLengthInBytes);
SDIO_HOST->MMC_BYTECNTL = dataLengthInBytes;

View File

@ -237,6 +237,8 @@ void gfx_task(void *param)
don't forget to turn the backlight on ! */
setBrightness(persistency_get_settings()->display.brightness);
extern LCDConfig_t LCDConfig;
for(;;)
{
lv_timer_handler();
@ -275,12 +277,18 @@ void gfx_task(void *param)
{
// First, we disable the display backlight and we set all the peripherals in their low power mode
setBrightness(0);
//lcd_on(&LCDConfig, false);
lcd_sleep(&LCDConfig, true);
QMC5883L_set_power_mode(Standby);
// Let's sleep
tls_pmu_sleep_start();
// On wake up, we force the watch face to sync up with the rtc /!\ RTC update delay WTF ?
tls_os_time_delay(1);
watch_face_force_sync(&watchFace);
lv_disp_trig_activity(NULL);
QMC5883L_set_power_mode(Continuous);
//lcd_on(&LCDConfig, true);
lcd_sleep(&LCDConfig, false);
setBrightness(persistency_get_settings()->display.brightness);
}
}