2019-12-05 18:23:46 +00:00
|
|
|
#pragma once
|
2019-12-07 16:11:50 +00:00
|
|
|
#include <cstddef>
|
2019-12-02 18:42:10 +00:00
|
|
|
|
2019-12-05 18:23:46 +00:00
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
2019-12-07 16:11:50 +00:00
|
|
|
class SpiMaster;
|
|
|
|
class St7789 {
|
2019-12-05 18:23:46 +00:00
|
|
|
public:
|
2019-12-07 16:11:50 +00:00
|
|
|
explicit St7789(SpiMaster& spiMaster, uint8_t pinDataCommand);
|
|
|
|
void Init();
|
2019-12-05 18:23:46 +00:00
|
|
|
void Uninit();
|
|
|
|
void DrawPixel(uint16_t x, uint16_t y, uint32_t color);
|
|
|
|
void FillRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
|
2019-12-02 18:42:10 +00:00
|
|
|
|
2019-12-07 18:15:33 +00:00
|
|
|
void BeginDrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
|
|
|
void NextDrawBuffer(const uint8_t* data, size_t size);
|
|
|
|
void EndDrawBuffer();
|
|
|
|
|
2020-01-02 13:47:59 +00:00
|
|
|
void DisplayOn();
|
|
|
|
void DisplayOff();
|
|
|
|
|
2019-12-07 16:11:50 +00:00
|
|
|
|
2019-12-05 18:23:46 +00:00
|
|
|
private:
|
2019-12-07 16:11:50 +00:00
|
|
|
SpiMaster& spi;
|
|
|
|
uint8_t pinDataCommand;
|
2019-12-02 18:42:10 +00:00
|
|
|
|
2020-01-02 13:47:59 +00:00
|
|
|
void HardwareReset();
|
2019-12-05 18:23:46 +00:00
|
|
|
void SoftwareReset();
|
|
|
|
void SleepOut();
|
|
|
|
void ColMod();
|
|
|
|
void MemoryDataAccessControl();
|
|
|
|
void DisplayInversionOn();
|
|
|
|
void NormalModeOn();
|
|
|
|
void WriteToRam();
|
2020-01-02 13:47:59 +00:00
|
|
|
|
2019-12-02 18:42:10 +00:00
|
|
|
|
2019-12-05 18:23:46 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
enum class Commands : uint8_t {
|
|
|
|
SoftwareReset = 0x01,
|
|
|
|
SleepOut = 0x11,
|
|
|
|
NormalModeOn = 0x13,
|
|
|
|
DisplayInversionOn = 0x21,
|
|
|
|
DisplayOff = 0x28,
|
|
|
|
DisplayOn = 0x29,
|
|
|
|
ColumnAddressSet = 0x2a,
|
|
|
|
RowAddressSet = 0x2b,
|
|
|
|
WriteToRam = 0x2c,
|
|
|
|
MemoryDataAccessControl = 036,
|
|
|
|
ColMod = 0x3a,
|
|
|
|
};
|
|
|
|
void WriteData(uint8_t data);
|
|
|
|
void ColumnAddressSet();
|
|
|
|
|
|
|
|
static constexpr uint16_t Width = 240;
|
|
|
|
static constexpr uint16_t Height = 240;
|
|
|
|
void RowAddressSet();
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2019-12-02 18:42:10 +00:00
|
|
|
|
|
|
|
|