* ST7735Display: now applies SCALE_X, SCALE_Y

This commit is contained in:
Scott Powell
2025-05-08 12:48:34 +10:00
parent 7a7f436921
commit 60b7897665
2 changed files with 9 additions and 7 deletions
+7 -5
View File
@@ -6,6 +6,8 @@
#define DISPLAY_ROTATION 2
#endif
#define SCALE_X 1.25f // 160 / 128
#define SCALE_Y 1.25f // 80 / 64
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
return true;
@@ -99,7 +101,7 @@ void ST7735Display::setColor(Color c) {
}
void ST7735Display::setCursor(int x, int y) {
display.setCursor(x, y);
display.setCursor(x*SCALE_X, y*SCALE_Y);
}
void ST7735Display::print(const char* str) {
@@ -107,22 +109,22 @@ void ST7735Display::print(const char* str) {
}
void ST7735Display::fillRect(int x, int y, int w, int h) {
display.fillRect(x, y, w, h, _color);
display.fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
}
void ST7735Display::drawRect(int x, int y, int w, int h) {
display.drawRect(x, y, w, h, _color);
display.drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
}
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x, y, bits, w, h, _color);
display.drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, _color);
}
uint16_t ST7735Display::getTextWidth(const char* str) {
int16_t x1, y1;
uint16_t w, h;
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
return w;
return w / SCALE_X;
}
void ST7735Display::endFrame() {