showCenterText uses const char

This commit is contained in:
Just Call Me Koko
2026-06-17 11:13:17 -04:00
parent a3f153b098
commit 61a5408df3
3 changed files with 19 additions and 11 deletions
+10 -4
View File
@@ -590,12 +590,18 @@ void Display::displayBuffer(bool do_clear)
}
}
void Display::showCenterText(String text, int y, bool small_pp)
void Display::showCenterText(const char* text, int y, bool small_pp)
{
if (!text)
text = "";
size_t len = strlen(text);
if (!small_pp)
tft.setCursor((SCREEN_WIDTH - (text.length() * (6 * BANNER_TEXT_SIZE))) / 2, y);
tft.setCursor((SCREEN_WIDTH - (len * (6 * BANNER_TEXT_SIZE))) / 2, y);
else
tft.setCursor((SCREEN_WIDTH - (text.length() * (6))) / 2, y);
tft.setCursor((SCREEN_WIDTH - (len * 6)) / 2, y);
tft.println(text);
}
@@ -619,7 +625,7 @@ void Display::buildBanner(String msg, int xpos)
this->tft.setFreeFont(NULL); // Font 4 selected
this->tft.setTextSize(BANNER_TEXT_SIZE); // Font size scaling is x1
this->tft.setTextColor(TFT_WHITE, TFT_BLACK); // Black text, no background colour
this->showCenterText(msg, banner_y);
this->showCenterText(msg.c_str(), banner_y);
}
#endif
+1 -1
View File
@@ -141,7 +141,7 @@ class Display
void getTouchWhileFunction(bool pressed);
void init();
void RunSetup();
void showCenterText(String text, int y, bool small_pp = false);
void showCenterText(const char* text, int y, bool small_pp = false);
void touchToExit();
void twoPartDisplay(String center_text);
void updateBanner(String msg);
+8 -6
View File
@@ -2112,8 +2112,10 @@ void WiFiScan::displayTargetFilter() {
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
for (int i = 0; i < access_points->size(); i++) {
AccessPoint access_point = access_points->get(i);
if (access_point.selected)
display_obj.showCenterText("CH: " + (String)access_point.channel + " " + access_point.essid, display_obj.tft.getCursorY(), true);
if (access_point.selected) {
String msg_str = "CH: " + (String)access_point.channel + " " + access_point.essid;
display_obj.showCenterText(msg_str.c_str(), display_obj.tft.getCursorY(), true);
}
}
} else {
display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
@@ -9849,8 +9851,8 @@ void WiFiScan::displayTransmitRate() {
displayString2.concat(" ");
#ifdef HAS_SCREEN
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
display_obj.showCenterText(displayString2, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString2.c_str(), TFT_HEIGHT / 2);
display_obj.showCenterText(displayString.c_str(), TFT_HEIGHT / 2);
#endif
}
@@ -10121,8 +10123,8 @@ void WiFiScan::main(uint32_t currentTime)
displayString2.concat(" ");
#ifdef HAS_SCREEN
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
display_obj.showCenterText(displayString2, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString, TFT_HEIGHT / 2);
display_obj.showCenterText(displayString2.c_str(), TFT_HEIGHT / 2);
display_obj.showCenterText(displayString.c_str(), TFT_HEIGHT / 2);
#endif
}