diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index fd243a0..0f14cb3 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -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 diff --git a/esp32_marauder/Display.h b/esp32_marauder/Display.h index bd01f25..f9eda4b 100644 --- a/esp32_marauder/Display.h +++ b/esp32_marauder/Display.h @@ -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); diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index bbc6fc1..87abb98 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -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 }