diff --git a/eink.hpp b/eink.hpp index 0704cdb..bc0d0af 100644 --- a/eink.hpp +++ b/eink.hpp @@ -211,7 +211,8 @@ class Eink { } static void drawText(const std::pair &pos, const char *text, - const Color textColor = Color::BLACK, const Color backgroundColor = Color::WHITE) + const Color textColor = Color::BLACK, const Color backgroundColor = Color::WHITE, + const std::uint8_t scaling = 1) { const auto textLength = std::strlen(text); @@ -260,9 +261,9 @@ class Eink { const auto sendChannel = [&](const auto command) { for (auto i = std::size_t{0}; i < textLength; ++i) { - const auto posX = pos.first + i * 8; + const auto posX = pos.first + i * 8 * scaling; const auto screenPosX = getXScreenCoordinates(posX); - setRamRange({screenPosX, screenPosX}, {pos.second, pos.second + 7}); + setRamRange({screenPosX, screenPosX - (scaling - 1)}, {pos.second, pos.second + 8 * scaling - 1}); setRamXPos(screenPosX); setRamYPos(pos.second); @@ -271,7 +272,22 @@ class Eink { const auto fontByte = flash::loadLike(FONT_8X8.value[text[i]][j]); static_assert(std::is_same_v, std::uint8_t>); const auto dataByte = adjustColor(flipEndianness(fontByte), command); - sendData(dataByte); + + auto scaledByte = std::uint8_t{0}; + auto bitCounter = 0; + for (auto sy = std::uint8_t{0}; sy < scaling; ++sy) { + for (auto b = std::uint8_t{0}; b < 8; ++b) { + const auto currentBit = dataByte >> (8 - b - 1) & 1; + for (auto sx = std::uint8_t{0}; sx < scaling; ++sx) { + scaledByte |= currentBit << (8 - bitCounter - 1); + if (++bitCounter == 8) { + sendData(scaledByte); + scaledByte = 0; + bitCounter = 0; + } + } + } + } } } };