From 80c7abd7271fcadacff8cf74c34184987f22f07d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 1 Jul 2022 04:49:37 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Remove=20poison=20wchar=5Ft=20ma?= =?UTF-8?q?cro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/power_monitor.cpp | 6 +- Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp | 12 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 138 +++++++++--------- Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp | 12 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 18 +-- Marlin/src/lcd/dogm/lcdprint_u8g.cpp | 2 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 36 ++--- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 44 +++--- Marlin/src/lcd/dogm/u8g_fontutf8.cpp | 26 ++-- Marlin/src/lcd/dogm/u8g_fontutf8.h | 2 +- Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp | 26 ++-- Marlin/src/lcd/e3v2/marlinui/dwin_string.h | 8 +- .../src/lcd/e3v2/marlinui/lcdprint_dwin.cpp | 10 +- Marlin/src/lcd/e3v2/marlinui/ui_common.cpp | 8 +- Marlin/src/lcd/fontutils.cpp | 6 +- Marlin/src/lcd/fontutils.h | 27 ++-- Marlin/src/lcd/lcdprint.cpp | 36 ++--- Marlin/src/lcd/lcdprint.h | 10 +- Marlin/src/lcd/marlinui.cpp | 20 +-- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_password.cpp | 6 +- Marlin/src/lcd/menu/menu_tune.cpp | 4 +- Marlin/src/lcd/tft/tft_string.cpp | 16 +- Marlin/src/lcd/tft/tft_string.h | 4 +- Marlin/src/lcd/tft/ui_common.cpp | 2 +- 26 files changed, 244 insertions(+), 239 deletions(-) diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 504f1ea48e3b..5a9db1ec24a1 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -53,7 +53,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_current() { const float amps = getAmps(); lcd_put_u8str(amps < 100 ? ftostr31ns(amps) : ui16tostr4rj((uint16_t)amps)); - lcd_put_wchar('A'); + lcd_put_lchar('A'); } #endif @@ -61,7 +61,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_voltage() { const float volts = getVolts(); lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts)); - lcd_put_wchar('V'); + lcd_put_lchar('V'); } #endif @@ -69,7 +69,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_power() { const float power = getPower(); lcd_put_u8str(power < 100 ? ftostr31ns(power) : ui16tostr4rj((uint16_t)power)); - lcd_put_wchar('W'); + lcd_put_lchar('W'); } #endif diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 1e82fe403d9f..fe31c21e3959 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -50,7 +50,7 @@ extern LCD_CLASS lcd; int lcd_glyph_height() { return 1; } typedef struct _hd44780_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } hd44780_charmap_t; @@ -992,7 +992,7 @@ void lcd_put_int(const int i) { lcd.print(i); } // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1051,10 +1051,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by pixel_len_t ret = 0; const uint8_t *p = (uint8_t *)utf8_str; while (ret < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - ret += lcd_put_wchar_max(ch, max_length - ret); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + ret += lcd_put_lchar_max(wc, max_length - ret); } return (int)ret; } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index da4db8b2d419..d8306dbf945d 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -405,7 +405,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } void lcd_erase_line(const lcd_uint_t line) { lcd_moveto(0, line); for (uint8_t i = LCD_WIDTH + 1; --i;) - lcd_put_wchar(' '); + lcd_put_lchar(' '); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line @@ -413,7 +413,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } uint8_t slen = utf8_strlen(ftxt); if (slen < len) { lcd_put_u8str_max(col, line, ftxt, len); - for (; slen < len; ++slen) lcd_put_wchar(' '); + for (; slen < len; ++slen) lcd_put_lchar(' '); safe_delay(time); } else { @@ -425,7 +425,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } lcd_put_u8str_max_P(col, line, p, len); // Fill with spaces - for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_wchar(' '); + for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_lchar(' '); // Delay safe_delay(dly); @@ -439,9 +439,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); } static void logo_lines(FSTR_P const extra) { int16_t indent = (LCD_WIDTH - 8 - utf8_strlen(extra)) / 2; - lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x01'); + lcd_put_lchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x01'); lcd_put_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str(extra); - lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x03'); + lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x03'); } void MarlinUI::show_bootscreen() { @@ -510,11 +510,11 @@ void MarlinUI::draw_kill_screen() { // Homed and known, display constantly. // FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) { - lcd_put_wchar('X' + uint8_t(axis)); + lcd_put_lchar('X' + uint8_t(axis)); if (blink) lcd_put_u8str(value); else if (axis_should_home(axis)) - while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); + while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else @@ -531,27 +531,27 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr const celsius_t t1 = thermalManager.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif - if (prefix >= 0) lcd_put_wchar(prefix); + if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); - lcd_put_wchar('/'); + lcd_put_lchar('/'); #if !HEATER_IDLE_HANDLER UNUSED(blink); #else if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 >= 10) lcd_put_lchar(' '); + if (t2 >= 100) lcd_put_lchar(' '); } else #endif lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { - lcd_put_wchar(LCD_STR_DEGREE[0]); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(' '); + if (t2 < 10) lcd_put_lchar(' '); } } @@ -559,27 +559,27 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { const celsius_t t2 = thermalManager.degTargetCooler(); - if (prefix >= 0) lcd_put_wchar(prefix); + if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); - lcd_put_wchar('/'); + lcd_put_lchar('/'); #if !HEATER_IDLE_HANDLER UNUSED(blink); #else if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 >= 10) lcd_put_lchar(' '); + if (t2 >= 100) lcd_put_lchar(' '); } else #endif lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { - lcd_put_wchar(LCD_STR_DEGREE[0]); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(' '); + if (t2 < 10) lcd_put_lchar(' '); } } #endif @@ -588,7 +588,7 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { FORCE_INLINE void _draw_flowmeter_status() { lcd_put_u8str("~"); lcd_put_u8str(ftostr11ns(cooler.flowrate)); - lcd_put_wchar('L'); + lcd_put_lchar('L'); } #endif @@ -602,7 +602,7 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { } else { lcd_put_u8str(ftostr12ns(ammeter.current)); - lcd_put_wchar('A'); + lcd_put_lchar('A'); } } #endif @@ -620,7 +620,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { lcd_put_u8str(ui8tostr3rj(progress)); else lcd_put_u8str(F("---")); - lcd_put_wchar('%'); + lcd_put_lchar('%'); } #endif @@ -667,7 +667,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(ftostr12ns(filwidth.measured_mm)); lcd_put_u8str(F(" V")); lcd_put_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); - lcd_put_wchar('%'); + lcd_put_lchar('%'); return; } @@ -686,7 +686,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; } + while (slen < LCD_WIDTH) { lcd_put_lchar(' '); ++slen; } } else { // String is larger than the available space in screen. @@ -700,11 +700,11 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < LCD_WIDTH) { uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) { // Draw a third space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -726,7 +726,7 @@ void MarlinUI::draw_status_message(const bool blink) { // Fill the rest with spaces if there are missing spaces while (slen < LCD_WIDTH) { - lcd_put_wchar(' '); + lcd_put_lchar(' '); ++slen; } #endif @@ -778,7 +778,7 @@ inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink) duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0; #endif timepos -= remaining.toDigital(buffer); - lcd_put_wchar(timepos, 2, 'R'); + lcd_put_lchar(timepos, 2, 'R'); } #else constexpr bool show_remain = false; @@ -787,7 +787,7 @@ inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink) if (!show_remain) { duration_t elapsed = print_job_timer.duration(); timepos -= elapsed.toDigital(buffer); - lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]); + lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]); } lcd_put_u8str(buffer); return timepos; @@ -912,7 +912,7 @@ void MarlinUI::draw_status_screen() { else { const xy_pos_t lpos = current_position.asLogical(); _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink); - lcd_put_wchar(' '); + lcd_put_lchar(' '); _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); } @@ -926,7 +926,7 @@ void MarlinUI::draw_status_screen() { _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && !HAS_HEATED_BED - lcd_put_wchar(planner.leveling_active || blink ? '_' : ' '); + lcd_put_lchar(planner.leveling_active || blink ? '_' : ' '); #endif #endif // LCD_HEIGHT > 2 @@ -935,9 +935,9 @@ void MarlinUI::draw_status_screen() { #if LCD_HEIGHT > 3 - lcd_put_wchar(0, 2, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(0, 2, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); const uint8_t timepos = draw_elapsed_or_remaining_time(LCD_WIDTH - 1, blink); @@ -969,9 +969,9 @@ void MarlinUI::draw_status_screen() { per = planner.flow_percentage[0]; #endif } - lcd_put_wchar(c); + lcd_put_lchar(c); lcd_put_u8str(i16tostr3rj(per)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); #endif #endif @@ -993,7 +993,7 @@ void MarlinUI::draw_status_screen() { _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && (HAS_MULTI_HOTEND || !HAS_HEATED_BED) - lcd_put_wchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' '); + lcd_put_lchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' '); #endif // ========== Line 2 ========== @@ -1008,9 +1008,9 @@ void MarlinUI::draw_status_screen() { _draw_bed_status(blink); #endif - lcd_put_wchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); // ========== Line 3 ========== @@ -1075,29 +1075,29 @@ void MarlinUI::draw_status_screen() { vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int8_t pad = (LCD_WIDTH - plen - vlen) / 2; - while (--pad >= 0) { lcd_put_wchar(' '); n--; } + while (--pad >= 0) { lcd_put_lchar(' '); n--; } } if (plen) n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n); if (vlen) n -= lcd_put_u8str_max(vstr, n); - for (; n > 0; --n) lcd_put_wchar(' '); + for (; n > 0; --n) lcd_put_lchar(' '); } // Draw a generic menu item with pre_char (if selected) and post_char void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) { - lcd_put_wchar(0, row, sel ? pre_char : ' '); + lcd_put_lchar(0, row, sel ? pre_char : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2); - for (; n; --n) lcd_put_wchar(' '); - lcd_put_wchar(post_char); + for (; n; --n) lcd_put_lchar(' '); + lcd_put_lchar(post_char); } // Draw a menu item with a (potentially) editable value void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) { const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0; - lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); + lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vlen); if (vlen) { - lcd_put_wchar(':'); - for (; n; --n) lcd_put_wchar(' '); + lcd_put_lchar(':'); + for (; n; --n) lcd_put_lchar(' '); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } } @@ -1107,10 +1107,10 @@ void MarlinUI::draw_status_screen() { ui.encoder_direction_normal(); uint8_t n = lcd_put_u8str(0, 1, ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1); if (value) { - lcd_put_wchar(':'); n--; + lcd_put_lchar(':'); n--; const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space const lcd_uint_t valrow = n < len ? 2 : 1; // Value on the next row if it won't fit - lcd_put_wchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space + lcd_put_lchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space lcd_put_u8str(value); } } @@ -1120,22 +1120,22 @@ void MarlinUI::draw_status_screen() { ui.draw_select_screen_prompt(pref, string, suff); if (no) { SETCURSOR(0, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_wchar(yesno ? ' ' : ']'); + lcd_put_lchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_lchar(yesno ? ' ' : ']'); } if (yes) { SETCURSOR_RJ(utf8_strlen(yes) + 2, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_wchar(yesno ? ']' : ' '); + lcd_put_lchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_lchar(yesno ? ']' : ' '); } } #if ENABLED(SDSUPPORT) void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { - lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); + lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); constexpr uint8_t maxlen = LCD_WIDTH - 2; uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); - for (; n; --n) lcd_put_wchar(' '); - lcd_put_wchar(isDir ? LCD_STR_FOLDER[0] : ' '); + for (; n; --n) lcd_put_lchar(' '); + lcd_put_lchar(isDir ? LCD_STR_FOLDER[0] : ' '); } #endif @@ -1253,7 +1253,7 @@ void MarlinUI::draw_status_screen() { void prep_and_put_map_char(custom_char &chrdata, const coordinate &ul, const coordinate &lr, const coordinate &brc, const uint8_t cl, const char c, const lcd_uint_t x, const lcd_uint_t y) { add_edges_to_custom_char(chrdata, ul, lr, brc, cl); lcd.createChar(c, (uint8_t*)&chrdata); - lcd_put_wchar(x, y, c); + lcd_put_lchar(x, y, c); } void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { @@ -1270,7 +1270,7 @@ void MarlinUI::draw_status_screen() { #define _LCD_W_POS 8 #define _PLOT_X 0 #define _MAP_X 1 - #define _LABEL(X,Y,C) lcd_put_wchar(X, Y, C) + #define _LABEL(X,Y,C) lcd_put_lchar(X, Y, C) #define _XLABEL(X,Y) _LABEL('X',X,Y) #define _YLABEL(X,Y) _LABEL('Y',X,Y) #define _ZLABEL(X,Y) _LABEL('Z',X,Y) @@ -1333,13 +1333,13 @@ void MarlinUI::draw_status_screen() { n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1; for (i = 0; i < n_cols; i++) { - lcd_put_wchar(i, 0, CHAR_LINE_TOP); // Box Top line - lcd_put_wchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line + lcd_put_lchar(i, 0, CHAR_LINE_TOP); // Box Top line + lcd_put_lchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line } for (j = 0; j < n_rows; j++) { - lcd_put_wchar(0, j, CHAR_EDGE_L); // Box Left edge - lcd_put_wchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge + lcd_put_lchar(0, j, CHAR_EDGE_L); // Box Left edge + lcd_put_lchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge } /** @@ -1349,8 +1349,8 @@ void MarlinUI::draw_status_screen() { k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2; l = (HD44780_CHAR_HEIGHT) * n_rows; if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) { - lcd_put_wchar(0, n_rows - 1, ' '); // Box Left edge - lcd_put_wchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge + lcd_put_lchar(0, n_rows - 1, ' '); // Box Left edge + lcd_put_lchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge } clear_custom_char(&new_char); @@ -1464,11 +1464,11 @@ void MarlinUI::draw_status_screen() { /** * Print plot position */ - lcd_put_wchar(_LCD_W_POS, 0, '('); + lcd_put_lchar(_LCD_W_POS, 0, '('); lcd_put_u8str(ui8tostr3rj(x_plot)); - lcd_put_wchar(','); + lcd_put_lchar(','); lcd_put_u8str(ui8tostr3rj(y_plot)); - lcd_put_wchar(')'); + lcd_put_lchar(')'); #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index 7b15b786055c..e681ff0a9170 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -48,7 +48,7 @@ int lcd_glyph_height() { return 1; } typedef struct _TFTGLCD_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } TFTGLCD_charmap_t; @@ -991,7 +991,7 @@ void lcd_put_int(const int i) { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1049,10 +1049,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by pixel_len_t ret = 0; const uint8_t *p = (uint8_t *)utf8_str; while (ret < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - ret += lcd_put_wchar_max(ch, max_length - ret); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + ret += lcd_put_lchar_max(wc, max_length - ret); } return (int)ret; } diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 46564bb1e6e2..f3d98ec55584 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -524,16 +524,16 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const UNUSED(blink); #else if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 >= 10) lcd_put_lchar(' '); + if (t2 >= 100) lcd_put_lchar(' '); } else #endif lcd_put_u8str(i16tostr3left(t2)); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 < 10) lcd_put_lchar(' '); if (t2) picBits |= ICON_TEMP1; else picBits &= ~ICON_TEMP1; @@ -545,7 +545,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_flowmeter_status() { lcd_moveto(5, 5); lcd_put_u8str(F("FLOW")); - lcd_moveto(7, 6); lcd_put_wchar('L'); + lcd_moveto(7, 6); lcd_put_lchar('L'); lcd_moveto(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); if (cooler.flowrate) picBits |= ICON_FAN; @@ -564,7 +564,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const { lcd_put_u8str("mA"); lcd_moveto(10, 7); - lcd_put_wchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); + lcd_put_lchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); } else { lcd_put_u8str(" A"); @@ -585,9 +585,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if CUTTER_UNIT_IS(RPM) lcd_moveto(16, 6); lcd_put_u8str(F("RPM")); lcd_moveto(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); - lcd_put_wchar('K'); + lcd_put_lchar('K'); #elif CUTTER_UNIT_IS(PERCENT) - lcd_moveto(17, 6); lcd_put_wchar('%'); + lcd_moveto(17, 6); lcd_put_lchar('%'); lcd_moveto(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); #else lcd_moveto(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index f5c13798f234..48b2e92a118d 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -28,7 +28,7 @@ void lcd_put_int(const int i) { u8g.print(i); } // return < 0 on error // return the advanced pixels -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { if (c < 256) { u8g.print((char)c); return u8g_GetFontBBXWidth(u8g.getU8g()); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 3c661a44294a..e32715988d2f 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -371,11 +371,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (!PAGE_CONTAINS(y1 + 1, y2 + 2)) return; - lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); - lcd_put_wchar((char)('1' + extruder)); - lcd_put_wchar(' '); + lcd_put_lchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); + lcd_put_lchar((char)('1' + extruder)); + lcd_put_lchar(' '); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); - lcd_put_wchar('/'); + lcd_put_lchar('/'); if (get_blink() || !thermalManager.heater_idle[extruder].timed_out) lcd_put_u8str(i16tostr3rj(thermalManager.degTargetHotend(extruder))); @@ -421,12 +421,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2; - while (--pad >= 0) n -= lcd_put_wchar(' '); + while (--pad >= 0) n -= lcd_put_lchar(' '); } if (plen) n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, n / (MENU_FONT_WIDTH)) * (MENU_FONT_WIDTH); if (vlen) n -= lcd_put_u8str_max(vstr, n); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); } } @@ -434,9 +434,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char, const char post_char) { if (mark_as_selected(row, sel)) { pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1) * (MENU_FONT_WIDTH); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); - lcd_put_wchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); - lcd_put_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + lcd_put_lchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); + lcd_put_lchar(' '); } } @@ -449,8 +449,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vallen * prop) * (MENU_FONT_WIDTH); if (vallen) { - lcd_put_wchar(':'); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + lcd_put_lchar(':'); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); lcd_moveto(LCD_PIXEL_WIDTH - _MAX((MENU_FONT_WIDTH) * vallen, pixelwidth + 2), row_y2); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } @@ -494,14 +494,14 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // If a value is included, print a colon, then print the value right-justified if (value) { - lcd_put_wchar(':'); + lcd_put_lchar(':'); if (extra_row) { // Assume that value is numeric (with no descender) baseline += EDIT_FONT_ASCENT + 2; onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline); } if (onpage) { - lcd_put_wchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space + lcd_put_lchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space lcd_put_u8str(value); } } @@ -533,10 +533,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { if (mark_as_selected(row, sel)) { const uint8_t maxlen = LCD_WIDTH - isDir; - if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]); + if (isDir) lcd_put_lchar(LCD_STR_FOLDER[0]); const pixel_len_t pixw = maxlen * (MENU_FONT_WIDTH); pixel_len_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); } } @@ -611,11 +611,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Print plot position if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) { - lcd_put_wchar(5, LCD_PIXEL_HEIGHT, '('); + lcd_put_lchar(5, LCD_PIXEL_HEIGHT, '('); u8g.print(x_plot); - lcd_put_wchar(','); + lcd_put_lchar(','); u8g.print(y_plot); - lcd_put_wchar(')'); + lcd_put_lchar(')'); // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 010a1397f620..858c6ea781fb 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -200,7 +200,7 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co const char *str = i16tostr3rj(temp); const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); - lcd_put_wchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(LCD_STR_DEGREE[0]); } } @@ -432,13 +432,13 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const const bool is_inch = parser.using_inch_units(); const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis); const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING); - lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis)); + lcd_put_lchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis)); lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE); if (blink) lcd_put_u8str(value); else if (axis_should_home(axis)) - while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); + while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else @@ -675,7 +675,7 @@ void MarlinUI::draw_status_screen() { lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); - lcd_put_wchar('K'); + lcd_put_lchar('K'); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #endif @@ -734,7 +734,7 @@ void MarlinUI::draw_status_screen() { } #endif lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd))); - lcd_put_wchar(c); + lcd_put_lchar(c); } } #endif @@ -783,7 +783,7 @@ void MarlinUI::draw_status_screen() { if (progress_state == 0) { if (progress_string[0]) { lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); - lcd_put_wchar('%'); + lcd_put_lchar('%'); } } else if (progress_state == 2 && estimation_string[0]) { @@ -804,7 +804,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(SHOW_SD_PERCENT) if (progress_string[0]) { lcd_put_u8str(55, EXTRAS_BASELINE, progress_string); // Percent complete - lcd_put_wchar('%'); + lcd_put_lchar('%'); } #endif @@ -814,7 +814,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(SHOW_REMAINING_TIME) if (blink && estimation_string[0]) { - lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, 'R'); + lcd_put_lchar(estimation_x_pos, EXTRAS_BASELINE, 'R'); lcd_put_u8str(estimation_string); } else @@ -912,11 +912,11 @@ void MarlinUI::draw_status_screen() { if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) { set_font(FONT_MENU); - lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]); set_font(FONT_STATUSMENU); lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); // // Filament sensor display if SD is disabled @@ -924,10 +924,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT) lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring); lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring); - lcd_put_wchar('%'); + lcd_put_lchar('%'); set_font(FONT_MENU); - lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); + lcd_put_lchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); + lcd_put_lchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); #endif } @@ -941,12 +941,12 @@ void MarlinUI::draw_status_screen() { // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); lcd_put_u8str(wstring); lcd_put_u8str(F(" " LCD_STR_FILAM_MUL)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); lcd_put_u8str(mstring); - lcd_put_wchar('%'); + lcd_put_lchar('%'); return; } #endif @@ -979,7 +979,7 @@ void MarlinUI::draw_status_message(const bool blink) { if (slen <= lcd_width) { // The string fits within the line. Print with no scrolling lcd_put_u8str(status_message); - while (slen < lcd_width) { lcd_put_wchar(' '); ++slen; } + while (slen < lcd_width) { lcd_put_lchar(' '); ++slen; } } else { // String is longer than the available space @@ -997,14 +997,14 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < lcd_width) { uint8_t chars = lcd_width - rlen; // Amount of space left in characters - lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) { // Draw a third space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) { // Print a second copy of the message lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); - lcd_put_wchar(' '); + lcd_put_lchar(' '); } } } @@ -1019,7 +1019,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, pixel_width); // Fill the rest with spaces - for (; slen < lcd_width; ++slen) lcd_put_wchar(' '); + for (; slen < lcd_width; ++slen) lcd_put_lchar(' '); #endif // !STATUS_MESSAGE_SCROLLING diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index 8ba0e7d50a8b..d5e0e5bafff3 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -60,11 +60,11 @@ static int fontgroup_init(font_group_t * root, const uxg_fontinfo_t * fntinfo, i return 0; } -static const font_t* fontgroup_find(font_group_t * root, wchar_t val) { - uxg_fontinfo_t vcmp = {(uint16_t)(val / 128), (uint8_t)(val % 128 + 128), (uint8_t)(val % 128 + 128), 0, 0}; - size_t idx = 0; +static const font_t* fontgroup_find(font_group_t * root, const lchar_t &val) { + if (val <= 0xFF) return nullptr; - if (val < 256) return nullptr; + uxg_fontinfo_t vcmp = { uint16_t(val >> 7), uint8_t((val & 0x7F) + 0x80), uint8_t((val & 0x7F) + 0x80), 0, 0 }; + size_t idx = 0; if (pf_bsearch_r((void*)root->m_fntifo, root->m_fntinfo_num, pf_bsearch_cb_comp_fntifo_pgm, (void*)&vcmp, &idx) < 0) return nullptr; @@ -73,7 +73,7 @@ static const font_t* fontgroup_find(font_group_t * root, wchar_t val) { return vcmp.fntdata; } -static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, wchar_t val, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { +static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, const lchar_t &val, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { uint8_t buf[2] = {0, 0}; const font_t * fntpqm = (font_t*)fontgroup_find(group, val); if (!fntpqm) { @@ -106,10 +106,10 @@ static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, static void fontgroup_drawstring(font_group_t *group, const font_t *fnt_default, const char *utf8_msg, read_byte_cb_t cb_read_byte, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { const uint8_t *p = (uint8_t*)utf8_msg; for (;;) { - wchar_t val = 0; - p = get_utf8_value_cb(p, cb_read_byte, &val); - if (!val) break; - fontgroup_drawwchar(group, fnt_default, val, userdata, cb_draw_ram); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + fontgroup_drawwchar(group, fnt_default, wc, userdata, cb_draw_ram); } } @@ -149,19 +149,19 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons } /** - * @brief Draw a wchar_t at the specified position + * @brief Draw a lchar_t at the specified position * * @param pu8g : U8G pointer * @param x : position x axis * @param y : position y axis - * @param ch : the wchar_t + * @param wc : the lchar_t * @param max_width : the pixel width of the string allowed * * @return number of pixels advanced * * Draw a UTF-8 string at the specified position */ -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, pixel_len_t max_width) { +unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &wc, pixel_len_t max_width) { struct _uxg_drawu8_data_t data; font_group_t *group = &g_fontgroup_root; const font_t *fnt_default = uxg_GetFont(pu8g); @@ -176,7 +176,7 @@ unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t data.adv = 0; data.max_width = max_width; data.fnt_prev = nullptr; - fontgroup_drawwchar(group, fnt_default, ch, (void*)&data, fontgroup_cb_draw_u8g); + fontgroup_drawwchar(group, fnt_default, wc, (void*)&data, fontgroup_cb_draw_u8g); u8g_SetFont(pu8g, (const u8g_fntpgm_uint8_t*)fnt_default); return data.adv; diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 5933f027cc79..0109b6674cbe 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -26,7 +26,7 @@ typedef struct _uxg_fontinfo_t { int uxg_SetUtf8Fonts(const uxg_fontinfo_t * fntinfo, int number); // fntinfo is type of PROGMEM -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, const pixel_len_t max_length); +unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &ch, const pixel_len_t max_length); unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, const pixel_len_t max_length); unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, const pixel_len_t max_length); diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp index 30e86270c726..38a8eafe2366 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp @@ -50,12 +50,12 @@ uint8_t read_byte(const uint8_t *byte) { return *byte; } * @ displays an axis name such as XYZUVW, or E for an extruder */ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { - wchar_t wchar; + lchar_t wc; while (*tpl) { - tpl = get_utf8_value_cb(tpl, read_byte, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + tpl = get_utf8_value_cb(tpl, read_byte, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -80,32 +80,32 @@ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nu } void DWIN_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { - wchar_t wchar; + lchar_t wc; while (*cstr && max_len) { - cstr = get_utf8_value_cb(cstr, read_byte, &wchar); + cstr = get_utf8_value_cb(cstr, read_byte, wc); /* - if (wchar > 255) wchar |= 0x0080; - uint8_t ch = uint8_t(wchar & 0x00FF); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); add_character(ch); */ - add(wchar); + add(wc); max_len--; } eol(); } -void DWIN_String::add(const wchar_t character) { +void DWIN_String::add(const lchar_t &wc) { int ret; size_t idx = 0; dwin_charmap_t pinval; dwin_charmap_t *copy_address = nullptr; - pinval.uchar = character; + pinval.uchar = wc; pinval.idx = -1; // For 8-bit ASCII just print the single character char str[] = { '?', 0 }; - if (character < 255) { - str[0] = (char)character; + if (wc < 255) { + str[0] = (char)wc; } else { copy_address = nullptr; diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h index c29777ae7b12..686b1aa2b17a 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h @@ -29,7 +29,7 @@ #include typedef struct _dwin_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } dwin_charmap_t; @@ -69,10 +69,10 @@ class DWIN_String { /** * @brief Append a UTF-8 character * - * @param character The UTF-8 character + * @param wc The UTF-8 character */ - static void add(wchar_t character); - static void set(wchar_t character) { set(); add(character); } + static void add(const lchar_t &wc); + static void set(const lchar_t &wc) { set(); add(wc); } /** * @brief Append / Set C-string diff --git a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp index 278f17fac994..e603882e0cfd 100644 --- a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp @@ -63,7 +63,7 @@ int lcd_put_dwin_string() { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { dwin_string.set(c); dwin_string.truncate(max_length); // Draw the char(s) at the cursor and advance the cursor @@ -87,10 +87,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by const uint8_t *p = (uint8_t *)utf8_str; dwin_string.set(); while (dwin_string.length < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - dwin_string.add(ch); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + dwin_string.add(wc); } DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string()); lcd_advance_cursor(dwin_string.length); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index 0727ab0b70ca..455fce272a1c 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -213,7 +213,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < max_status_chars) { lcd_put_wchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } } } else { @@ -227,10 +227,10 @@ void MarlinUI::draw_status_message(const bool blink) { // If the string doesn't completely fill the line... if (rlen < max_status_chars) { - lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot + lcd_put_lchar('.'); // Always at 1+ spaces left, draw a dot uint8_t chars = max_status_chars - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space - lcd_put_wchar('.'); + lcd_put_lchar('.'); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -254,7 +254,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, max_status_chars); // Fill the rest with spaces if there are missing spaces - while (slen < max_status_chars) { lcd_put_wchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } } #endif diff --git a/Marlin/src/lcd/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index a97e63ac4d3a..46329fd4be62 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -31,8 +31,6 @@ #include "../inc/MarlinConfig.h" -#define MAX_UTF8_CHAR_SIZE 4 - #if HAS_WIRED_LCD #include "marlinui.h" #include "../MarlinCore.h" @@ -99,7 +97,7 @@ static inline bool utf8_is_start_byte_of_char(const uint8_t b) { /* This function gets the character at the pstart position, interpreting UTF8 multibyte sequences and returns the pointer to the next character */ -const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { +const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) { uint32_t val = 0; const uint8_t *p = pstart; @@ -158,7 +156,7 @@ const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_b else for (; 0xFC < (0xFE & valcur); ) { p++; valcur = cb_read_byte(p); } - if (pval) *pval = val; + pval = val; return p; } diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index e01962d7ad80..69edf1a0c839 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -31,36 +31,41 @@ #pragma once #include -#include // wchar_t #include // uint32_t #include "../HAL/shared/Marduino.h" #include "../core/macros.h" +#define MAX_UTF8_CHAR_SIZE 4 + +// Use a longer character type (if needed) because wchar_t is only 16 bits wide +#ifdef MAX_UTF8_CHAR_SIZE + #if MAX_UTF8_CHAR_SIZE > 2 + typedef uint32_t lchar_t; + #else + typedef wchar_t lchar_t; + #endif +#else + #define wchar_t uint32_t +#endif + // read a byte from ROM or RAM typedef uint8_t (*read_byte_cb_t)(const uint8_t * str); uint8_t read_byte_ram(const uint8_t *str); uint8_t read_byte_rom(const uint8_t *str); -// there's overflow of the wchar_t due to the 2-byte size in Arduino -// sizeof(wchar_t)=2; sizeof(size_t)=2; sizeof(uint32_t)=4; -// sizeof(int)=2; sizeof(long)=4; sizeof(unsigned)=2; -//#undef wchar_t -#define wchar_t uint32_t -//typedef uint32_t wchar_t; - typedef uint16_t pixel_len_t; #define PIXEL_LEN_NOLIMIT ((pixel_len_t)(-1)) /* Perform binary search */ -typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); /*"data_list[idx] - *data_pin"*/ +typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, void *data_pinpoint, size_t *ret_idx); /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */ -const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval); +const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval); -inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { +inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) { return (const char *)get_utf8_value_cb((const uint8_t *)pstart, cb_read_byte, pval); } diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index deec2b1778b8..7757379ac9d2 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -47,19 +47,19 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ const uint8_t *p = (uint8_t*)ptpl; int8_t n = maxlen; while (n > 0) { - wchar_t ch; - p = get_utf8_value_cb(p, read_byte_rom, &ch); - if (!ch) break; - if (ch == '=' || ch == '~' || ch == '*') { + lchar_t wc; + p = get_utf8_value_cb(p, read_byte_rom, wc); + if (!wc) break; + if (wc == '=' || wc == '~' || wc == '*') { if (ind >= 0) { - if (ch == '*') { lcd_put_wchar('E'); n--; } + if (wc == '*') { lcd_put_lchar('E'); n--; } if (n) { - int8_t inum = ind + ((ch == '=') ? 0 : LCD_FIRST_TOOL); + int8_t inum = ind + ((wc == '=') ? 0 : LCD_FIRST_TOOL); if (inum >= 10) { - lcd_put_wchar('0' + (inum / 10)); n--; + lcd_put_lchar('0' + (inum / 10)); n--; inum %= 10; } - if (n) { lcd_put_wchar('0' + inum); n--; } + if (n) { lcd_put_lchar('0' + inum); n--; } } } else { @@ -71,19 +71,19 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ break; } } - else if (ch == '$' && fstr) { + else if (wc == '$' && fstr) { n -= lcd_put_u8str_max_P(FTOP(fstr), n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } - else if (ch == '$' && cstr) { + else if (wc == '$' && cstr) { n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } - else if (ch == '@') { - lcd_put_wchar(AXIS_CHAR(ind)); + else if (wc == '@') { + lcd_put_lchar(AXIS_CHAR(ind)); n--; } else { - lcd_put_wchar(ch); - n -= ch > 255 ? prop : 1; + lcd_put_lchar(wc); + n -= wc > 255 ? prop : 1; } } return n; @@ -97,10 +97,10 @@ int calculateWidth(PGM_P const pstr) { int n = 0; do { - wchar_t ch; - p = get_utf8_value_cb(p, read_byte_rom, &ch); - if (!ch) break; - n += (ch > 255) ? prop : 1; + lchar_t wc; + p = get_utf8_value_cb(p, read_byte_rom, wc); + if (!wc) break; + n += (wc > 255) ? prop : 1; } while (1); return n * MENU_FONT_WIDTH; diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index 2eb47c534b05..bcf85cb69396 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -138,7 +138,7 @@ int lcd_glyph_height(); * * @return the output width (in pixels on GLCD) */ -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length); +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length); /** * @brief Draw a SRAM UTF-8 string @@ -267,17 +267,17 @@ inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, const char /** * @brief Draw a UTF-8 character with no width limit * - * @param c The wchar to draw + * @param c The lchar to draw * @return the output width (in pixels on GLCD) */ -inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); } +inline int lcd_put_lchar(const lchar_t &c) { return lcd_put_lchar_max(c, PIXEL_LEN_NOLIMIT); } /** * @param col * @param row */ -inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) { +inline int lcd_put_lchar(const lcd_uint_t col, const lcd_uint_t row, const lchar_t &c) { lcd_moveto(col, row); - return lcd_put_wchar(c); + return lcd_put_lchar(c); } /** diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index c1b600593457..7d9cb1b679d6 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -417,26 +417,26 @@ void MarlinUI::init() { }; const uint8_t *p = (uint8_t*)string; - wchar_t ch; + lchar_t wc; if (wordwrap) { const uint8_t *wrd = nullptr; uint8_t c = 0; // find the end of the part for (;;) { if (!wrd) wrd = p; // Get word start /before/ advancing - p = get_utf8_value_cb(p, cb_read_byte, &ch); - const bool eol = !ch; // zero ends the string + p = get_utf8_value_cb(p, cb_read_byte, wc); + const bool eol = !wc; // zero ends the string // End or a break between phrases? - if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') { - if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces + if (eol || wc == ' ' || wc == '-' || wc == '+' || wc == '.') { + if (!c && wc == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces // Past the right and the word is not too long? if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap? c += !eol; // +1 so the space will be printed col += c; // advance col to new position while (c) { // character countdown --c; // count down to zero - wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again - lcd_put_wchar(ch); // character to the LCD + wrd = get_utf8_value_cb(wrd, cb_read_byte, wc); // get characters again + lcd_put_lchar(wc); // character to the LCD } if (eol) break; // all done! wrd = nullptr; // set up for next word @@ -446,9 +446,9 @@ void MarlinUI::init() { } else { for (;;) { - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - lcd_put_wchar(ch); + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + lcd_put_lchar(wc); col++; if (col >= LCD_WIDTH) _newline(); } diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 3fe0c582cb10..c4a63dafc6ac 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -178,7 +178,7 @@ static void _lcd_level_bed_corners_get_next_position() { lcd_put_u8str(GET_TEXT_F(MSG_BED_TRAMMING_GOOD_POINTS)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); - lcd_put_wchar('/'); + lcd_put_lchar('/'); lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points)); } diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 8b6af33fd11e..1f2257a77fe3 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -79,7 +79,7 @@ void menu_advanced_settings(); LIMIT(bar_percent, 0, 100); ui.encoderPosition = 0; MenuItem_static::draw(0, GET_TEXT_F(MSG_PROGRESS_BAR_TEST), SS_DEFAULT|SS_INVERT); - lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_wchar('%'); + lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_lchar('%'); lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent); } diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index 89ea42d70477..d29b77311fd3 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -61,10 +61,10 @@ void Password::menu_password_entry() { FSTR_P const label = GET_TEXT_F(MSG_ENTER_DIGIT); EDIT_ITEM_F(uint8, label, &editable.uint8, 0, 9, digit_entered); MENU_ITEM_ADDON_START(utf8_strlen(label) + 1); - lcd_put_wchar(' '); - lcd_put_wchar('1' + digit_no); + lcd_put_lchar(' '); + lcd_put_lchar('1' + digit_no); SETCURSOR_X(LCD_WIDTH - 2); - lcd_put_wchar('>'); + lcd_put_lchar('>'); MENU_ITEM_ADDON_END(); ACTION_ITEM(MSG_START_OVER, start_over); diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index b13c55f80a3b..bc5200196717 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -76,12 +76,12 @@ #if ENABLED(TFT_COLOR_UI) lcd_moveto(4, 3); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); lcd_moveto(10, 3); #else lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1)); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); #endif lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); } diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index d8c419d1a078..d589b0465b7f 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -94,12 +94,12 @@ void TFT_String::set() { * @ displays an axis name such as XYZUVW, or E for an extruder */ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { - wchar_t wchar; + lchar_t wc; while (*tpl) { - tpl = get_utf8_value_cb(tpl, read_byte_ram, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + tpl = get_utf8_value_cb(tpl, read_byte_ram, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -124,11 +124,11 @@ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nul } void TFT_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { - wchar_t wchar; + lchar_t wc; while (*cstr && max_len) { - cstr = get_utf8_value_cb(cstr, read_byte_ram, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + cstr = get_utf8_value_cb(cstr, read_byte_ram, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); add_character(ch); max_len--; } diff --git a/Marlin/src/lcd/tft/tft_string.h b/Marlin/src/lcd/tft/tft_string.h index 5940a48ac98b..d43e0b0df2b4 100644 --- a/Marlin/src/lcd/tft/tft_string.h +++ b/Marlin/src/lcd/tft/tft_string.h @@ -25,6 +25,8 @@ #include +#include "../fontutils.h" + extern const uint8_t ISO10646_1_5x7[]; extern const uint8_t font10x20[]; @@ -97,7 +99,7 @@ class TFT_String { * @param character The ASCII character */ static void add(const char character) { add_character(character); eol(); } - static void set(wchar_t character) { set(); add(character); } + static void set(const lchar_t &character) { set(); add(character); } /** * @brief Append / Set C-string diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index c9e069dbbd6f..bb0578576632 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -96,7 +96,7 @@ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { lcd_gotopixel(int(col) * (TFT_COL_WIDTH), int(row) * MENU_LINE_HEIGHT); } -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { if (max_length < 1) return 0; tft_string.set(c); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);