Skip to content

Commit 97c6a73

Browse files
thinkyheadLCh-77
authored andcommitted
πŸ§‘β€πŸ’» Extend LCD string substitution (MarlinFirmware#24278)
1 parent 82d1c65 commit 97c6a73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1068
-1312
lines changed

β€ŽMarlin/src/feature/dac/stepper_dac.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#if HAS_MOTOR_CURRENT_DAC
3030

3131
#include "stepper_dac.h"
32-
#include "../../MarlinCore.h" // for SP_X_LBL...
3332

3433
bool dac_present = false;
3534
constexpr xyze_uint8_t dac_order = DAC_STEPPER_ORDER;

β€ŽMarlin/src/lcd/HD44780/lcdprint_hd44780.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ void lcd_put_int(const int i) { lcd.print(i); }
992992

993993
// return < 0 on error
994994
// return the advanced cols
995-
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
995+
int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) {
996996

997997
// find the HD44780 internal ROM first
998998
int ret;
@@ -1047,9 +1047,9 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
10471047
*
10481048
* Draw a UTF-8 string
10491049
*/
1050-
static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) {
1050+
static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) {
10511051
pixel_len_t ret = 0;
1052-
uint8_t *p = (uint8_t *)utf8_str;
1052+
const uint8_t *p = (uint8_t *)utf8_str;
10531053
while (ret < max_length) {
10541054
wchar_t ch = 0;
10551055
p = get_utf8_value_cb(p, cb_read_byte, &ch);
@@ -1059,11 +1059,11 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(u
10591059
return (int)ret;
10601060
}
10611061

1062-
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
1062+
int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) {
10631063
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
10641064
}
10651065

1066-
int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
1066+
int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) {
10671067
return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length);
10681068
}
10691069

β€ŽMarlin/src/lcd/HD44780/marlinui_HD44780.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,13 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
495495
#endif // SHOW_BOOTSCREEN
496496

497497
void MarlinUI::draw_kill_screen() {
498-
lcd_put_u8str(0, 0, status_message);
499-
lcd_uint_t y = 2;
498+
lcd_uint_t x = 0, y = 0;
499+
lcd_put_u8str(x, y, status_message);
500+
y = 2;
500501
#if LCD_HEIGHT >= 4
501-
lcd_put_u8str(0, y++, GET_TEXT_F(MSG_HALTED));
502+
lcd_put_u8str(x, y++, GET_TEXT_F(MSG_HALTED));
502503
#endif
503-
lcd_put_u8str(0, y, GET_TEXT_F(MSG_PLEASE_RESET));
504+
lcd_put_u8str(x, y, GET_TEXT_F(MSG_PLEASE_RESET));
504505
}
505506

506507
//
@@ -1076,24 +1077,24 @@ void MarlinUI::draw_status_screen() {
10761077
int8_t pad = (LCD_WIDTH - plen - vlen) / 2;
10771078
while (--pad >= 0) { lcd_put_wchar(' '); n--; }
10781079
}
1079-
if (plen) n = lcd_put_u8str_ind(fstr, itemIndex, itemString, n);
1080+
if (plen) n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n);
10801081
if (vlen) n -= lcd_put_u8str_max(vstr, n);
10811082
for (; n > 0; --n) lcd_put_wchar(' ');
10821083
}
10831084

10841085
// Draw a generic menu item with pre_char (if selected) and post_char
1085-
void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char) {
1086+
void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) {
10861087
lcd_put_wchar(0, row, sel ? pre_char : ' ');
1087-
uint8_t n = lcd_put_u8str_ind(fstr, itemIndex, itemString, LCD_WIDTH - 2);
1088+
uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2);
10881089
for (; n; --n) lcd_put_wchar(' ');
10891090
lcd_put_wchar(post_char);
10901091
}
10911092

10921093
// Draw a menu item with a (potentially) editable value
1093-
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm) {
1094+
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) {
10941095
const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0;
10951096
lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
1096-
uint8_t n = lcd_put_u8str_ind(fstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen);
1097+
uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vlen);
10971098
if (vlen) {
10981099
lcd_put_wchar(':');
10991100
for (; n; --n) lcd_put_wchar(' ');
@@ -1102,9 +1103,9 @@ void MarlinUI::draw_status_screen() {
11021103
}
11031104

11041105
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
1105-
void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) {
1106+
void MenuEditItemBase::draw_edit_screen(FSTR_P const ftpl, const char * const value/*=nullptr*/) {
11061107
ui.encoder_direction_normal();
1107-
uint8_t n = lcd_put_u8str_ind(0, 1, fstr, itemIndex, itemString, LCD_WIDTH - 1);
1108+
uint8_t n = lcd_put_u8str(0, 1, ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1);
11081109
if (value) {
11091110
lcd_put_wchar(':'); n--;
11101111
const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space

β€ŽMarlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ void lcd_put_int(const int i) {
991991

992992
// return < 0 on error
993993
// return the advanced cols
994-
int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
994+
int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) {
995995

996996
// find the HD44780 internal ROM first
997997
int ret;
@@ -1045,9 +1045,9 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
10451045
*
10461046
* Draw a UTF-8 string
10471047
*/
1048-
static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) {
1048+
static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) {
10491049
pixel_len_t ret = 0;
1050-
uint8_t *p = (uint8_t *)utf8_str;
1050+
const uint8_t *p = (uint8_t *)utf8_str;
10511051
while (ret < max_length) {
10521052
wchar_t ch = 0;
10531053
p = get_utf8_value_cb(p, cb_read_byte, &ch);
@@ -1057,11 +1057,11 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(u
10571057
return (int)ret;
10581058
}
10591059

1060-
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
1060+
int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) {
10611061
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
10621062
}
10631063

1064-
int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
1064+
int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) {
10651065
return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length);
10661066
}
10671067

0 commit comments

Comments
Β (0)