@@ -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+
6678void 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+
138175void St7789::DisplayOn () {
139176 WriteCommand (static_cast <uint8_t >(Commands::DisplayOn));
140177}
@@ -208,11 +245,13 @@ void St7789::HardwareReset() {
208245
209246void St7789::LowPowerOn () {
210247 IdleModeOn ();
248+ FrameRateLow ();
211249 NRF_LOG_INFO (" [LCD] Low power mode" );
212250}
213251
214252void St7789::LowPowerOff () {
215253 IdleModeOff ();
254+ FrameRateNormal ();
216255 NRF_LOG_INFO (" [LCD] Normal power mode" );
217256}
218257
0 commit comments