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