diff --git a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h index 56428cfa..833ed101 100644 --- a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h +++ b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h @@ -313,6 +313,12 @@ class FourLineDisplayUsermod : public Usermod { (static_cast(u8x8))->setPowerSave(save); } + void center(String &line, uint8_t width) { + int len = line.length(); + if (len0; i--) line = ' ' + line; + for (byte i=line.length(); i 1 ? getCols() - 2 : 0); - drawString(1, 0, ssidString.c_str()); + line = knownSsid.substring(0, getCols() > 1 ? getCols() - 2 : 0); + center(line, getCols()-2); + drawString(1, 0, line.c_str()); // Print `~` char to indicate that SSID is longer, than our display - if (knownSsid.length() > getCols()) { + if (knownSsid.length() > getCols()-1) { drawString(getCols() - 1, 0, "~"); } @@ -416,12 +423,12 @@ class FourLineDisplayUsermod : public Usermod { drawString(1, lineHeight, apPass); } else { // alternate IP address and server name - String secondLine = knownIp.toString(); + line = knownIp.toString(); if (showName && strcmp(serverDescription, "WLED") != 0) { - secondLine = serverDescription; + line = serverDescription; } - for (uint8_t i=secondLine.length(); i