Skip to content

Commit 31230c0

Browse files
committed
aod: porch control: 2Hz idle + 75Hz on
1 parent 22548b3 commit 31230c0

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

src/drivers/St7789.cpp

+31-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ void St7789::Init() {
2121
#ifndef DRIVER_DISPLAY_MIRROR
2222
DisplayInversionOn();
2323
#endif
24+
PorchSet();
25+
FrameRateNormalSet();
26+
IdleFrameRateOff();
2427
NormalModeOn();
2528
SetVdv();
2629
PowerControl();
@@ -159,8 +162,28 @@ void St7789::IdleModeOff() {
159162
WriteCommand(static_cast<uint8_t>(Commands::IdleModeOff));
160163
}
161164

162-
void St7789::FrameRateLow() {
163-
WriteCommand(static_cast<uint8_t>(Commands::FrameRate));
165+
void St7789::PorchSet() {
166+
WriteCommand(static_cast<uint8_t>(Commands::Porch));
167+
// Normal mode front porch
168+
WriteData(0x02);
169+
// Normal mode back porch
170+
WriteData(0x03);
171+
// Porch control enable
172+
WriteData(0x01);
173+
// Idle mode front:back porch
174+
WriteData(0xed);
175+
// Partial mode front:back porch (partial mode unused but set anyway)
176+
WriteData(0xed);
177+
}
178+
179+
void St7789::FrameRateNormalSet() {
180+
WriteCommand(static_cast<uint8_t>(Commands::FrameRateNormal));
181+
// Note that datasheet table inaccurate - see formula below table
182+
WriteData(0x0a);
183+
}
184+
185+
void St7789::IdleFrameRateOn() {
186+
WriteCommand(static_cast<uint8_t>(Commands::FrameRateIdle));
164187
// Enable frame rate control for partial/idle mode, 8x frame divider
165188
// In testing this divider appears to actually be 16x?
166189
WriteData(0x13);
@@ -170,14 +193,14 @@ void St7789::FrameRateLow() {
170193
WriteData(0x1f);
171194
}
172195

173-
void St7789::FrameRateNormal() {
174-
WriteCommand(static_cast<uint8_t>(Commands::FrameRate));
196+
void St7789::IdleFrameRateOff() {
197+
WriteCommand(static_cast<uint8_t>(Commands::FrameRateIdle));
175198
// Disable frame rate control and divider
176199
WriteData(0x00);
177200
// Idle mode frame rate (normal)
178-
WriteData(0x0f);
201+
WriteData(0x0a);
179202
// Partial mode frame rate (normal, unused)
180-
WriteData(0x0f);
203+
WriteData(0x0a);
181204
}
182205

183206
void St7789::DisplayOn() {
@@ -260,13 +283,13 @@ void St7789::HardwareReset() {
260283

261284
void St7789::LowPowerOn() {
262285
IdleModeOn();
263-
FrameRateLow();
286+
IdleFrameRateOn();
264287
NRF_LOG_INFO("[LCD] Low power mode");
265288
}
266289

267290
void St7789::LowPowerOff() {
268291
IdleModeOff();
269-
FrameRateNormal();
292+
IdleFrameRateOff();
270293
NRF_LOG_INFO("[LCD] Normal power mode");
271294
}
272295

src/drivers/St7789.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ namespace Pinetime {
5050
void WriteToRam(const uint8_t* data, size_t size);
5151
void IdleModeOn();
5252
void IdleModeOff();
53-
void FrameRateNormal();
54-
void FrameRateLow();
53+
void FrameRateNormalSet();
54+
void IdleFrameRateOff();
55+
void IdleFrameRateOn();
5556
void DisplayOn();
5657
void DisplayOff();
5758
void PowerControl();
5859
void GateControl();
60+
void PorchSet();
5961

6062
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
6163
void SetVdv();
@@ -81,12 +83,14 @@ namespace Pinetime {
8183
IdleModeOff = 0x38,
8284
IdleModeOn = 0x39,
8385
ColMod = 0x3a,
84-
FrameRate = 0xb3,
86+
FrameRateIdle = 0xb3,
87+
FrameRateNormal = 0xc6,
8588
VdvSet = 0xc4,
8689
PowerControl1 = 0xd0,
8790
Command2Enable = 0xdf,
8891
PowerControl2 = 0xe8,
8992
GateControl = 0xb7,
93+
Porch = 0xb2,
9094
};
9195
void WriteData(uint8_t data);
9296
void ColumnAddressSet();

0 commit comments

Comments
 (0)