Add print at position shortcuts

This commit is contained in:
Scott Lahteine 2019-08-22 19:36:18 -05:00
parent 5c0e5c599f
commit 7924e0d819
10 changed files with 77 additions and 134 deletions

View File

@ -401,9 +401,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
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) { 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); uint8_t slen = utf8_strlen_P(text);
if (slen < len) { if (slen < len) {
// Fits into, lcd_put_u8str_max_P(col, line, text, len);
lcd_moveto(col, line);
lcd_put_u8str_max_P(text, len);
for (; slen < len; ++slen) lcd_put_wchar(' '); for (; slen < len; ++slen) lcd_put_wchar(' ');
safe_delay(time); safe_delay(time);
} }
@ -412,11 +410,8 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
int dly = time / _MAX(slen, 1); int dly = time / _MAX(slen, 1);
for (uint8_t i = 0; i <= slen; i++) { for (uint8_t i = 0; i <= slen; i++) {
// Go to the correct place // Print the text at the correct place
lcd_moveto(col, line); lcd_put_u8str_max_P(col, line, p, len);
// Print the text
lcd_put_u8str_max_P(p, len);
// Fill with spaces // 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_wchar(' ');
@ -433,9 +428,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
static void logo_lines(PGM_P const extra) { static void logo_lines(PGM_P const extra) {
int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2; int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2;
lcd_moveto(indent, 0); lcd_put_wchar('\x00'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x01'); lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x01');
lcd_moveto(indent, 1); lcd_put_u8str_P(PSTR("|Marlin|")); lcd_put_u8str_P(extra); lcd_put_u8str_P(indent, 1, PSTR("|Marlin|")); lcd_put_u8str_P(extra);
lcd_moveto(indent, 2); lcd_put_wchar('\x02'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x03'); lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x03');
} }
void MarlinUI::show_bootscreen() { void MarlinUI::show_bootscreen() {
@ -447,8 +442,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
#define CENTER_OR_SCROLL(STRING,DELAY) \ #define CENTER_OR_SCROLL(STRING,DELAY) \
lcd_erase_line(3); \ lcd_erase_line(3); \
if (utf8_strlen(STRING) <= LCD_WIDTH) { \ if (utf8_strlen(STRING) <= LCD_WIDTH) { \
lcd_moveto((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3); \ lcd_put_u8str_P((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3, PSTR(STRING)); \
lcd_put_u8str_P(PSTR(STRING)); \
safe_delay(DELAY); \ safe_delay(DELAY); \
} \ } \
else { \ else { \
@ -518,16 +512,12 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
#endif // SHOW_BOOTSCREEN #endif // SHOW_BOOTSCREEN
void MarlinUI::draw_kill_screen() { void MarlinUI::draw_kill_screen() {
lcd_moveto(0, 0); lcd_put_u8str(0, 0, status_message);
lcd_put_u8str(status_message); lcd_uint_t y = 2;
#if LCD_HEIGHT < 4 #if LCD_HEIGHT >= 4
lcd_moveto(0, 2); lcd_put_u8str_P(0, y++, PSTR(MSG_HALTED));
#else
lcd_moveto(0, 2);
lcd_put_u8str_P(PSTR(MSG_HALTED));
lcd_moveto(0, 3);
#endif #endif
lcd_put_u8str_P(PSTR(MSG_PLEASE_RESET)); lcd_put_u8str_P(0, y, PSTR(MSG_PLEASE_RESET));
} }
// //
@ -886,8 +876,7 @@ void MarlinUI::draw_status_screen() {
#if LCD_HEIGHT > 3 #if LCD_HEIGHT > 3
lcd_moveto(0, 2); lcd_put_wchar(0, 2, LCD_STR_FEEDRATE[0]);
lcd_put_wchar(LCD_STR_FEEDRATE[0]);
lcd_put_u8str(i16tostr3(feedrate_percentage)); lcd_put_u8str(i16tostr3(feedrate_percentage));
lcd_put_wchar('%'); lcd_put_wchar('%');
@ -895,8 +884,7 @@ void MarlinUI::draw_status_screen() {
duration_t elapsed = print_job_timer.duration(); duration_t elapsed = print_job_timer.duration();
const uint8_t len = elapsed.toDigital(buffer), const uint8_t len = elapsed.toDigital(buffer),
timepos = LCD_WIDTH - len - 1; timepos = LCD_WIDTH - len - 1;
lcd_moveto(timepos, 2); lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]);
lcd_put_wchar(LCD_STR_CLOCK[0]);
lcd_put_u8str(buffer); lcd_put_u8str(buffer);
#if LCD_WIDTH >= 20 #if LCD_WIDTH >= 20
@ -945,8 +933,7 @@ void MarlinUI::draw_status_screen() {
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink); _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink);
#if HAS_LEVELING && (HOTENDS > 1 || !HAS_HEATED_BED) #if HAS_LEVELING && (HOTENDS > 1 || !HAS_HEATED_BED)
lcd_moveto(LCD_WIDTH - 1, 0); lcd_put_wchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' ');
lcd_put_wchar(planner.leveling_active || blink ? '_' : ' ');
#endif #endif
// ========== Line 2 ========== // ========== Line 2 ==========
@ -961,8 +948,7 @@ void MarlinUI::draw_status_screen() {
_draw_bed_status(blink); _draw_bed_status(blink);
#endif #endif
lcd_moveto(LCD_WIDTH - 9, 1); lcd_put_wchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]);
lcd_put_wchar(LCD_STR_FEEDRATE[0]);
lcd_put_u8str(i16tostr3(feedrate_percentage)); lcd_put_u8str(i16tostr3(feedrate_percentage));
lcd_put_wchar('%'); lcd_put_wchar('%');
@ -1033,8 +1019,7 @@ void MarlinUI::draw_status_screen() {
void draw_menu_item(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) { void draw_menu_item(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
uint8_t n = LCD_WIDTH - 2; uint8_t n = LCD_WIDTH - 2;
lcd_moveto(0, row); lcd_put_wchar(0, row, sel ? pre_char : ' ');
lcd_put_wchar(sel ? pre_char : ' ');
n -= lcd_put_u8str_max_P(pstr, n); n -= lcd_put_u8str_max_P(pstr, n);
for (; n; --n) lcd_put_wchar(' '); for (; n; --n) lcd_put_wchar(' ');
lcd_put_wchar(post_char); lcd_put_wchar(post_char);
@ -1042,8 +1027,7 @@ void MarlinUI::draw_status_screen() {
void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) { void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
uint8_t n = LCD_WIDTH - 2 - (pgm ? utf8_strlen_P(data) : utf8_strlen(data)); uint8_t n = LCD_WIDTH - 2 - (pgm ? utf8_strlen_P(data) : utf8_strlen(data));
lcd_moveto(0, row); lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
lcd_put_wchar(sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
n -= lcd_put_u8str_max_P(pstr, n); n -= lcd_put_u8str_max_P(pstr, n);
lcd_put_wchar(':'); lcd_put_wchar(':');
for (; n; --n) lcd_put_wchar(' '); for (; n; --n) lcd_put_wchar(' ');
@ -1053,14 +1037,12 @@ void MarlinUI::draw_status_screen() {
void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
ui.encoder_direction_normal(); ui.encoder_direction_normal();
lcd_moveto(0, 1); lcd_put_u8str_P(0, 1, pstr);
lcd_put_u8str_P(pstr);
if (value != nullptr) { if (value != nullptr) {
lcd_put_wchar(':'); lcd_put_wchar(':');
int len = utf8_strlen(value); int len = utf8_strlen(value);
const lcd_uint_t valrow = (utf8_strlen_P(pstr) + 1 + len + 1) > (LCD_WIDTH - 2) ? 2 : 1; // Value on the next row if it won't fit const lcd_uint_t valrow = (utf8_strlen_P(pstr) + 1 + len + 1) > (LCD_WIDTH - 2) ? 2 : 1; // Value on the next row if it won't fit
lcd_moveto((LCD_WIDTH - 1) - (len + 1), valrow); // Right-justified, padded by spaces lcd_put_wchar((LCD_WIDTH - 1) - (len + 1), valrow, ' '); // Right-justified, padded, add a leading space
lcd_put_wchar(' '); // Overwrite char if value gets shorter
lcd_put_u8str(value); lcd_put_u8str(value);
} }
} }
@ -1078,8 +1060,7 @@ void MarlinUI::draw_status_screen() {
void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) { void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
UNUSED(pstr); UNUSED(pstr);
lcd_moveto(0, row); lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
lcd_put_wchar(sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
constexpr uint8_t maxlen = LCD_WIDTH - 2; constexpr uint8_t maxlen = LCD_WIDTH - 2;
uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
for (; n; --n) lcd_put_wchar(' '); for (; n; --n) lcd_put_wchar(' ');
@ -1206,8 +1187,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) { 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); add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
lcd.createChar(c, (uint8_t*)&chrdata); lcd.createChar(c, (uint8_t*)&chrdata);
lcd_moveto(x, y); lcd_put_wchar(x, y, c);
lcd_put_wchar(c);
} }
void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
@ -1216,7 +1196,7 @@ void MarlinUI::draw_status_screen() {
#define _LCD_W_POS 12 #define _LCD_W_POS 12
#define _PLOT_X 1 #define _PLOT_X 1
#define _MAP_X 3 #define _MAP_X 3
#define _LABEL(C,X,Y) lcd_moveto(X, Y); lcd_put_u8str(C) #define _LABEL(C,X,Y) lcd_put_u8str(X, Y, C)
#define _XLABEL(X,Y) _LABEL("X:",X,Y) #define _XLABEL(X,Y) _LABEL("X:",X,Y)
#define _YLABEL(X,Y) _LABEL("Y:",X,Y) #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
#define _ZLABEL(X,Y) _LABEL("Z:",X,Y) #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
@ -1224,7 +1204,7 @@ void MarlinUI::draw_status_screen() {
#define _LCD_W_POS 8 #define _LCD_W_POS 8
#define _PLOT_X 0 #define _PLOT_X 0
#define _MAP_X 1 #define _MAP_X 1
#define _LABEL(X,Y,C) lcd_moveto(X, Y); lcd_put_wchar(C) #define _LABEL(X,Y,C) lcd_put_wchar(X, Y, C)
#define _XLABEL(X,Y) _LABEL('X',X,Y) #define _XLABEL(X,Y) _LABEL('X',X,Y)
#define _YLABEL(X,Y) _LABEL('Y',X,Y) #define _YLABEL(X,Y) _LABEL('Y',X,Y)
#define _ZLABEL(X,Y) _LABEL('Z',X,Y) #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
@ -1288,17 +1268,13 @@ void MarlinUI::draw_status_screen() {
n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1; n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1;
for (i = 0; i < n_cols; i++) { for (i = 0; i < n_cols; i++) {
lcd_moveto(i, 0); lcd_put_wchar(i, 0, CHAR_LINE_TOP); // Box Top line
lcd_put_wchar(CHAR_LINE_TOP); // Box Top line lcd_put_wchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line
lcd_moveto(i, n_rows - 1);
lcd_put_wchar(CHAR_LINE_BOT); // Box Bottom line
} }
for (j = 0; j < n_rows; j++) { for (j = 0; j < n_rows; j++) {
lcd_moveto(0, j); lcd_put_wchar(0, j, CHAR_EDGE_L); // Box Left edge
lcd_put_wchar(CHAR_EDGE_L); // Box Left edge lcd_put_wchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge
lcd_moveto(n_cols - 1, j);
lcd_put_wchar(CHAR_EDGE_R); // Box Right edge
} }
/** /**
@ -1308,10 +1284,8 @@ void MarlinUI::draw_status_screen() {
k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2; k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2;
l = (HD44780_CHAR_HEIGHT) * n_rows; l = (HD44780_CHAR_HEIGHT) * n_rows;
if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) { if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) {
lcd_moveto(0, n_rows - 1); // Box Left edge lcd_put_wchar(0, n_rows - 1, ' '); // Box Left edge
lcd_put_wchar(' '); lcd_put_wchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge
lcd_moveto(n_cols - 1, n_rows - 1); // Box Right edge
lcd_put_wchar(' ');
} }
clear_custom_char(&new_char); clear_custom_char(&new_char);
@ -1425,8 +1399,7 @@ void MarlinUI::draw_status_screen() {
/** /**
* Print plot position * Print plot position
*/ */
lcd_moveto(_LCD_W_POS, 0); lcd_put_wchar(_LCD_W_POS, 0, '(');
lcd_put_wchar('(');
lcd_put_u8str(ui8tostr3(x_plot)); lcd_put_u8str(ui8tostr3(x_plot));
lcd_put_wchar(','); lcd_put_wchar(',');
lcd_put_u8str(ui8tostr3(y_plot)); lcd_put_u8str(ui8tostr3(y_plot));

View File

@ -100,8 +100,7 @@
FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) { FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
const char *str = i16tostr3(temp); const char *str = i16tostr3(temp);
const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
lcd_moveto(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty); lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
lcd_put_u8str(&str[3-len]);
lcd_put_wchar(LCD_STR_DEGREE[0]); lcd_put_wchar(LCD_STR_DEGREE[0]);
} }
@ -264,8 +263,7 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
// //
FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) { FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
const uint8_t offs = (XYZ_SPACING) * axis; const uint8_t offs = (XYZ_SPACING) * axis;
lcd_moveto(X_LABEL_POS + offs, XYZ_BASELINE); lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, 'X' + axis);
lcd_put_wchar('X' + axis);
lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE); lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
if (blink) if (blink)
lcd_put_u8str(value); lcd_put_u8str(value);
@ -429,8 +427,7 @@ void MarlinUI::draw_status_screen() {
c = '*'; c = '*';
} }
#endif #endif
lcd_moveto(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y); lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3(thermalManager.fanPercent(spd)));
lcd_put_u8str(i16tostr3(thermalManager.fanPercent(spd)));
lcd_put_wchar(c); lcd_put_wchar(c);
} }
} }
@ -488,8 +485,7 @@ void MarlinUI::draw_status_screen() {
#if ENABLED(DOGM_SD_PERCENT) #if ENABLED(DOGM_SD_PERCENT)
if (PAGE_CONTAINS(41, 48)) { if (PAGE_CONTAINS(41, 48)) {
// Percent complete // Percent complete
lcd_moveto(55, 48); lcd_put_u8str(55, 48, ui8tostr3(progress));
lcd_put_u8str(ui8tostr3(progress));
lcd_put_wchar('%'); lcd_put_wchar('%');
} }
#endif #endif
@ -510,8 +506,7 @@ void MarlinUI::draw_status_screen() {
duration_t elapsed = print_job_timer.duration(); duration_t elapsed = print_job_timer.duration();
bool has_days = (elapsed.value >= 60*60*24L); bool has_days = (elapsed.value >= 60*60*24L);
uint8_t len = elapsed.toDigital(buffer, has_days); uint8_t len = elapsed.toDigital(buffer, has_days);
lcd_moveto(SD_DURATION_X, EXTRAS_BASELINE); lcd_put_u8str(SD_DURATION_X, EXTRAS_BASELINE, buffer);
lcd_put_u8str(buffer);
} }
#endif // HAS_PRINT_PROGRESS #endif // HAS_PRINT_PROGRESS
@ -546,8 +541,6 @@ void MarlinUI::draw_status_screen() {
// Two-component mix / gradient instead of XY // Two-component mix / gradient instead of XY
lcd_moveto(X_LABEL_POS, XYZ_BASELINE);
char mixer_messages[12]; char mixer_messages[12];
const char *mix_label; const char *mix_label;
#if ENABLED(GRADIENT_MIX) #if ENABLED(GRADIENT_MIX)
@ -562,7 +555,7 @@ void MarlinUI::draw_status_screen() {
mix_label = "Mx"; mix_label = "Mx";
} }
sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1])); sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(mixer_messages); lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
#else #else
@ -587,28 +580,22 @@ void MarlinUI::draw_status_screen() {
if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) { if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
set_font(FONT_MENU); set_font(FONT_MENU);
lcd_moveto(3, EXTRAS_2_BASELINE); lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);
lcd_put_wchar(LCD_STR_FEEDRATE[0]);
set_font(FONT_STATUSMENU); set_font(FONT_STATUSMENU);
lcd_moveto(12, EXTRAS_2_BASELINE); lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3(feedrate_percentage));
lcd_put_u8str(i16tostr3(feedrate_percentage));
lcd_put_wchar('%'); lcd_put_wchar('%');
// //
// Filament sensor display if SD is disabled // Filament sensor display if SD is disabled
// //
#if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT) #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
lcd_moveto(56, EXTRAS_2_BASELINE); lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring);
lcd_put_u8str(wstring); lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
lcd_moveto(102, EXTRAS_2_BASELINE);
lcd_put_u8str(mstring);
lcd_put_wchar('%'); lcd_put_wchar('%');
set_font(FONT_MENU); set_font(FONT_MENU);
lcd_moveto(47, EXTRAS_2_BASELINE); lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA)); lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
lcd_moveto(93, EXTRAS_2_BASELINE);
lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
#endif #endif
} }

View File

@ -201,13 +201,11 @@ bool MarlinUI::detected() { return true; }
auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) { auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap); u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
set_font(FONT_MENU); set_font(FONT_MENU);
const u8g_pgm_uint8_t splash1[] U8G_PROGMEM = STRING_SPLASH_LINE1;
#ifndef STRING_SPLASH_LINE2 #ifndef STRING_SPLASH_LINE2
u8g.drawStrP(txt_offx_1, txt_base, splash1); lcd_put_u8str_P(txt_offx_1, txt_base, PSTR(STRING_SPLASH_LINE1));
#else #else
const u8g_pgm_uint8_t splash2[] U8G_PROGMEM = STRING_SPLASH_LINE2; lcd_put_u8str_P(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), PSTR(STRING_SPLASH_LINE1));
u8g.drawStrP(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), splash1); lcd_put_u8str_P(txt_offx_2, txt_base, PSTR(STRING_SPLASH_LINE2));
u8g.drawStrP(txt_offx_2, txt_base, splash2);
#endif #endif
}; };
@ -306,12 +304,9 @@ void MarlinUI::draw_kill_screen() {
u8g.firstPage(); u8g.firstPage();
do { do {
set_font(FONT_MENU); set_font(FONT_MENU);
lcd_moveto(0, h4 * 1); lcd_put_u8str(0, h4 * 1, status_message);
lcd_put_u8str(status_message); lcd_put_u8str_P(0, h4 * 2, PSTR(MSG_HALTED));
lcd_moveto(0, h4 * 2); lcd_put_u8str_P(0, h4 * 3, PSTR(MSG_PLEASE_RESET));
lcd_put_u8str_P(PSTR(MSG_HALTED));
lcd_moveto(0, h4 * 3);
lcd_put_u8str_P(PSTR(MSG_PLEASE_RESET));
} while (u8g.nextPage()); } while (u8g.nextPage());
} }
@ -329,8 +324,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return; if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return;
lcd_moveto(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2); lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2, 'E');
lcd_put_wchar('E');
lcd_put_wchar((char)('1' + extruder)); lcd_put_wchar((char)('1' + extruder));
lcd_put_wchar(' '); lcd_put_wchar(' ');
lcd_put_u8str(i16tostr3(thermalManager.degHotend(extruder))); lcd_put_u8str(i16tostr3(thermalManager.degHotend(extruder)));
@ -396,8 +390,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH); u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
n -= lcd_put_u8str_max_P(pstr, n); n -= lcd_put_u8str_max_P(pstr, n);
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2); lcd_put_wchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char);
lcd_put_wchar(post_char);
lcd_put_wchar(' '); lcd_put_wchar(' ');
} }
} }
@ -447,10 +440,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
// Assume the label is alpha-numeric (with a descender) // Assume the label is alpha-numeric (with a descender)
bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT); bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
if (onpage) { if (onpage) lcd_put_u8str_P(0, baseline, pstr);
lcd_moveto(0, baseline);
lcd_put_u8str_P(pstr);
}
// If a value is included, print a colon, then print the value right-justified // If a value is included, print a colon, then print the value right-justified
if (value != nullptr) { if (value != nullptr) {
@ -461,8 +451,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline); onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
} }
if (onpage) { if (onpage) {
lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces lcd_put_wchar(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space
lcd_put_wchar(' '); // overwrite char if value gets shorter
lcd_put_u8str(value); lcd_put_u8str(value);
} }
} }
@ -476,8 +465,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1); u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
u8g.setColorIndex(0); u8g.setColorIndex(0);
} }
lcd_moveto(bx, by); lcd_put_u8str_P(bx, by, pstr);
lcd_put_u8str_P(pstr);
if (inv) u8g.setColorIndex(1); if (inv) u8g.setColorIndex(1);
} }
@ -562,26 +550,22 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
// Show X and Y positions at top of screen // Show X and Y positions at top of screen
u8g.setColorIndex(1); u8g.setColorIndex(1);
if (PAGE_UNDER(7)) { if (PAGE_UNDER(7)) {
lcd_moveto(5, 7); lcd_put_u8str(5, 7, "X:");
lcd_put_u8str("X:");
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot])))); lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
lcd_moveto(74, 7); lcd_put_u8str(74, 7, "Y:");
lcd_put_u8str("Y:");
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot])))); lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
} }
// Print plot position // Print plot position
if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) { if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) {
lcd_moveto(5, LCD_PIXEL_HEIGHT); lcd_put_wchar(5, LCD_PIXEL_HEIGHT, '(');
lcd_put_wchar('(');
u8g.print(x_plot); u8g.print(x_plot);
lcd_put_wchar(','); lcd_put_wchar(',');
u8g.print(y_plot); u8g.print(y_plot);
lcd_put_wchar(')'); lcd_put_wchar(')');
// Show the location value // Show the location value
lcd_moveto(74, LCD_PIXEL_HEIGHT); lcd_put_u8str(74, LCD_PIXEL_HEIGHT, "Z:");
lcd_put_u8str("Z:");
if (!isnan(ubl.z_values[x_plot][y_plot])) if (!isnan(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else else

View File

@ -38,6 +38,11 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length);
*/ */
int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length); int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
/**
* Set the print baseline position
*/
void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row);
/** /**
* @brief Draw a ROM UTF-8 string * @brief Draw a ROM UTF-8 string
* *
@ -49,13 +54,19 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
* Draw a ROM UTF-8 string * Draw a ROM UTF-8 string
*/ */
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length); int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
inline int lcd_put_u8str_max_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P utf8_str_P, pixel_len_t max_length) {
void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row); lcd_moveto(col, row);
return lcd_put_u8str_max_P(utf8_str_P, max_length);
}
void lcd_put_int(const int i); void lcd_put_int(const int i);
inline void lcd_put_int(const lcd_uint_t col, const lcd_uint_t row, const int i) { lcd_moveto(col, row); lcd_put_int(i); }
inline int lcd_put_u8str_P(PGM_P str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); } inline int lcd_put_u8str_P(PGM_P str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); }
inline int lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P str) { lcd_moveto(col, row); return lcd_put_u8str_P(str); }
inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); } inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }
inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, PGM_P str) { lcd_moveto(col, row); return lcd_put_u8str(str); }
inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); } inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) { lcd_moveto(col, row); return lcd_put_wchar(c); }

View File

@ -180,8 +180,7 @@ void BrickoutGame::game_screen() {
// Score Digits // Score Digits
//const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2; //const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
constexpr uint8_t sx = 0; constexpr uint8_t sx = 0;
lcd_moveto(sx, MENU_FONT_ASCENT - 1); lcd_put_int(sx, MENU_FONT_ASCENT - 1, score);
lcd_put_int(score);
// Balls Left // Balls Left
lcd_moveto(LCD_PIXEL_WIDTH - MENU_FONT_WIDTH * 3, MENU_FONT_ASCENT - 1); lcd_moveto(LCD_PIXEL_WIDTH - MENU_FONT_WIDTH * 3, MENU_FONT_ASCENT - 1);

View File

@ -48,10 +48,7 @@ void MarlinGame::draw_game_over() {
u8g.setColorIndex(0); u8g.setColorIndex(0);
u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2); u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2);
u8g.setColorIndex(1); u8g.setColorIndex(1);
if (ui.get_blink()) { if (ui.get_blink()) lcd_put_u8str_P(lx, ly, PSTR("GAME OVER"));
lcd_moveto(lx, ly);
lcd_put_u8str_P(PSTR("GAME OVER"));
}
} }
} }

View File

@ -416,8 +416,7 @@ void InvadersGame::game_screen() {
// Draw Score // Draw Score
//const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2; //const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
constexpr uint8_t sx = 0; constexpr uint8_t sx = 0;
lcd_moveto(sx, MENU_FONT_ASCENT - 1); lcd_put_int(sx, MENU_FONT_ASCENT - 1, score);
lcd_put_int(score);
// Draw lives // Draw lives
if (idat.cannons_left) if (idat.cannons_left)

View File

@ -80,10 +80,7 @@ void MazeGame::game_screen() {
u8g.setColorIndex(1); u8g.setColorIndex(1);
// Draw Score // Draw Score
if (PAGE_UNDER(HEADER_H)) { if (PAGE_UNDER(HEADER_H)) lcd_put_int(0, HEADER_H - 1, score);
lcd_moveto(0, HEADER_H - 1);
lcd_put_int(score);
}
// Draw the maze // Draw the maze
// for (uint8_t n = 0; n < head_ind; ++n) { // for (uint8_t n = 0; n < head_ind; ++n) {

View File

@ -231,10 +231,7 @@ void SnakeGame::game_screen() {
u8g.setColorIndex(1); u8g.setColorIndex(1);
// Draw Score // Draw Score
if (PAGE_UNDER(HEADER_H)) { if (PAGE_UNDER(HEADER_H)) lcd_put_int(0, HEADER_H - 1, score);
lcd_moveto(0, HEADER_H - 1);
lcd_put_int(score);
}
// DRAW THE PLAYFIELD BORDER // DRAW THE PLAYFIELD BORDER
u8g.drawFrame(BOARD_L - 2, BOARD_T - 2, BOARD_R - BOARD_L + 4, BOARD_B - BOARD_T + 4); u8g.drawFrame(BOARD_L - 2, BOARD_T - 2, BOARD_R - BOARD_L + 4, BOARD_B - BOARD_T + 4);

View File

@ -76,8 +76,7 @@ static void lcd_factory_settings() {
LIMIT(bar_percent, 0, 100); LIMIT(bar_percent, 0, 100);
ui.encoderPosition = 0; ui.encoderPosition = 0;
draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true); draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
lcd_moveto((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2); lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_wchar('%');
lcd_put_int(bar_percent); lcd_put_wchar('%');
lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent); lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent);
} }