Skip to content

Commit ef88e81

Browse files
mark9064JF002
authored andcommitted
aod: porch control: 2Hz idle + 75Hz on
1 parent da9ab4a commit ef88e81

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

src/drivers/St7789.cpp

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ void St7789::Init() {
2525
#ifndef DRIVER_DISPLAY_MIRROR
2626
DisplayInversionOn();
2727
#endif
28+
PorchSet();
29+
FrameRateNormalSet();
30+
IdleFrameRateOff();
2831
NormalModeOn();
2932
SetVdv();
3033
PowerControl();
@@ -149,27 +152,44 @@ void St7789::IdleModeOff() {
149152
WriteCommand(static_cast<uint8_t>(Commands::IdleModeOff));
150153
}
151154

152-
void St7789::FrameRateLow() {
153-
WriteCommand(static_cast<uint8_t>(Commands::FrameRate));
154-
// Enable frame rate control for partial/idle mode, 8x frame divider
155+
void St7789::PorchSet() {
156+
WriteCommand(static_cast<uint8_t>(Commands::Porch));
157+
constexpr uint8_t args[] = {
158+
0x02, // Normal mode front porch
159+
0x03, // Normal mode back porch
160+
0x01, // Porch control enable
161+
0xed, // Idle mode front:back porch
162+
0xed, // Partial mode front:back porch (partial mode unused but set anyway)
163+
};
164+
WriteData(args, sizeof(args));
165+
}
166+
167+
void St7789::FrameRateNormalSet() {
168+
WriteCommand(static_cast<uint8_t>(Commands::FrameRateNormal));
169+
// Note that the datasheet table is imprecise - see formula below table
170+
WriteData(0x0a);
171+
}
172+
173+
void St7789::IdleFrameRateOn() {
174+
WriteCommand(static_cast<uint8_t>(Commands::FrameRateIdle));
155175
// According to the datasheet, these controls should apply only to partial/idle mode
156176
// However they appear to apply to normal mode, so we have to enable/disable
157177
// every time we enter/exit always on
158178
// In testing this divider appears to actually be 16x?
159179
constexpr uint8_t args[] = {
160180
0x13, // Enable frame rate control for partial/idle mode, 8x frame divider
161-
0x1f, // Idle mode frame rate (lowest possible)
162-
0x1f, // Partial mode frame rate (lowest possible, unused)
181+
0x1e, // Idle mode frame rate
182+
0x1e, // Partial mode frame rate (unused)
163183
};
164184
WriteData(args, sizeof(args));
165185
}
166186

167-
void St7789::FrameRateNormal() {
168-
WriteCommand(static_cast<uint8_t>(Commands::FrameRate));
187+
void St7789::IdleFrameRateOff() {
188+
WriteCommand(static_cast<uint8_t>(Commands::FrameRateIdle));
169189
constexpr uint8_t args[] = {
170190
0x00, // Disable frame rate control and divider
171-
0x0f, // Idle mode frame rate (normal)
172-
0x0f, // Partial mode frame rate (normal, unused)
191+
0x0a, // Idle mode frame rate (normal)
192+
0x0a, // Partial mode frame rate (normal, unused)
173193
};
174194
WriteData(args, sizeof(args));
175195
}
@@ -266,13 +286,13 @@ void St7789::HardwareReset() {
266286

267287
void St7789::LowPowerOn() {
268288
IdleModeOn();
269-
FrameRateLow();
289+
IdleFrameRateOn();
270290
NRF_LOG_INFO("[LCD] Low power mode");
271291
}
272292

273293
void St7789::LowPowerOff() {
274294
IdleModeOff();
275-
FrameRateNormal();
295+
IdleFrameRateOff();
276296
NRF_LOG_INFO("[LCD] Normal power mode");
277297
}
278298

src/drivers/St7789.h

Lines changed: 7 additions & 3 deletions
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();
@@ -80,12 +82,14 @@ namespace Pinetime {
8082
IdleModeOff = 0x38,
8183
IdleModeOn = 0x39,
8284
PixelFormat = 0x3a,
83-
FrameRate = 0xb3,
85+
FrameRateIdle = 0xb3,
86+
FrameRateNormal = 0xc6,
8487
VdvSet = 0xc4,
8588
Command2Enable = 0xdf,
8689
PowerControl1 = 0xd0,
8790
PowerControl2 = 0xe8,
8891
GateControl = 0xb7,
92+
Porch = 0xb2,
8993
};
9094
void WriteData(uint8_t data);
9195
void WriteData(const uint8_t* data, size_t size);

0 commit comments

Comments
 (0)