Merge upstream changes from Marlin 2.1.1
This commit is contained in:
@@ -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(wchar_t c, 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;
|
||||
@@ -1047,24 +1047,24 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
|
||||
*
|
||||
* Draw a UTF-8 string
|
||||
*/
|
||||
static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) {
|
||||
static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) {
|
||||
pixel_len_t ret = 0;
|
||||
uint8_t *p = (uint8_t *)utf8_str;
|
||||
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;
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
|
||||
int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
|
||||
}
|
||||
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length);
|
||||
int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) {
|
||||
return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length);
|
||||
}
|
||||
|
||||
#if ENABLED(DEBUG_LCDPRINT)
|
||||
|
@@ -120,10 +120,11 @@ static void createChar_P(const char c, const byte * const ptr) {
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_USE_I2C_BUZZER)
|
||||
|
||||
void MarlinUI::buzz(const long duration, const uint16_t freq) {
|
||||
if (!buzzer_enabled) return;
|
||||
lcd.buzz(duration, freq);
|
||||
if (sound_on) lcd.buzz(duration, freq);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARSET_INFO*/) {
|
||||
@@ -284,7 +285,7 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS
|
||||
|
||||
#endif // LCD_PROGRESS_BAR
|
||||
|
||||
#if BOTH(SDSUPPORT, HAS_LCD_MENU)
|
||||
#if BOTH(SDSUPPORT, HAS_MARLINUI_MENU)
|
||||
|
||||
// CHARSET_MENU
|
||||
const static PROGMEM byte refresh[8] = {
|
||||
@@ -334,7 +335,7 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS
|
||||
#endif
|
||||
{
|
||||
createChar_P(LCD_STR_UPLEVEL[0], uplevel);
|
||||
#if BOTH(SDSUPPORT, HAS_LCD_MENU)
|
||||
#if BOTH(SDSUPPORT, HAS_MARLINUI_MENU)
|
||||
// SD Card sub-menu special characters
|
||||
createChar_P(LCD_STR_REFRESH[0], refresh);
|
||||
createChar_P(LCD_STR_FOLDER[0], folder);
|
||||
@@ -405,19 +406,19 @@ 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
|
||||
void lcd_scroll(const lcd_uint_t col, const lcd_uint_t line, PGM_P const text, const uint8_t len, const int16_t time) {
|
||||
uint8_t slen = utf8_strlen_P(text);
|
||||
void lcd_scroll(const lcd_uint_t col, const lcd_uint_t line, FSTR_P const ftxt, const uint8_t len, const int16_t time) {
|
||||
uint8_t slen = utf8_strlen(ftxt);
|
||||
if (slen < len) {
|
||||
lcd_put_u8str_max_P(col, line, text, len);
|
||||
for (; slen < len; ++slen) lcd_put_wchar(' ');
|
||||
lcd_put_u8str_max(col, line, ftxt, len);
|
||||
for (; slen < len; ++slen) lcd_put_lchar(' ');
|
||||
safe_delay(time);
|
||||
}
|
||||
else {
|
||||
PGM_P p = text;
|
||||
PGM_P p = FTOP(ftxt);
|
||||
int dly = time / _MAX(slen, 1);
|
||||
LOOP_LE_N(i, slen) {
|
||||
|
||||
@@ -425,7 +426,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);
|
||||
@@ -437,11 +438,11 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
}
|
||||
}
|
||||
|
||||
static void logo_lines(PGM_P const extra) {
|
||||
int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2;
|
||||
lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x01');
|
||||
lcd_put_u8str_P(indent, 1, PSTR("|Marlin|")); lcd_put_u8str_P(extra);
|
||||
lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x03');
|
||||
static void logo_lines(FSTR_P const extra) {
|
||||
int16_t indent = (LCD_WIDTH - 8 - utf8_strlen(extra)) / 2;
|
||||
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_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x03');
|
||||
}
|
||||
|
||||
void MarlinUI::show_bootscreen() {
|
||||
@@ -450,15 +451,16 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
|
||||
#define LCD_EXTRA_SPACE (LCD_WIDTH-8)
|
||||
|
||||
#define CENTER_OR_SCROLL(STRING,DELAY) \
|
||||
#define CENTER_OR_SCROLL(STRING,DELAY) { \
|
||||
lcd_erase_line(3); \
|
||||
if (utf8_strlen(STRING) <= LCD_WIDTH) { \
|
||||
lcd_put_u8str_P((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3, PSTR(STRING)); \
|
||||
const int len = utf8_strlen(STRING); \
|
||||
if (len <= LCD_WIDTH) { \
|
||||
lcd_put_u8str((LCD_WIDTH - len) / 2, 3, F(STRING)); \
|
||||
safe_delay(DELAY); \
|
||||
} \
|
||||
else { \
|
||||
lcd_scroll(0, 3, PSTR(STRING), LCD_WIDTH, DELAY); \
|
||||
}
|
||||
else \
|
||||
lcd_scroll(0, 3, F(STRING), LCD_WIDTH, DELAY); \
|
||||
}
|
||||
|
||||
//
|
||||
// Show the Marlin logo with splash line 1
|
||||
@@ -467,7 +469,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
//
|
||||
// Show the Marlin logo, splash line1, and splash line 2
|
||||
//
|
||||
logo_lines(PSTR(" " SHORT_BUILD_VERSION));
|
||||
logo_lines(F(" " SHORT_BUILD_VERSION));
|
||||
CENTER_OR_SCROLL(MARLIN_WEBSITE_URL, 2000);
|
||||
}
|
||||
else {
|
||||
@@ -475,7 +477,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
// Show the Marlin logo and short build version
|
||||
// After a delay show the website URL
|
||||
//
|
||||
logo_lines(NUL_STR);
|
||||
logo_lines(FPSTR(NUL_STR));
|
||||
CENTER_OR_SCROLL(SHORT_BUILD_VERSION, 1500);
|
||||
CENTER_OR_SCROLL(MARLIN_WEBSITE_URL, 1500);
|
||||
#ifdef STRING_SPLASH_LINE3
|
||||
@@ -494,12 +496,13 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
#endif // SHOW_BOOTSCREEN
|
||||
|
||||
void MarlinUI::draw_kill_screen() {
|
||||
lcd_put_u8str(0, 0, status_message);
|
||||
lcd_uint_t y = 2;
|
||||
lcd_uint_t x = 0, y = 0;
|
||||
lcd_put_u8str(x, y, status_message);
|
||||
y = 2;
|
||||
#if LCD_HEIGHT >= 4
|
||||
lcd_put_u8str_P(0, y++, GET_TEXT(MSG_HALTED));
|
||||
lcd_put_u8str(x, y++, GET_TEXT_F(MSG_HALTED));
|
||||
#endif
|
||||
lcd_put_u8str_P(0, y, GET_TEXT(MSG_PLEASE_RESET));
|
||||
lcd_put_u8str(x, y, GET_TEXT_F(MSG_PLEASE_RESET));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -508,13 +511,13 @@ 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_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
|
||||
lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" "));
|
||||
else
|
||||
lcd_put_u8str(value);
|
||||
}
|
||||
@@ -529,27 +532,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(' ');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,27 +560,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
|
||||
@@ -586,7 +589,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
|
||||
|
||||
@@ -600,7 +603,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
|
||||
@@ -613,12 +616,12 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
|
||||
|
||||
FORCE_INLINE void _draw_print_progress() {
|
||||
const uint8_t progress = ui.get_progress_percent();
|
||||
lcd_put_u8str_P(PSTR(TERN(SDSUPPORT, "SD", "P:")));
|
||||
lcd_put_u8str(F(TERN(SDSUPPORT, "SD", "P:")));
|
||||
if (progress)
|
||||
lcd_put_u8str(ui8tostr3rj(progress));
|
||||
else
|
||||
lcd_put_u8str_P(PSTR("---"));
|
||||
lcd_put_wchar('%');
|
||||
lcd_put_u8str(F("---"));
|
||||
lcd_put_lchar('%');
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -661,11 +664,11 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
// Alternate Status message and Filament display
|
||||
if (ELAPSED(millis(), next_filament_display)) {
|
||||
lcd_put_u8str_P(PSTR("Dia "));
|
||||
lcd_put_u8str(F("Dia "));
|
||||
lcd_put_u8str(ftostr12ns(filwidth.measured_mm));
|
||||
lcd_put_u8str_P(PSTR(" V"));
|
||||
lcd_put_u8str(F(" V"));
|
||||
lcd_put_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
|
||||
lcd_put_wchar('%');
|
||||
lcd_put_lchar('%');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -684,7 +687,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.
|
||||
@@ -698,11 +701,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
|
||||
}
|
||||
@@ -724,7 +727,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
|
||||
@@ -776,7 +779,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;
|
||||
@@ -785,7 +788,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;
|
||||
@@ -910,7 +913,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);
|
||||
}
|
||||
|
||||
@@ -924,7 +927,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
|
||||
@@ -933,9 +936,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);
|
||||
|
||||
@@ -967,9 +970,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
|
||||
|
||||
@@ -991,7 +994,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 ==========
|
||||
@@ -1006,9 +1009,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 ==========
|
||||
|
||||
@@ -1050,7 +1053,7 @@ void MarlinUI::draw_status_screen() {
|
||||
draw_status_message(blink);
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
#if HAS_MARLINUI_MENU
|
||||
|
||||
#include "../menu/menu.h"
|
||||
|
||||
@@ -1066,70 +1069,74 @@ void MarlinUI::draw_status_screen() {
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
||||
// Draw a static item with no left-right margin required. Centered by default.
|
||||
void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
int8_t n = LCD_WIDTH;
|
||||
lcd_moveto(0, row);
|
||||
const int8_t plen = pstr ? utf8_strlen_P(pstr) : 0,
|
||||
const int8_t plen = fstr ? utf8_strlen(fstr) : 0,
|
||||
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_ind_P(pstr, itemIndex, itemString, 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, PGM_P const pstr, const char pre_char, const char post_char) {
|
||||
lcd_put_wchar(0, row, sel ? pre_char : ' ');
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2);
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
lcd_put_wchar(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_lchar(0, row, sel ? pre_char : ' ');
|
||||
uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2);
|
||||
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, PGM_P const pstr, const char * const inStr, const bool pgm) {
|
||||
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] : ' ');
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
|
||||
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) {
|
||||
void MenuEditItemBase::draw_edit_screen(FSTR_P const ftpl, const char * const value/*=nullptr*/) {
|
||||
ui.encoder_direction_normal();
|
||||
uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, itemString, LCD_WIDTH - 1);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// The Select Screen presents a prompt and two "buttons"
|
||||
void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
||||
void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) {
|
||||
ui.draw_select_screen_prompt(pref, string, suff);
|
||||
SETCURSOR(0, LCD_HEIGHT - 1);
|
||||
lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd_put_wchar(yesno ? ' ' : ']');
|
||||
SETCURSOR_RJ(utf8_strlen_P(yes) + 2, LCD_HEIGHT - 1);
|
||||
lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd_put_wchar(yesno ? ']' : ' ');
|
||||
if (no) {
|
||||
SETCURSOR(0, LCD_HEIGHT - 1);
|
||||
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_lchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_lchar(yesno ? ']' : ' ');
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) {
|
||||
lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
|
||||
void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) {
|
||||
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
|
||||
@@ -1247,7 +1254,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) {
|
||||
@@ -1264,7 +1271,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)
|
||||
@@ -1276,9 +1283,9 @@ void MarlinUI::draw_status_screen() {
|
||||
* Show X and Y positions
|
||||
*/
|
||||
_XLABEL(_PLOT_X, 0);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(bedlevel.get_mesh_x(x_plot))));
|
||||
_YLABEL(_LCD_W_POS, 0);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(bedlevel.get_mesh_y(y_plot))));
|
||||
|
||||
lcd_moveto(_PLOT_X, 0);
|
||||
|
||||
@@ -1327,13 +1334,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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1343,8 +1350,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);
|
||||
@@ -1458,11 +1465,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
|
||||
|
||||
@@ -1470,10 +1477,10 @@ void MarlinUI::draw_status_screen() {
|
||||
* Print Z values
|
||||
*/
|
||||
_ZLABEL(_LCD_W_POS, 1);
|
||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
lcd_put_u8str_P(PSTR(" -----"));
|
||||
lcd_put_u8str(F(" -----"));
|
||||
|
||||
#else // 16x4 or 20x4 display
|
||||
|
||||
@@ -1481,18 +1488,18 @@ void MarlinUI::draw_status_screen() {
|
||||
* Show all values at right of screen
|
||||
*/
|
||||
_XLABEL(_LCD_W_POS, 1);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(bedlevel.get_mesh_x(x_plot))));
|
||||
_YLABEL(_LCD_W_POS, 2);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(bedlevel.get_mesh_y(y_plot))));
|
||||
|
||||
/**
|
||||
* Show the location value
|
||||
*/
|
||||
_ZLABEL(_LCD_W_POS, 3);
|
||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
lcd_put_u8str_P(PSTR(" -----"));
|
||||
lcd_put_u8str(F(" -----"));
|
||||
|
||||
#endif // LCD_HEIGHT > 3
|
||||
}
|
||||
@@ -1583,6 +1590,6 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
#endif // HAS_LCD_MENU
|
||||
#endif // HAS_MARLINUI_MENU
|
||||
|
||||
#endif // HAS_MARLINUI_HD44780
|
||||
|
Reference in New Issue
Block a user