From c8cf7b8046dd295cb7d08b2540aed784bbf6ea42 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 11 Nov 2023 10:19:04 +0100 Subject: [PATCH] Change parameter of `display_wrapped_text` To add compatibility to ESPHome 2023.11 Solves #1247 --- nspanel_esphome_core.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index e59020b..3826a83 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -1971,30 +1971,30 @@ script: mode: queued parameters: component: string - text: string + text_to_display: string line_length_limit: uint then: - lambda: |- int startPos = 0; int endPos = 0; std::string wrappedText = ""; - while (startPos < text.length()) { - while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } + while (startPos < text_to_display.length()) { + while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; } int endPos = startPos + line_length_limit; - if (endPos >= text.length()) endPos = text.length(); + if (endPos >= text_to_display.length()) endPos = text_to_display.length(); else { - while (endPos > startPos && text[endPos] != ' ') { endPos--; } + while (endPos > startPos && text_to_display[endPos] != ' ') { endPos--; } if (endPos == startPos) endPos = startPos + line_length_limit; // Handle case of long word } - wrappedText += text.substr(startPos, endPos-startPos); - if (endPos < text.length()) + wrappedText += text_to_display.substr(startPos, endPos-startPos); + if (endPos < text_to_display.length()) { - while (text[endPos] == ' ') { endPos--; } + while (text_to_display[endPos] == ' ') { endPos--; } if (endPos >= startPos) wrappedText += "\\r"; } startPos = endPos + 1; // Skip the space - while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } + while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; } } disp1->set_component_text_printf(component.c_str(), "%s", wrappedText.c_str());