@@ -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
267287void St7789::LowPowerOn () {
268288 IdleModeOn ();
269- FrameRateLow ();
289+ IdleFrameRateOn ();
270290 NRF_LOG_INFO (" [LCD] Low power mode" );
271291}
272292
273293void St7789::LowPowerOff () {
274294 IdleModeOff ();
275- FrameRateNormal ();
295+ IdleFrameRateOff ();
276296 NRF_LOG_INFO (" [LCD] Normal power mode" );
277297}
278298
0 commit comments