From 69e6d69798f5bdc7fd90deb765c48fcb94f601f7 Mon Sep 17 00:00:00 2001 From: WattleFoxxo Date: Fri, 3 Oct 2025 22:55:32 +1000 Subject: [PATCH] Fix font and icon scaling issues for TDeck --- src/helpers/ui/ST7789LCDDisplay.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/helpers/ui/ST7789LCDDisplay.cpp b/src/helpers/ui/ST7789LCDDisplay.cpp index 38c28893..87f9b8ad 100644 --- a/src/helpers/ui/ST7789LCDDisplay.cpp +++ b/src/helpers/ui/ST7789LCDDisplay.cpp @@ -39,7 +39,7 @@ bool ST7789LCDDisplay::begin() { display.fillScreen(ST77XX_BLACK); display.setTextColor(ST77XX_WHITE); - display.setTextSize(2); + display.setTextSize(2 * DISPLAY_SCALE_X); display.cp437(true); // Use full 256 char 'Code Page 437' font _isOn = true; @@ -70,12 +70,12 @@ void ST7789LCDDisplay::clear() { void ST7789LCDDisplay::startFrame(Color bkg) { display.fillScreen(ST77XX_BLACK); display.setTextColor(ST77XX_WHITE); - display.setTextSize(1); // This one affects size of Please wait... message + display.setTextSize(1 * DISPLAY_SCALE_X); // This one affects size of Please wait... message display.cp437(true); // Use full 256 char 'Code Page 437' font } void ST7789LCDDisplay::setTextSize(int sz) { - display.setTextSize(sz); + display.setTextSize(sz * DISPLAY_SCALE_X); } void ST7789LCDDisplay::setColor(Color c) { @@ -125,7 +125,22 @@ void ST7789LCDDisplay::drawRect(int x, int y, int w, int h) { } void ST7789LCDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { - display.drawBitmap(x * DISPLAY_SCALE_X, y * DISPLAY_SCALE_Y, bits, w, h, _color); + uint8_t byteWidth = (w + 7) / 8; + + for (int j = 0; j < h; j++) { + for (int i = 0; i < w; i++) { + uint8_t byte = bits[j * byteWidth + i / 8]; + bool pixelOn = byte & (0x80 >> (i & 7)); + + if (pixelOn) { + for (int dy = 0; dy < DISPLAY_SCALE_X; dy++) { + for (int dx = 0; dx < DISPLAY_SCALE_X; dx++) { + display.drawPixel(x * DISPLAY_SCALE_X + i * DISPLAY_SCALE_X + dx, y * DISPLAY_SCALE_Y + j * DISPLAY_SCALE_X + dy, _color); + } + } + } + } + } } uint16_t ST7789LCDDisplay::getTextWidth(const char* str) { @@ -138,4 +153,4 @@ uint16_t ST7789LCDDisplay::getTextWidth(const char* str) { void ST7789LCDDisplay::endFrame() { // display.display(); -} +} \ No newline at end of file