Use enum to represent commands

This commit is contained in:
BlackMark 2022-05-28 16:14:12 +02:00
parent 9a4193ee75
commit d1419b2d23

View File

@ -12,21 +12,21 @@ namespace eink {
template <uint16_t Width, uint16_t Height, typename Spi, io::P RstPin, io::P DcPin, io::P BusyPin> template <uint16_t Width, uint16_t Height, typename Spi, io::P RstPin, io::P DcPin, io::P BusyPin>
class Eink { class Eink {
struct Cmd { enum class Cmd : uint8_t {
static constexpr auto SW_RESET = uint8_t{0x12}; DRIVER_OUTPUT_CONTROL = 0x01,
static constexpr auto DRIVER_OUTPUT_CONTROL = uint8_t{0x01}; DEEP_SLEEP_MODE = 0x10,
static constexpr auto DATA_ENTRY_MODE = uint8_t{0x11}; DATA_ENTRY_MODE = 0x11,
static constexpr auto SET_RAM_X_ADDR_POSITIONS = uint8_t{0x44}; SW_RESET = 0x12,
static constexpr auto SET_RAM_Y_ADDR_POSITIONS = uint8_t{0x45}; READ_TEMPERATURE_SENSOR = 0x18,
static constexpr auto BORDER_WAVEFORM_CONTROL = uint8_t{0x3C}; UPDATE_DISPLAY = 0x20,
static constexpr auto READ_TEMPERATURE_SENSOR = uint8_t{0x18}; DISPLAY_UPDATE_CONTROL_2 = 0x22,
static constexpr auto SET_RAM_X_ADDR = uint8_t{0x4E}; WRITE_RAM_BLACK = 0x24,
static constexpr auto SET_RAM_Y_ADDR = uint8_t{0x4F}; WRITE_RAM_RED = 0x26,
static constexpr auto WRITE_RAM_BLACK = uint8_t{0x24}; BORDER_WAVEFORM_CONTROL = 0x3C,
static constexpr auto WRITE_RAM_RED = uint8_t{0x26}; SET_RAM_X_ADDR_POSITIONS = 0x44,
static constexpr auto DISPLAY_UPDATE_CONTROL_2 = uint8_t{0x22}; SET_RAM_Y_ADDR_POSITIONS = 0x45,
static constexpr auto UPDATE_DISPLAY = uint8_t{0x20}; SET_RAM_X_ADDR = 0x4E,
static constexpr auto DEEP_SLEEP_MODE = uint8_t{0x10}; SET_RAM_Y_ADDR = 0x4F,
}; };
static io::Pin<RstPin> m_rst; static io::Pin<RstPin> m_rst;
@ -106,10 +106,10 @@ class Eink {
waitUntilIdle(); waitUntilIdle();
} }
static void sendCommand(const uint8_t command) static void sendCommand(const Cmd command)
{ {
m_dc = false; m_dc = false;
spiTransfer(command); spiTransfer(static_cast<uint8_t>(command));
} }
static void sendData(const uint8_t data) static void sendData(const uint8_t data)