1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-08-18 18:32:30 +02:00

Fix for drawTextCenter() for ST7796

This commit is contained in:
Norbert Walter
2026-02-28 22:10:57 +00:00
parent ffa9c8ac83
commit 2e47263008
+3 -2
View File
@@ -488,9 +488,10 @@ std::vector<String> wordwrap(String &line, uint16_t maxwidth) {
// Draw centered text // Draw centered text
void drawTextCenter(int16_t cx, int16_t cy, String text) { void drawTextCenter(int16_t cx, int16_t cy, String text) {
#ifdef DISPLAY_ST7796 #ifdef DISPLAY_ST7796
uint16_t h = getdisplay().fontHeight();
auto oldDatum = getdisplay().getTextDatum(); auto oldDatum = getdisplay().getTextDatum();
getdisplay().setTextDatum(textdatum_t::middle_center); getdisplay().setTextDatum(textdatum_t::top_center);
getdisplay().drawString(text, cx, cy); getdisplay().drawString(text, cx, cy - static_cast<int16_t>(h / 2));
getdisplay().setTextDatum(oldDatum); getdisplay().setTextDatum(oldDatum);
#else #else
int16_t x1, y1; int16_t x1, y1;