mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-08-18 18:32:30 +02:00
Fix for drawTextCenter()
This commit is contained in:
@@ -488,11 +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 w = getdisplay().textWidth(text);
|
||||||
uint16_t h = getdisplay().fontHeight();
|
uint16_t h = getdisplay().fontHeight();
|
||||||
auto oldDatum = getdisplay().getTextDatum();
|
getdisplay().setCursor(cx - static_cast<int16_t>(w / 2), cy + static_cast<int16_t>(h / 2));
|
||||||
getdisplay().setTextDatum(textdatum_t::top_center);
|
getdisplay().print(text);
|
||||||
getdisplay().drawString(text, cx, cy - static_cast<int16_t>(h / 2));
|
|
||||||
getdisplay().setTextDatum(oldDatum);
|
|
||||||
#else
|
#else
|
||||||
int16_t x1, y1;
|
int16_t x1, y1;
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
|
|||||||
Reference in New Issue
Block a user