Language based bytes per char

Solves #2000
This commit is contained in:
Edward Firmo
2024-04-04 09:45:52 +02:00
parent 6e0137bcec
commit 7eed2adcc6
2 changed files with 48 additions and 5 deletions

View File

@@ -15,8 +15,9 @@ substitutions:
ota_password: ${wifi_password}
temp_units: "°C"
invalid_cooldown: "100ms"
bytes_per_char: "1"
##### DON'T CHANGE THIS ######
version: "4.3.2"
version: "4.3.3d1"
##############################
##### External components #####
@@ -339,6 +340,7 @@ api:
screensaver_time_font: int # Specifies the font id for the screensaver time display.
screensaver_time_color: int[] # RGB color for the screensaver time display, e.g., [165, 42, 42] for reddish-brown.
decimal_separator: string # The char to be used as decimal separator.
# bytes_per_char: init
then:
- if:
condition:
@@ -354,6 +356,7 @@ api:
screensaver_time_font: !lambda return screensaver_time_font;
screensaver_time_color: !lambda return screensaver_time_color;
decimal_separator: !lambda return decimal_separator;
# bytes_per_char: !lambda return bytes_per_char;
- script.wait: global_settings
- lambda: blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 5));
@@ -985,6 +988,11 @@ display:
##### START - GLOBALS CONFIGURATION #####
globals:
- id: mui_bytes_per_char
type: uint8_t
restore_value: true
initial_value: ${bytes_per_char}
###### Buttons settings ######
# Bit # Settings #
# 0 # Left Bt - Enabled #
@@ -2029,12 +2037,12 @@ script:
} else {
while (startPos < text_to_display.length()) {
while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; }
int endPos = startPos + line_length_limit;
int endPos = startPos + (line_length_limit * id(mui_bytes_per_char));
if (endPos >= text_to_display.length()) endPos = text_to_display.length();
else
{
while (endPos > startPos && text_to_display[endPos] != ' ') { endPos--; }
if (endPos == startPos) endPos = startPos + line_length_limit; // Handle case of long word
if (endPos == startPos) endPos = startPos + (line_length_limit * id(mui_bytes_per_char)); // Handle case of long word
}
wrappedText += text_to_display.substr(startPos, endPos-startPos);
if (endPos < text_to_display.length())
@@ -2059,6 +2067,7 @@ script:
screensaver_time_font: int
screensaver_time_color: int32_t[]
decimal_separator: string
# bytes_per_char: int
then:
- lambda: |-
if (!id(is_uploading_tft)) {
@@ -2070,6 +2079,7 @@ script:
// MUI strings
id(mui_please_confirm_global) = mui_please_confirm;
id(mui_unavailable_global) = mui_unavailable;
// id(mui_bytes_per_char) = bytes_per_char;
// Screen saver page (sleep)
id(screensaver_display_time) = screensaver_time;