2019-12-05 19:23:46 +01:00
|
|
|
#pragma once
|
2019-12-07 17:11:50 +01:00
|
|
|
#include <cstddef>
|
2020-11-15 05:04:22 +01:00
|
|
|
#include <cstdint>
|
2019-12-02 19:42:10 +01:00
|
|
|
|
2019-12-05 19:23:46 +01:00
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
2020-05-07 19:53:51 +02:00
|
|
|
class Spi;
|
2019-12-07 17:11:50 +01:00
|
|
|
class St7789 {
|
2019-12-05 19:23:46 +01:00
|
|
|
public:
|
2020-05-07 19:53:51 +02:00
|
|
|
explicit St7789(Spi& spi, uint8_t pinDataCommand);
|
2020-03-08 21:38:11 +01:00
|
|
|
St7789(const St7789&) = delete;
|
|
|
|
St7789& operator=(const St7789&) = delete;
|
|
|
|
St7789(St7789&&) = delete;
|
|
|
|
St7789& operator=(St7789&&) = delete;
|
|
|
|
|
2019-12-07 17:11:50 +01:00
|
|
|
void Init();
|
2019-12-05 19:23:46 +01:00
|
|
|
void Uninit();
|
|
|
|
void DrawPixel(uint16_t x, uint16_t y, uint32_t color);
|
2019-12-02 19:42:10 +01:00
|
|
|
|
2020-02-15 15:12:29 +01:00
|
|
|
void VerticalScrollDefinition(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines);
|
|
|
|
void VerticalScrollStartAddress(uint16_t line);
|
|
|
|
|
|
|
|
|
2019-12-07 19:15:33 +01:00
|
|
|
void BeginDrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
2020-01-26 13:37:10 +01:00
|
|
|
void NextDrawBuffer(const uint8_t* data, size_t size);
|
2019-12-07 19:15:33 +01:00
|
|
|
|
2020-01-02 14:47:59 +01:00
|
|
|
void DisplayOn();
|
|
|
|
void DisplayOff();
|
|
|
|
|
2020-01-17 22:16:45 +01:00
|
|
|
void Sleep();
|
|
|
|
void Wakeup();
|
2019-12-05 19:23:46 +01:00
|
|
|
private:
|
2020-05-07 19:53:51 +02:00
|
|
|
Spi& spi;
|
2019-12-07 17:11:50 +01:00
|
|
|
uint8_t pinDataCommand;
|
2020-03-11 21:35:06 +01:00
|
|
|
uint8_t verticalScrollingStartAddress = 0;
|
2019-12-02 19:42:10 +01:00
|
|
|
|
2020-01-02 14:47:59 +01:00
|
|
|
void HardwareReset();
|
2019-12-05 19:23:46 +01:00
|
|
|
void SoftwareReset();
|
|
|
|
void SleepOut();
|
2020-01-17 22:16:45 +01:00
|
|
|
void SleepIn();
|
2019-12-05 19:23:46 +01:00
|
|
|
void ColMod();
|
|
|
|
void MemoryDataAccessControl();
|
|
|
|
void DisplayInversionOn();
|
|
|
|
void NormalModeOn();
|
|
|
|
void WriteToRam();
|
|
|
|
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
|
|
|
void WriteCommand(uint8_t cmd);
|
2020-01-26 13:37:10 +01:00
|
|
|
void WriteSpi(const uint8_t* data, size_t size);
|
2019-12-05 19:23:46 +01:00
|
|
|
|
|
|
|
enum class Commands : uint8_t {
|
|
|
|
SoftwareReset = 0x01,
|
2020-01-17 22:16:45 +01:00
|
|
|
SleepIn = 0x10,
|
2019-12-05 19:23:46 +01:00
|
|
|
SleepOut = 0x11,
|
|
|
|
NormalModeOn = 0x13,
|
|
|
|
DisplayInversionOn = 0x21,
|
|
|
|
DisplayOff = 0x28,
|
|
|
|
DisplayOn = 0x29,
|
|
|
|
ColumnAddressSet = 0x2a,
|
|
|
|
RowAddressSet = 0x2b,
|
|
|
|
WriteToRam = 0x2c,
|
|
|
|
MemoryDataAccessControl = 036,
|
2020-02-15 15:12:29 +01:00
|
|
|
VerticalScrollDefinition = 0x33,
|
|
|
|
VerticalScrollStartAddress = 0x37,
|
2019-12-05 19:23:46 +01:00
|
|
|
ColMod = 0x3a,
|
|
|
|
};
|
|
|
|
void WriteData(uint8_t data);
|
|
|
|
void ColumnAddressSet();
|
|
|
|
|
|
|
|
static constexpr uint16_t Width = 240;
|
2020-03-08 21:46:25 +01:00
|
|
|
static constexpr uint16_t Height = 320;
|
2019-12-05 19:23:46 +01:00
|
|
|
void RowAddressSet();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2019-12-02 19:42:10 +01:00
|
|
|
|
|
|
|
|