Power optimization - Improve SPI sleep mode
ST7789 driver : replace the constant '26' with a named constant to specify the pin number of the reset pin of the LCD controller.
This commit is contained in:
parent
62848b33fb
commit
9bd90c906e
|
@ -34,6 +34,7 @@ namespace Pinetime {
|
|||
static constexpr uint8_t SpiFlashCsn = 5;
|
||||
static constexpr uint8_t SpiLcdCsn = 25;
|
||||
static constexpr uint8_t LcdDataCommand = 18;
|
||||
static constexpr uint8_t LcdReset = 26;
|
||||
|
||||
static constexpr uint8_t TwiScl = 7;
|
||||
static constexpr uint8_t TwiSda = 6;
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
using namespace Pinetime::Drivers;
|
||||
|
||||
St7789::St7789(Spi& spi, uint8_t pinDataCommand) : spi {spi}, pinDataCommand {pinDataCommand} {
|
||||
St7789::St7789(Spi& spi, uint8_t pinDataCommand, uint8_t pinReset) : spi {spi}, pinDataCommand {pinDataCommand}, pinReset{pinReset} {
|
||||
}
|
||||
|
||||
void St7789::Init() {
|
||||
nrf_gpio_cfg_output(pinDataCommand);
|
||||
nrf_gpio_cfg_output(26);
|
||||
nrf_gpio_pin_set(26);
|
||||
nrf_gpio_cfg_output(pinReset);
|
||||
nrf_gpio_pin_set(pinReset);
|
||||
HardwareReset();
|
||||
SoftwareReset();
|
||||
SleepOut();
|
||||
|
@ -178,15 +178,15 @@ void St7789::DrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
|||
}
|
||||
|
||||
void St7789::HardwareReset() {
|
||||
nrf_gpio_pin_clear(26);
|
||||
nrf_gpio_pin_clear(pinReset);
|
||||
nrf_delay_ms(10);
|
||||
nrf_gpio_pin_set(26);
|
||||
nrf_gpio_pin_set(pinReset);
|
||||
}
|
||||
|
||||
void St7789::Sleep() {
|
||||
SleepIn();
|
||||
nrf_gpio_cfg_default(pinDataCommand);
|
||||
nrf_gpio_cfg_default(26);
|
||||
nrf_gpio_cfg_default(pinReset);
|
||||
NRF_LOG_INFO("[LCD] Sleep");
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Pinetime {
|
|||
|
||||
class St7789 {
|
||||
public:
|
||||
explicit St7789(Spi& spi, uint8_t pinDataCommand);
|
||||
explicit St7789(Spi& spi, uint8_t pinDataCommand, uint8_t pinReset);
|
||||
St7789(const St7789&) = delete;
|
||||
St7789& operator=(const St7789&) = delete;
|
||||
St7789(St7789&&) = delete;
|
||||
|
@ -29,6 +29,7 @@ namespace Pinetime {
|
|||
private:
|
||||
Spi& spi;
|
||||
uint8_t pinDataCommand;
|
||||
uint8_t pinReset;
|
||||
uint8_t verticalScrollingStartAddress = 0;
|
||||
|
||||
void HardwareReset();
|
||||
|
|
|
@ -68,7 +68,7 @@ Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
|
|||
Pinetime::PinMap::SpiMiso}};
|
||||
|
||||
Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
|
||||
Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand};
|
||||
Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand, Pinetime::PinMap::LcdReset};
|
||||
|
||||
Pinetime::Drivers::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
|
||||
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
|
||||
|
|
Loading…
Reference in New Issue
Block a user