diff options
| author | John Crawford <coffeeboi47@protonmail.com> | 2023-10-14 15:19:50 -0600 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2024-08-05 20:32:43 +0200 |
| commit | 0960d670010852f294e8ba19a6d92eb93e537421 (patch) | |
| tree | 185ae93dc41385de2f5a43f52287bd0444c8931b /src/drivers | |
| parent | 5385f7e275a0b3ca83d8a7cae959b02700ef153a (diff) | |
aod: lower refresh rate when always on
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/St7789.cpp | 39 | ||||
| -rw-r--r-- | src/drivers/St7789.h | 5 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/drivers/St7789.cpp b/src/drivers/St7789.cpp index 274e2b62..035d61c9 100644 --- a/src/drivers/St7789.cpp +++ b/src/drivers/St7789.cpp @@ -16,6 +16,7 @@ void St7789::Init() { nrf_gpio_pin_set(pinReset); HardwareReset(); SoftwareReset(); + Command2Enable(); SleepOut(); PixelFormat(); MemoryDataAccessControl(); @@ -63,6 +64,17 @@ void St7789::SoftwareReset() { vTaskDelay(pdMS_TO_TICKS(125)); } +void St7789::Command2Enable() { + WriteCommand(static_cast<uint8_t>(Commands::Command2Enable)); + constexpr uint8_t args[] = { + 0x5a, // Constant + 0x69, // Constant + 0x02, // Constant + 0x01, // Enable + }; + WriteData(args, sizeof(args)); +} + void St7789::SleepOut() { if (!sleepIn) { return; @@ -135,6 +147,31 @@ void St7789::IdleModeOff() { WriteCommand(static_cast<uint8_t>(Commands::IdleModeOff)); } +void St7789::FrameRateLow() { + WriteCommand(static_cast<uint8_t>(Commands::FrameRate)); + // Enable frame rate control for partial/idle mode, 8x frame divider + // According to the datasheet, these controls should apply only to partial/idle mode + // However they appear to apply to normal mode, so we have to enable/disable + // every time we enter/exit always on + // In testing this divider appears to actually be 16x? + constexpr uint8_t args[] = { + 0x13, // Enable frame rate control for partial/idle mode, 8x frame divider + 0x1f, // Idle mode frame rate (lowest possible) + 0x1f, // Partial mode frame rate (lowest possible, unused) + }; + WriteData(args, sizeof(args)); +} + +void St7789::FrameRateNormal() { + WriteCommand(static_cast<uint8_t>(Commands::FrameRate)); + constexpr uint8_t args[] = { + 0x00, // Disable frame rate control and divider + 0x0f, // Idle mode frame rate (normal) + 0x0f, // Partial mode frame rate (normal, unused) + }; + WriteData(args, sizeof(args)); +} + void St7789::DisplayOn() { WriteCommand(static_cast<uint8_t>(Commands::DisplayOn)); } @@ -208,11 +245,13 @@ void St7789::HardwareReset() { void St7789::LowPowerOn() { IdleModeOn(); + FrameRateLow(); NRF_LOG_INFO("[LCD] Low power mode"); } void St7789::LowPowerOff() { IdleModeOff(); + FrameRateNormal(); NRF_LOG_INFO("[LCD] Normal power mode"); } diff --git a/src/drivers/St7789.h b/src/drivers/St7789.h index ccc951ff..e249e0b0 100644 --- a/src/drivers/St7789.h +++ b/src/drivers/St7789.h @@ -39,6 +39,7 @@ namespace Pinetime { void HardwareReset(); void SoftwareReset(); + void Command2Enable(); void SleepOut(); void EnsureSleepOutPostDelay(); void SleepIn(); @@ -49,6 +50,8 @@ namespace Pinetime { void WriteToRam(const uint8_t* data, size_t size); void IdleModeOn(); void IdleModeOff(); + void FrameRateNormal(); + void FrameRateLow(); void DisplayOn(); void DisplayOff(); @@ -75,7 +78,9 @@ namespace Pinetime { IdleModeOff = 0x38, IdleModeOn = 0x39, PixelFormat = 0x3a, + FrameRate = 0xb3, VdvSet = 0xc4, + Command2Enable = 0xdf, }; void WriteData(uint8_t data); void WriteData(const uint8_t* data, size_t size); |
