Skip to content

Commit 5ae574b

Browse files
authored
Merge pull request #878 from WattleFoxxo/tdeck
Scaling fixes for TDeck
2 parents 54675ed + 69e6d69 commit 5ae574b

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/helpers/ui/ST7789LCDDisplay.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool ST7789LCDDisplay::begin() {
3939

4040
display.fillScreen(ST77XX_BLACK);
4141
display.setTextColor(ST77XX_WHITE);
42-
display.setTextSize(2);
42+
display.setTextSize(2 * DISPLAY_SCALE_X);
4343
display.cp437(true); // Use full 256 char 'Code Page 437' font
4444

4545
_isOn = true;
@@ -70,12 +70,12 @@ void ST7789LCDDisplay::clear() {
7070
void ST7789LCDDisplay::startFrame(Color bkg) {
7171
display.fillScreen(ST77XX_BLACK);
7272
display.setTextColor(ST77XX_WHITE);
73-
display.setTextSize(1); // This one affects size of Please wait... message
73+
display.setTextSize(1 * DISPLAY_SCALE_X); // This one affects size of Please wait... message
7474
display.cp437(true); // Use full 256 char 'Code Page 437' font
7575
}
7676

7777
void ST7789LCDDisplay::setTextSize(int sz) {
78-
display.setTextSize(sz);
78+
display.setTextSize(sz * DISPLAY_SCALE_X);
7979
}
8080

8181
void ST7789LCDDisplay::setColor(Color c) {
@@ -125,7 +125,22 @@ void ST7789LCDDisplay::drawRect(int x, int y, int w, int h) {
125125
}
126126

127127
void ST7789LCDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
128-
display.drawBitmap(x * DISPLAY_SCALE_X, y * DISPLAY_SCALE_Y, bits, w, h, _color);
128+
uint8_t byteWidth = (w + 7) / 8;
129+
130+
for (int j = 0; j < h; j++) {
131+
for (int i = 0; i < w; i++) {
132+
uint8_t byte = bits[j * byteWidth + i / 8];
133+
bool pixelOn = byte & (0x80 >> (i & 7));
134+
135+
if (pixelOn) {
136+
for (int dy = 0; dy < DISPLAY_SCALE_X; dy++) {
137+
for (int dx = 0; dx < DISPLAY_SCALE_X; dx++) {
138+
display.drawPixel(x * DISPLAY_SCALE_X + i * DISPLAY_SCALE_X + dx, y * DISPLAY_SCALE_Y + j * DISPLAY_SCALE_X + dy, _color);
139+
}
140+
}
141+
}
142+
}
143+
}
129144
}
130145

131146
uint16_t ST7789LCDDisplay::getTextWidth(const char* str) {
@@ -138,4 +153,4 @@ uint16_t ST7789LCDDisplay::getTextWidth(const char* str) {
138153

139154
void ST7789LCDDisplay::endFrame() {
140155
// display.display();
141-
}
156+
}

0 commit comments

Comments
 (0)