mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-12-25 10:41:42 +03:00
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 SpiFlashCsn = 5;
|
||||||
static constexpr uint8_t SpiLcdCsn = 25;
|
static constexpr uint8_t SpiLcdCsn = 25;
|
||||||
static constexpr uint8_t LcdDataCommand = 18;
|
static constexpr uint8_t LcdDataCommand = 18;
|
||||||
|
static constexpr uint8_t LcdReset = 26;
|
||||||
|
|
||||||
static constexpr uint8_t TwiScl = 7;
|
static constexpr uint8_t TwiScl = 7;
|
||||||
static constexpr uint8_t TwiSda = 6;
|
static constexpr uint8_t TwiSda = 6;
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
using namespace Pinetime::Drivers;
|
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() {
|
void St7789::Init() {
|
||||||
nrf_gpio_cfg_output(pinDataCommand);
|
nrf_gpio_cfg_output(pinDataCommand);
|
||||||
nrf_gpio_cfg_output(26);
|
nrf_gpio_cfg_output(pinReset);
|
||||||
nrf_gpio_pin_set(26);
|
nrf_gpio_pin_set(pinReset);
|
||||||
HardwareReset();
|
HardwareReset();
|
||||||
SoftwareReset();
|
SoftwareReset();
|
||||||
SleepOut();
|
SleepOut();
|
||||||
@ -178,15 +178,15 @@ void St7789::DrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void St7789::HardwareReset() {
|
void St7789::HardwareReset() {
|
||||||
nrf_gpio_pin_clear(26);
|
nrf_gpio_pin_clear(pinReset);
|
||||||
nrf_delay_ms(10);
|
nrf_delay_ms(10);
|
||||||
nrf_gpio_pin_set(26);
|
nrf_gpio_pin_set(pinReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::Sleep() {
|
void St7789::Sleep() {
|
||||||
SleepIn();
|
SleepIn();
|
||||||
nrf_gpio_cfg_default(pinDataCommand);
|
nrf_gpio_cfg_default(pinDataCommand);
|
||||||
nrf_gpio_cfg_default(26);
|
nrf_gpio_cfg_default(pinReset);
|
||||||
NRF_LOG_INFO("[LCD] Sleep");
|
NRF_LOG_INFO("[LCD] Sleep");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ namespace Pinetime {
|
|||||||
|
|
||||||
class St7789 {
|
class St7789 {
|
||||||
public:
|
public:
|
||||||
explicit St7789(Spi& spi, uint8_t pinDataCommand);
|
explicit St7789(Spi& spi, uint8_t pinDataCommand, uint8_t pinReset);
|
||||||
St7789(const St7789&) = delete;
|
St7789(const St7789&) = delete;
|
||||||
St7789& operator=(const St7789&) = delete;
|
St7789& operator=(const St7789&) = delete;
|
||||||
St7789(St7789&&) = delete;
|
St7789(St7789&&) = delete;
|
||||||
@ -29,6 +29,7 @@ namespace Pinetime {
|
|||||||
private:
|
private:
|
||||||
Spi& spi;
|
Spi& spi;
|
||||||
uint8_t pinDataCommand;
|
uint8_t pinDataCommand;
|
||||||
|
uint8_t pinReset;
|
||||||
uint8_t verticalScrollingStartAddress = 0;
|
uint8_t verticalScrollingStartAddress = 0;
|
||||||
|
|
||||||
void HardwareReset();
|
void HardwareReset();
|
||||||
|
@ -68,7 +68,7 @@ Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
|
|||||||
Pinetime::PinMap::SpiMiso}};
|
Pinetime::PinMap::SpiMiso}};
|
||||||
|
|
||||||
Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
|
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::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
|
||||||
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
|
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
|
||||||
|
Loading…
Reference in New Issue
Block a user