From c06a183f28ea4d40ea7757d441a46cc733cd6a12 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sun, 29 Aug 2021 16:05:30 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Fix,=20enhance=20FTDI=20Ev?= =?UTF-8?q?e=20Touch=20UI=20(#22619)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ftdi_eve_lib/extended/text_box.cpp | 12 ++++++--- .../extui/ftdi_eve_touch_ui/theme/bitmaps.h | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index 544c5fed05..342b1e4d2b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -23,6 +23,10 @@ #if ENABLED(FTDI_EXTENDED) +#define IS_LINE_SEPARATOR(c) c == '\n' || c == '\t' +#define IS_WORD_SEPARATOR(c) c == ' ' +#define IS_SEPARATOR(c) IS_LINE_SEPARATOR(c) || IS_WORD_SEPARATOR(c) + namespace FTDI { /** * Given a str, end will be set to the position at which a line needs to @@ -37,11 +41,11 @@ namespace FTDI { const char *next = p; const utf8_char_t c = get_utf8_char_and_inc(next); // Decide whether to break the string at this location - if (c == '\n' || c == '\0' || c == ' ') { + if (IS_SEPARATOR(c) || c == '\0' ) { end = p; result = lw; } - if (c == '\n' || c == '\0') break; + if (IS_LINE_SEPARATOR(c) || c == '\0') break; // Measure the next character const uint16_t cw = use_utf8 ? utf8_fm.get_char_width(c) : clcd_fm.char_widths[(uint8_t)c]; // Stop processing once string exceeds the display width @@ -69,7 +73,7 @@ namespace FTDI { const uint16_t line_width = find_line_break(utf8_fm, clcd_fm, wrap_width, line_start, line_end, use_utf8); width = max(width, line_width); height += utf8_fm.get_height(); - if (*line_end == '\n' || *line_end == ' ') line_end++; + if (IS_SEPARATOR(*line_end)) line_end++; if (*line_end == '\0') break; if (line_end == line_start) break; line_start = line_end; @@ -124,7 +128,7 @@ namespace FTDI { } y += utf8_fm.get_height(); - if (*line_end == '\n' || *line_end == ' ') line_end++; + if (IS_SEPARATOR(*line_end)) line_end++; if (*line_end == '\0') break; if (line_end == line_start) break; line_start = line_end; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h index f7cb63125f..c689f23905 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/bitmaps.h @@ -229,5 +229,31 @@ namespace Theme { 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00 }; + constexpr PROGMEM bitmap_info_t Light_Bulb_Info = { + .format = L1, + .linestride = 4, + .filter = BILINEAR, + .wrapx = BORDER, + .wrapy = BORDER, + .RAMG_offset = 8685, + .width = 31, + .height = 32, + }; + + const unsigned char Light_Bulb[128] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, + 0x02, 0x00, 0x00, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, + 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x18, 0x30, 0x00, 0x00, 0x36, 0x18, 0x00, + 0x00, 0x2C, 0x08, 0x00, 0x00, 0x58, 0x04, 0x00, 0x00, 0x50, 0x04, 0x00, + 0x7C, 0x50, 0x04, 0x7C, 0x00, 0x40, 0x04, 0x00, 0x00, 0x40, 0x04, 0x00, + 0x00, 0x60, 0x0C, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x88, 0x22, 0x00, 0x01, 0x08, 0x21, 0x00, + 0x02, 0x08, 0x20, 0x80, 0x04, 0x0F, 0xE0, 0x40, 0x00, 0x07, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + constexpr PROGMEM uint32_t UTF8_FONT_OFFSET = 10000; + constexpr PROGMEM uint32_t BACKGROUND_OFFSET = 40000; }; // namespace Theme