summaryrefslogtreecommitdiff
path: root/src/drivers/St7789.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-01-17 21:16:45 (GMT)
committerJF <jf@codingfield.com>2020-01-17 21:16:45 (GMT)
commitc1f3a31b513e90b29f31f23ba24e5856837ea6d4 (patch)
tree8c3ef1be5a0bd4fa904311e8f1fc24de22646d62 /src/drivers/St7789.cpp
parent69a14a224780a3abe13bc4fcacd2d71db54716ac (diff)
Disable SPI, I²C, touch controller and display controller in sleep mode.
Re-enable them on wake up. Remove delays that were not needed in st7889 driver. Hopefully, it'll improve the battery life!
Diffstat (limited to 'src/drivers/St7789.cpp')
-rw-r--r--src/drivers/St7789.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/drivers/St7789.cpp b/src/drivers/St7789.cpp
index 7c52f17..0bb7b7c 100644
--- a/src/drivers/St7789.cpp
+++ b/src/drivers/St7789.cpp
@@ -48,7 +48,10 @@ void St7789::SoftwareReset() {
void St7789::SleepOut() {
WriteCommand(static_cast<uint8_t>(Commands::SleepOut));
- nrf_delay_ms(500);
+}
+
+void St7789::SleepIn() {
+ WriteCommand(static_cast<uint8_t>(Commands::SleepIn));
}
void St7789::ColMod() {
@@ -90,7 +93,6 @@ void St7789::NormalModeOn() {
void St7789::DisplayOn() {
WriteCommand(static_cast<uint8_t>(Commands::DisplayOn));
- nrf_delay_ms(500);
}
void St7789::FillRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) {
@@ -163,9 +165,30 @@ void St7789::NextDrawBuffer(const uint8_t *data, size_t size) {
void St7789::HardwareReset() {
nrf_gpio_pin_clear(26);
- nrf_delay_ms(200);
+ nrf_delay_ms(10);
nrf_gpio_pin_set(26);
+}
+
+void St7789::Sleep() {
+ SleepIn();
+ nrf_gpio_cfg_default(pinDataCommand);
+ spi.Sleep();
+}
+void St7789::Wakeup() {
+ spi.Wakeup();
+
+ nrf_gpio_cfg_output(pinDataCommand);
+ // TODO why do we need to reset the controller?
+ SoftwareReset();
+ SleepOut();
+ ColMod();
+ MemoryDataAccessControl();
+ ColumnAddressSet();
+ RowAddressSet();
+ DisplayInversionOn();
+ NormalModeOn();
+ DisplayOn();
}