diff --git a/eink.hpp b/eink.hpp index c6c1a5d..ce5f3e3 100644 --- a/eink.hpp +++ b/eink.hpp @@ -1,6 +1,8 @@ #pragma once -#include +#include + +#include #include @@ -10,11 +12,11 @@ namespace eink { -template +template class Eink { using word_t = typename Spi::word_t; - enum class Cmd : uint8_t { + enum class Cmd : std::uint8_t { DRIVER_OUTPUT_CONTROL = 0x01, DEEP_SLEEP_MODE = 0x10, DATA_ENTRY_MODE = 0x11, @@ -40,7 +42,7 @@ class Eink { static constexpr auto BLOCK_SIZE = 5; - enum class Color : uint8_t { + enum class Color : std::uint8_t { BLACK = 0b00, WHITE = 0b01, RED = 0b10, @@ -49,12 +51,12 @@ class Eink { class ImageBlock { public: - inline Color &operator[](const size_t idx) + inline Color &operator[](const std::size_t idx) { return data[idx]; } - inline const Color &operator[](const size_t idx) const + inline const Color &operator[](const std::size_t idx) const { return data[idx]; } @@ -147,26 +149,26 @@ class Eink { template static void draw(const Image &image) { - constexpr auto lookup = [](uint8_t bits) { + constexpr auto lookup = [](std::uint8_t bits) { auto block = ImageBlock{}; - for_constexpr( + util::for_constexpr( [&](const auto idx) { block[idx.value] = static_cast(bits % 3); bits /= 3; }, - util::make_index_sequence{}); + std::make_index_sequence{}); return block; }; constexpr auto sendImageChannel = [lookup](const auto command, const auto image) { sendCommand(command); - auto buffer = uint8_t{0}; - auto bufferPos = uint8_t{0}; - for (auto i = uint16_t{0}; i < Width * Height / BLOCK_SIZE; i++) { + auto buffer = std::uint8_t{0}; + auto bufferPos = std::uint8_t{0}; + for (auto i = std::uint16_t{0}; i < Width * Height / BLOCK_SIZE; i++) { const auto block = lookup(pgm_read_byte(&image[i])); - for (auto p = uint8_t{0}; p < BLOCK_SIZE; ++p) { - const auto pixel = uint8_t{(command == Cmd::WRITE_RAM_BLACK) ? (block[p] != Color::BLACK) - : (block[p] == Color::RED)}; + for (auto p = std::uint8_t{0}; p < BLOCK_SIZE; ++p) { + const auto pixel = std::uint8_t{(command == Cmd::WRITE_RAM_BLACK) ? (block[p] != Color::BLACK) + : (block[p] == Color::RED)}; buffer |= pixel << (7 - bufferPos++); if (bufferPos == 8) { sendData(buffer); @@ -189,11 +191,11 @@ class Eink { static void clear() { sendCommand(Cmd::WRITE_RAM_BLACK); - for (auto i = uint16_t{0}; i < Width * Height / 8; i++) { + for (auto i = std::uint16_t{0}; i < Width * Height / 8; i++) { sendData(0xff); } sendCommand(Cmd::WRITE_RAM_RED); - for (auto i = uint16_t{0}; i < Width * Height / 8; i++) { + for (auto i = std::uint16_t{0}; i < Width * Height / 8; i++) { sendData(0x00); }