Implement getTextWidth for display classes

- Added getTextWidth method to DisplayDriver interface
- Implemented getTextWidth in all display classes
- Updated examples to use getTextWidth directly
This commit is contained in:
JQ
2025-05-04 18:17:18 -07:00
parent e442e94e3d
commit 678f36a57b
10 changed files with 32 additions and 8 deletions
+5
View File
@@ -44,6 +44,7 @@ void ST7789Display::startFrame(Color bkg) {
}
void ST7789Display::setTextSize(int sz) {
_textSize = sz; // Store the text size
switch(sz) {
case 1 :
display.setFont(ArialMT_Plain_10);
@@ -107,6 +108,10 @@ void ST7789Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x+X_OFFSET, y, w, h, bits);
}
uint16_t ST7789Display::getTextWidth(const char* str) {
return display.getStringWidth(str);
}
void ST7789Display::endFrame() {
display.display();
}