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:
parent
1fe8e03a13
commit
0ec9b4246b
@ -382,11 +382,39 @@ void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness)
|
|||||||
|
|
||||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
|
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
|
||||||
{
|
{
|
||||||
|
if(!LCDConfig) return;
|
||||||
|
|
||||||
tls_gpio_write(LCDConfig->LCDResetPin, 0);
|
tls_gpio_write(LCDConfig->LCDResetPin, 0);
|
||||||
tls_os_time_delay(1);
|
tls_os_time_delay(1);
|
||||||
tls_gpio_write(LCDConfig->LCDResetPin, 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)
|
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 !
|
// Select the slave CS line and tell him that he will receive a command !
|
||||||
|
@ -104,4 +104,21 @@ void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness);
|
|||||||
*/
|
*/
|
||||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig);
|
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
|
#endif //LCD_H
|
@ -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)
|
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->BUF_CTL = 0x4820;
|
||||||
SDIO_HOST->DATA_BUF[0] = (uint32_t)data;
|
SDIO_HOST->DATA_BUF[0] = (uint32_t)data;
|
||||||
SDIO_HOST->MMC_BYTECNTL = 1U;
|
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)
|
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;
|
SDIO_HOST->BUF_CTL = 0x4820;
|
||||||
memcpy((void *)SDIO_HOST->DATA_BUF, (void *)data, dataLengthInBytes);
|
memcpy((void *)SDIO_HOST->DATA_BUF, (void *)data, dataLengthInBytes);
|
||||||
SDIO_HOST->MMC_BYTECNTL = dataLengthInBytes;
|
SDIO_HOST->MMC_BYTECNTL = dataLengthInBytes;
|
||||||
|
@ -237,6 +237,8 @@ void gfx_task(void *param)
|
|||||||
don't forget to turn the backlight on ! */
|
don't forget to turn the backlight on ! */
|
||||||
setBrightness(persistency_get_settings()->display.brightness);
|
setBrightness(persistency_get_settings()->display.brightness);
|
||||||
|
|
||||||
|
extern LCDConfig_t LCDConfig;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
lv_timer_handler();
|
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
|
// First, we disable the display backlight and we set all the peripherals in their low power mode
|
||||||
setBrightness(0);
|
setBrightness(0);
|
||||||
|
//lcd_on(&LCDConfig, false);
|
||||||
|
lcd_sleep(&LCDConfig, true);
|
||||||
|
QMC5883L_set_power_mode(Standby);
|
||||||
// Let's sleep
|
// Let's sleep
|
||||||
tls_pmu_sleep_start();
|
tls_pmu_sleep_start();
|
||||||
// On wake up, we force the watch face to sync up with the rtc /!\ RTC update delay WTF ?
|
// On wake up, we force the watch face to sync up with the rtc /!\ RTC update delay WTF ?
|
||||||
tls_os_time_delay(1);
|
tls_os_time_delay(1);
|
||||||
watch_face_force_sync(&watchFace);
|
watch_face_force_sync(&watchFace);
|
||||||
lv_disp_trig_activity(NULL);
|
lv_disp_trig_activity(NULL);
|
||||||
|
QMC5883L_set_power_mode(Continuous);
|
||||||
|
//lcd_on(&LCDConfig, true);
|
||||||
|
lcd_sleep(&LCDConfig, false);
|
||||||
setBrightness(persistency_get_settings()->display.brightness);
|
setBrightness(persistency_get_settings()->display.brightness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user