Skip to content

Commit 0960d67

Browse files
KaffeinatedKatJF002
authored andcommitted
aod: lower refresh rate when always on
1 parent 5385f7e commit 0960d67

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

src/drivers/St7789.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void St7789::Init() {
1616
nrf_gpio_pin_set(pinReset);
1717
HardwareReset();
1818
SoftwareReset();
19+
Command2Enable();
1920
SleepOut();
2021
PixelFormat();
2122
MemoryDataAccessControl();
@@ -63,6 +64,17 @@ void St7789::SoftwareReset() {
6364
vTaskDelay(pdMS_TO_TICKS(125));
6465
}
6566

67+
void St7789::Command2Enable() {
68+
WriteCommand(static_cast<uint8_t>(Commands::Command2Enable));
69+
constexpr uint8_t args[] = {
70+
0x5a, // Constant
71+
0x69, // Constant
72+
0x02, // Constant
73+
0x01, // Enable
74+
};
75+
WriteData(args, sizeof(args));
76+
}
77+
6678
void St7789::SleepOut() {
6779
if (!sleepIn) {
6880
return;
@@ -135,6 +147,31 @@ void St7789::IdleModeOff() {
135147
WriteCommand(static_cast<uint8_t>(Commands::IdleModeOff));
136148
}
137149

150+
void St7789::FrameRateLow() {
151+
WriteCommand(static_cast<uint8_t>(Commands::FrameRate));
152+
// Enable frame rate control for partial/idle mode, 8x frame divider
153+
// According to the datasheet, these controls should apply only to partial/idle mode
154+
// However they appear to apply to normal mode, so we have to enable/disable
155+
// every time we enter/exit always on
156+
// In testing this divider appears to actually be 16x?
157+
constexpr uint8_t args[] = {
158+
0x13, // Enable frame rate control for partial/idle mode, 8x frame divider
159+
0x1f, // Idle mode frame rate (lowest possible)
160+
0x1f, // Partial mode frame rate (lowest possible, unused)
161+
};
162+
WriteData(args, sizeof(args));
163+
}
164+
165+
void St7789::FrameRateNormal() {
166+
WriteCommand(static_cast<uint8_t>(Commands::FrameRate));
167+
constexpr uint8_t args[] = {
168+
0x00, // Disable frame rate control and divider
169+
0x0f, // Idle mode frame rate (normal)
170+
0x0f, // Partial mode frame rate (normal, unused)
171+
};
172+
WriteData(args, sizeof(args));
173+
}
174+
138175
void St7789::DisplayOn() {
139176
WriteCommand(static_cast<uint8_t>(Commands::DisplayOn));
140177
}
@@ -208,11 +245,13 @@ void St7789::HardwareReset() {
208245

209246
void St7789::LowPowerOn() {
210247
IdleModeOn();
248+
FrameRateLow();
211249
NRF_LOG_INFO("[LCD] Low power mode");
212250
}
213251

214252
void St7789::LowPowerOff() {
215253
IdleModeOff();
254+
FrameRateNormal();
216255
NRF_LOG_INFO("[LCD] Normal power mode");
217256
}
218257

src/drivers/St7789.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace Pinetime {
3939

4040
void HardwareReset();
4141
void SoftwareReset();
42+
void Command2Enable();
4243
void SleepOut();
4344
void EnsureSleepOutPostDelay();
4445
void SleepIn();
@@ -49,6 +50,8 @@ namespace Pinetime {
4950
void WriteToRam(const uint8_t* data, size_t size);
5051
void IdleModeOn();
5152
void IdleModeOff();
53+
void FrameRateNormal();
54+
void FrameRateLow();
5255
void DisplayOn();
5356
void DisplayOff();
5457

@@ -75,7 +78,9 @@ namespace Pinetime {
7578
IdleModeOff = 0x38,
7679
IdleModeOn = 0x39,
7780
PixelFormat = 0x3a,
81+
FrameRate = 0xb3,
7882
VdvSet = 0xc4,
83+
Command2Enable = 0xdf,
7984
};
8085
void WriteData(uint8_t data);
8186
void WriteData(const uint8_t* data, size_t size);

0 commit comments

Comments
 (0)