aod: lower refresh rate when always on

This commit is contained in:
John Crawford 2023-10-14 15:19:50 -06:00 committed by JF
parent 5385f7e275
commit 0960d67001
2 changed files with 44 additions and 0 deletions

View file

@ -16,6 +16,7 @@ void St7789::Init() {
nrf_gpio_pin_set(pinReset); nrf_gpio_pin_set(pinReset);
HardwareReset(); HardwareReset();
SoftwareReset(); SoftwareReset();
Command2Enable();
SleepOut(); SleepOut();
PixelFormat(); PixelFormat();
MemoryDataAccessControl(); MemoryDataAccessControl();
@ -63,6 +64,17 @@ void St7789::SoftwareReset() {
vTaskDelay(pdMS_TO_TICKS(125)); 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() { void St7789::SleepOut() {
if (!sleepIn) { if (!sleepIn) {
return; return;
@ -135,6 +147,31 @@ void St7789::IdleModeOff() {
WriteCommand(static_cast<uint8_t>(Commands::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() { void St7789::DisplayOn() {
WriteCommand(static_cast<uint8_t>(Commands::DisplayOn)); WriteCommand(static_cast<uint8_t>(Commands::DisplayOn));
} }
@ -208,11 +245,13 @@ void St7789::HardwareReset() {
void St7789::LowPowerOn() { void St7789::LowPowerOn() {
IdleModeOn(); IdleModeOn();
FrameRateLow();
NRF_LOG_INFO("[LCD] Low power mode"); NRF_LOG_INFO("[LCD] Low power mode");
} }
void St7789::LowPowerOff() { void St7789::LowPowerOff() {
IdleModeOff(); IdleModeOff();
FrameRateNormal();
NRF_LOG_INFO("[LCD] Normal power mode"); NRF_LOG_INFO("[LCD] Normal power mode");
} }

View file

@ -39,6 +39,7 @@ namespace Pinetime {
void HardwareReset(); void HardwareReset();
void SoftwareReset(); void SoftwareReset();
void Command2Enable();
void SleepOut(); void SleepOut();
void EnsureSleepOutPostDelay(); void EnsureSleepOutPostDelay();
void SleepIn(); void SleepIn();
@ -49,6 +50,8 @@ namespace Pinetime {
void WriteToRam(const uint8_t* data, size_t size); void WriteToRam(const uint8_t* data, size_t size);
void IdleModeOn(); void IdleModeOn();
void IdleModeOff(); void IdleModeOff();
void FrameRateNormal();
void FrameRateLow();
void DisplayOn(); void DisplayOn();
void DisplayOff(); void DisplayOff();
@ -75,7 +78,9 @@ namespace Pinetime {
IdleModeOff = 0x38, IdleModeOff = 0x38,
IdleModeOn = 0x39, IdleModeOn = 0x39,
PixelFormat = 0x3a, PixelFormat = 0x3a,
FrameRate = 0xb3,
VdvSet = 0xc4, VdvSet = 0xc4,
Command2Enable = 0xdf,
}; };
void WriteData(uint8_t data); void WriteData(uint8_t data);
void WriteData(const uint8_t* data, size_t size); void WriteData(const uint8_t* data, size_t size);