Browse Source

Add print at position shortcuts

Scott Lahteine 6 years ago
parent
commit
7924e0d819

+ 31
- 58
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp View File

@@ -401,9 +401,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
401 401
   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) {
402 402
     uint8_t slen = utf8_strlen_P(text);
403 403
     if (slen < len) {
404
-      // Fits into,
405
-      lcd_moveto(col, line);
406
-      lcd_put_u8str_max_P(text, len);
404
+      lcd_put_u8str_max_P(col, line, text, len);
407 405
       for (; slen < len; ++slen) lcd_put_wchar(' ');
408 406
       safe_delay(time);
409 407
     }
@@ -412,11 +410,8 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
412 410
       int dly = time / _MAX(slen, 1);
413 411
       for (uint8_t i = 0; i <= slen; i++) {
414 412
 
415
-        // Go to the correct place
416
-        lcd_moveto(col, line);
417
-
418
-        // Print the text
419
-        lcd_put_u8str_max_P(p, len);
413
+        // Print the text at the correct place
414
+        lcd_put_u8str_max_P(col, line, p, len);
420 415
 
421 416
         // Fill with spaces
422 417
         for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_wchar(' ');
@@ -433,9 +428,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
433 428
 
434 429
   static void logo_lines(PGM_P const extra) {
435 430
     int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2;
436
-    lcd_moveto(indent, 0); lcd_put_wchar('\x00'); lcd_put_u8str_P(PSTR( "------" ));  lcd_put_wchar('\x01');
437
-    lcd_moveto(indent, 1);                        lcd_put_u8str_P(PSTR("|Marlin|"));  lcd_put_u8str_P(extra);
438
-    lcd_moveto(indent, 2); lcd_put_wchar('\x02'); lcd_put_u8str_P(PSTR( "------" ));  lcd_put_wchar('\x03');
431
+    lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str_P(PSTR( "------" ));  lcd_put_wchar('\x01');
432
+    lcd_put_u8str_P(indent, 1, PSTR("|Marlin|"));  lcd_put_u8str_P(extra);
433
+    lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str_P(PSTR( "------" ));  lcd_put_wchar('\x03');
439 434
   }
440 435
 
441 436
   void MarlinUI::show_bootscreen() {
@@ -447,8 +442,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
447 442
     #define CENTER_OR_SCROLL(STRING,DELAY) \
448 443
       lcd_erase_line(3); \
449 444
       if (utf8_strlen(STRING) <= LCD_WIDTH) { \
450
-        lcd_moveto((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3); \
451
-        lcd_put_u8str_P(PSTR(STRING)); \
445
+        lcd_put_u8str_P((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3, PSTR(STRING)); \
452 446
         safe_delay(DELAY); \
453 447
       } \
454 448
       else { \
@@ -518,16 +512,12 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
518 512
 #endif // SHOW_BOOTSCREEN
519 513
 
520 514
 void MarlinUI::draw_kill_screen() {
521
-  lcd_moveto(0, 0);
522
-  lcd_put_u8str(status_message);
523
-  #if LCD_HEIGHT < 4
524
-    lcd_moveto(0, 2);
525
-  #else
526
-    lcd_moveto(0, 2);
527
-    lcd_put_u8str_P(PSTR(MSG_HALTED));
528
-    lcd_moveto(0, 3);
515
+  lcd_put_u8str(0, 0, status_message);
516
+  lcd_uint_t y = 2;
517
+  #if LCD_HEIGHT >= 4
518
+    lcd_put_u8str_P(0, y++, PSTR(MSG_HALTED));
529 519
   #endif
530
-  lcd_put_u8str_P(PSTR(MSG_PLEASE_RESET));
520
+  lcd_put_u8str_P(0, y, PSTR(MSG_PLEASE_RESET));
531 521
 }
532 522
 
533 523
 //
@@ -886,8 +876,7 @@ void MarlinUI::draw_status_screen() {
886 876
 
887 877
     #if LCD_HEIGHT > 3
888 878
 
889
-      lcd_moveto(0, 2);
890
-      lcd_put_wchar(LCD_STR_FEEDRATE[0]);
879
+      lcd_put_wchar(0, 2, LCD_STR_FEEDRATE[0]);
891 880
       lcd_put_u8str(i16tostr3(feedrate_percentage));
892 881
       lcd_put_wchar('%');
893 882
 
@@ -895,8 +884,7 @@ void MarlinUI::draw_status_screen() {
895 884
       duration_t elapsed = print_job_timer.duration();
896 885
       const uint8_t len = elapsed.toDigital(buffer),
897 886
                     timepos = LCD_WIDTH - len - 1;
898
-      lcd_moveto(timepos, 2);
899
-      lcd_put_wchar(LCD_STR_CLOCK[0]);
887
+      lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]);
900 888
       lcd_put_u8str(buffer);
901 889
 
902 890
       #if LCD_WIDTH >= 20
@@ -945,8 +933,7 @@ void MarlinUI::draw_status_screen() {
945 933
     _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink);
946 934
 
947 935
     #if HAS_LEVELING && (HOTENDS > 1 || !HAS_HEATED_BED)
948
-      lcd_moveto(LCD_WIDTH - 1, 0);
949
-      lcd_put_wchar(planner.leveling_active || blink ? '_' : ' ');
936
+      lcd_put_wchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' ');
950 937
     #endif
951 938
 
952 939
     // ========== Line 2 ==========
@@ -961,8 +948,7 @@ void MarlinUI::draw_status_screen() {
961 948
       _draw_bed_status(blink);
962 949
     #endif
963 950
 
964
-    lcd_moveto(LCD_WIDTH - 9, 1);
965
-    lcd_put_wchar(LCD_STR_FEEDRATE[0]);
951
+    lcd_put_wchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]);
966 952
     lcd_put_u8str(i16tostr3(feedrate_percentage));
967 953
     lcd_put_wchar('%');
968 954
 
@@ -1033,8 +1019,7 @@ void MarlinUI::draw_status_screen() {
1033 1019
 
1034 1020
   void draw_menu_item(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
1035 1021
     uint8_t n = LCD_WIDTH - 2;
1036
-    lcd_moveto(0, row);
1037
-    lcd_put_wchar(sel ? pre_char : ' ');
1022
+    lcd_put_wchar(0, row, sel ? pre_char : ' ');
1038 1023
     n -= lcd_put_u8str_max_P(pstr, n);
1039 1024
     for (; n; --n) lcd_put_wchar(' ');
1040 1025
     lcd_put_wchar(post_char);
@@ -1042,8 +1027,7 @@ void MarlinUI::draw_status_screen() {
1042 1027
 
1043 1028
   void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
1044 1029
     uint8_t n = LCD_WIDTH - 2 - (pgm ? utf8_strlen_P(data) : utf8_strlen(data));
1045
-    lcd_moveto(0, row);
1046
-    lcd_put_wchar(sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
1030
+    lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
1047 1031
     n -= lcd_put_u8str_max_P(pstr, n);
1048 1032
     lcd_put_wchar(':');
1049 1033
     for (; n; --n) lcd_put_wchar(' ');
@@ -1053,14 +1037,12 @@ void MarlinUI::draw_status_screen() {
1053 1037
   void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
1054 1038
     ui.encoder_direction_normal();
1055 1039
 
1056
-    lcd_moveto(0, 1);
1057
-    lcd_put_u8str_P(pstr);
1040
+    lcd_put_u8str_P(0, 1, pstr);
1058 1041
     if (value != nullptr) {
1059 1042
       lcd_put_wchar(':');
1060 1043
       int len = utf8_strlen(value);
1061 1044
       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
1062
-      lcd_moveto((LCD_WIDTH - 1) - (len + 1), valrow);                                           // Right-justified, padded by spaces
1063
-      lcd_put_wchar(' ');                                                                        // Overwrite char if value gets shorter
1045
+      lcd_put_wchar((LCD_WIDTH - 1) - (len + 1), valrow, ' ');                                   // Right-justified, padded, add a leading space
1064 1046
       lcd_put_u8str(value);
1065 1047
     }
1066 1048
   }
@@ -1078,8 +1060,7 @@ void MarlinUI::draw_status_screen() {
1078 1060
     void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
1079 1061
       UNUSED(pstr);
1080 1062
 
1081
-      lcd_moveto(0, row);
1082
-      lcd_put_wchar(sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
1063
+      lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
1083 1064
       constexpr uint8_t maxlen = LCD_WIDTH - 2;
1084 1065
       uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
1085 1066
       for (; n; --n) lcd_put_wchar(' ');
@@ -1206,8 +1187,7 @@ void MarlinUI::draw_status_screen() {
1206 1187
     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) {
1207 1188
       add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
1208 1189
       lcd.createChar(c, (uint8_t*)&chrdata);
1209
-      lcd_moveto(x, y);
1210
-      lcd_put_wchar(c);
1190
+      lcd_put_wchar(x, y, c);
1211 1191
     }
1212 1192
 
1213 1193
     void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
@@ -1216,7 +1196,7 @@ void MarlinUI::draw_status_screen() {
1216 1196
         #define _LCD_W_POS 12
1217 1197
         #define _PLOT_X 1
1218 1198
         #define _MAP_X 3
1219
-        #define _LABEL(C,X,Y) lcd_moveto(X, Y); lcd_put_u8str(C)
1199
+        #define _LABEL(C,X,Y) lcd_put_u8str(X, Y, C)
1220 1200
         #define _XLABEL(X,Y) _LABEL("X:",X,Y)
1221 1201
         #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
1222 1202
         #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
@@ -1224,7 +1204,7 @@ void MarlinUI::draw_status_screen() {
1224 1204
         #define _LCD_W_POS 8
1225 1205
         #define _PLOT_X 0
1226 1206
         #define _MAP_X 1
1227
-        #define _LABEL(X,Y,C) lcd_moveto(X, Y); lcd_put_wchar(C)
1207
+        #define _LABEL(X,Y,C) lcd_put_wchar(X, Y, C)
1228 1208
         #define _XLABEL(X,Y) _LABEL('X',X,Y)
1229 1209
         #define _YLABEL(X,Y) _LABEL('Y',X,Y)
1230 1210
         #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
@@ -1288,17 +1268,13 @@ void MarlinUI::draw_status_screen() {
1288 1268
         n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1;
1289 1269
 
1290 1270
         for (i = 0; i < n_cols; i++) {
1291
-          lcd_moveto(i, 0);
1292
-          lcd_put_wchar(CHAR_LINE_TOP);                                     // Box Top line
1293
-          lcd_moveto(i, n_rows - 1);
1294
-          lcd_put_wchar(CHAR_LINE_BOT);                                     // Box Bottom line
1271
+          lcd_put_wchar(i, 0, CHAR_LINE_TOP);                               // Box Top line
1272
+          lcd_put_wchar(i, n_rows - 1, CHAR_LINE_BOT);                      // Box Bottom line
1295 1273
         }
1296 1274
 
1297 1275
         for (j = 0; j < n_rows; j++) {
1298
-          lcd_moveto(0, j);
1299
-          lcd_put_wchar(CHAR_EDGE_L);                                       // Box Left edge
1300
-          lcd_moveto(n_cols - 1, j);
1301
-          lcd_put_wchar(CHAR_EDGE_R);                                       // Box Right edge
1276
+          lcd_put_wchar(0, j, CHAR_EDGE_L);                                 // Box Left edge
1277
+          lcd_put_wchar(n_cols - 1, j, CHAR_EDGE_R);                        // Box Right edge
1302 1278
         }
1303 1279
 
1304 1280
         /**
@@ -1308,10 +1284,8 @@ void MarlinUI::draw_status_screen() {
1308 1284
         k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2;
1309 1285
         l = (HD44780_CHAR_HEIGHT) * n_rows;
1310 1286
         if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) {
1311
-          lcd_moveto(0, n_rows - 1);                                        // Box Left edge
1312
-          lcd_put_wchar(' ');
1313
-          lcd_moveto(n_cols - 1, n_rows - 1);                               // Box Right edge
1314
-          lcd_put_wchar(' ');
1287
+          lcd_put_wchar(0, n_rows - 1, ' ');                                // Box Left edge
1288
+          lcd_put_wchar(n_cols - 1, n_rows - 1, ' ');                       // Box Right edge
1315 1289
         }
1316 1290
 
1317 1291
         clear_custom_char(&new_char);
@@ -1425,8 +1399,7 @@ void MarlinUI::draw_status_screen() {
1425 1399
       /**
1426 1400
        * Print plot position
1427 1401
        */
1428
-      lcd_moveto(_LCD_W_POS, 0);
1429
-      lcd_put_wchar('(');
1402
+      lcd_put_wchar(_LCD_W_POS, 0, '(');
1430 1403
       lcd_put_u8str(ui8tostr3(x_plot));
1431 1404
       lcd_put_wchar(',');
1432 1405
       lcd_put_u8str(ui8tostr3(y_plot));

+ 12
- 25
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

@@ -100,8 +100,7 @@
100 100
 FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
101 101
   const char *str = i16tostr3(temp);
102 102
   const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
103
-  lcd_moveto(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty);
104
-  lcd_put_u8str(&str[3-len]);
103
+  lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
105 104
   lcd_put_wchar(LCD_STR_DEGREE[0]);
106 105
 }
107 106
 
@@ -264,8 +263,7 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
264 263
 //
265 264
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
266 265
   const uint8_t offs = (XYZ_SPACING) * axis;
267
-  lcd_moveto(X_LABEL_POS + offs, XYZ_BASELINE);
268
-  lcd_put_wchar('X' + axis);
266
+  lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, 'X' + axis);
269 267
   lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
270 268
   if (blink)
271 269
     lcd_put_u8str(value);
@@ -429,8 +427,7 @@ void MarlinUI::draw_status_screen() {
429 427
               c = '*';
430 428
             }
431 429
           #endif
432
-          lcd_moveto(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y);
433
-          lcd_put_u8str(i16tostr3(thermalManager.fanPercent(spd)));
430
+          lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3(thermalManager.fanPercent(spd)));
434 431
           lcd_put_wchar(c);
435 432
         }
436 433
       }
@@ -488,8 +485,7 @@ void MarlinUI::draw_status_screen() {
488 485
       #if ENABLED(DOGM_SD_PERCENT)
489 486
         if (PAGE_CONTAINS(41, 48)) {
490 487
           // Percent complete
491
-          lcd_moveto(55, 48);
492
-          lcd_put_u8str(ui8tostr3(progress));
488
+          lcd_put_u8str(55, 48, ui8tostr3(progress));
493 489
           lcd_put_wchar('%');
494 490
         }
495 491
       #endif
@@ -510,8 +506,7 @@ void MarlinUI::draw_status_screen() {
510 506
       duration_t elapsed = print_job_timer.duration();
511 507
       bool has_days = (elapsed.value >= 60*60*24L);
512 508
       uint8_t len = elapsed.toDigital(buffer, has_days);
513
-      lcd_moveto(SD_DURATION_X, EXTRAS_BASELINE);
514
-      lcd_put_u8str(buffer);
509
+      lcd_put_u8str(SD_DURATION_X, EXTRAS_BASELINE, buffer);
515 510
     }
516 511
 
517 512
   #endif // HAS_PRINT_PROGRESS
@@ -546,8 +541,6 @@ void MarlinUI::draw_status_screen() {
546 541
 
547 542
         // Two-component mix / gradient instead of XY
548 543
 
549
-        lcd_moveto(X_LABEL_POS, XYZ_BASELINE);
550
-
551 544
         char mixer_messages[12];
552 545
         const char *mix_label;
553 546
         #if ENABLED(GRADIENT_MIX)
@@ -562,7 +555,7 @@ void MarlinUI::draw_status_screen() {
562 555
             mix_label = "Mx";
563 556
           }
564 557
         sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
565
-        lcd_put_u8str(mixer_messages);
558
+        lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
566 559
 
567 560
       #else
568 561
 
@@ -587,28 +580,22 @@ void MarlinUI::draw_status_screen() {
587 580
 
588 581
   if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
589 582
     set_font(FONT_MENU);
590
-    lcd_moveto(3, EXTRAS_2_BASELINE);
591
-    lcd_put_wchar(LCD_STR_FEEDRATE[0]);
583
+    lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);
592 584
 
593 585
     set_font(FONT_STATUSMENU);
594
-    lcd_moveto(12, EXTRAS_2_BASELINE);
595
-    lcd_put_u8str(i16tostr3(feedrate_percentage));
586
+    lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3(feedrate_percentage));
596 587
     lcd_put_wchar('%');
597 588
 
598 589
     //
599 590
     // Filament sensor display if SD is disabled
600 591
     //
601 592
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
602
-      lcd_moveto(56, EXTRAS_2_BASELINE);
603
-      lcd_put_u8str(wstring);
604
-      lcd_moveto(102, EXTRAS_2_BASELINE);
605
-      lcd_put_u8str(mstring);
593
+      lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring);
594
+      lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
606 595
       lcd_put_wchar('%');
607 596
       set_font(FONT_MENU);
608
-      lcd_moveto(47, EXTRAS_2_BASELINE);
609
-      lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
610
-      lcd_moveto(93, EXTRAS_2_BASELINE);
611
-      lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
597
+      lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
598
+      lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
612 599
     #endif
613 600
   }
614 601
 

+ 15
- 31
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp View File

@@ -201,13 +201,11 @@ bool MarlinUI::detected() { return true; }
201 201
     auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
202 202
       u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
203 203
       set_font(FONT_MENU);
204
-      const u8g_pgm_uint8_t splash1[] U8G_PROGMEM  = STRING_SPLASH_LINE1;
205 204
       #ifndef STRING_SPLASH_LINE2
206
-        u8g.drawStrP(txt_offx_1, txt_base, splash1);
205
+        lcd_put_u8str_P(txt_offx_1, txt_base, PSTR(STRING_SPLASH_LINE1));
207 206
       #else
208
-        const u8g_pgm_uint8_t splash2[] U8G_PROGMEM  = STRING_SPLASH_LINE2;
209
-        u8g.drawStrP(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), splash1);
210
-        u8g.drawStrP(txt_offx_2, txt_base, splash2);
207
+        lcd_put_u8str_P(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), PSTR(STRING_SPLASH_LINE1));
208
+        lcd_put_u8str_P(txt_offx_2, txt_base, PSTR(STRING_SPLASH_LINE2));
211 209
       #endif
212 210
     };
213 211
 
@@ -306,12 +304,9 @@ void MarlinUI::draw_kill_screen() {
306 304
   u8g.firstPage();
307 305
   do {
308 306
     set_font(FONT_MENU);
309
-    lcd_moveto(0, h4 * 1);
310
-    lcd_put_u8str(status_message);
311
-    lcd_moveto(0, h4 * 2);
312
-    lcd_put_u8str_P(PSTR(MSG_HALTED));
313
-    lcd_moveto(0, h4 * 3);
314
-    lcd_put_u8str_P(PSTR(MSG_PLEASE_RESET));
307
+    lcd_put_u8str(0, h4 * 1, status_message);
308
+    lcd_put_u8str_P(0, h4 * 2, PSTR(MSG_HALTED));
309
+    lcd_put_u8str_P(0, h4 * 3, PSTR(MSG_PLEASE_RESET));
315 310
   } while (u8g.nextPage());
316 311
 }
317 312
 
@@ -329,8 +324,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
329 324
 
330 325
       if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return;
331 326
 
332
-      lcd_moveto(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2);
333
-      lcd_put_wchar('E');
327
+      lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2, 'E');
334 328
       lcd_put_wchar((char)('1' + extruder));
335 329
       lcd_put_wchar(' ');
336 330
       lcd_put_u8str(i16tostr3(thermalManager.degHotend(extruder)));
@@ -396,8 +390,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
396 390
       u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
397 391
       n -= lcd_put_u8str_max_P(pstr, n);
398 392
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
399
-      lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2);
400
-      lcd_put_wchar(post_char);
393
+      lcd_put_wchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char);
401 394
       lcd_put_wchar(' ');
402 395
     }
403 396
   }
@@ -447,10 +440,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
447 440
 
448 441
     // Assume the label is alpha-numeric (with a descender)
449 442
     bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
450
-    if (onpage) {
451
-      lcd_moveto(0, baseline);
452
-      lcd_put_u8str_P(pstr);
453
-    }
443
+    if (onpage) lcd_put_u8str_P(0, baseline, pstr);
454 444
 
455 445
     // If a value is included, print a colon, then print the value right-justified
456 446
     if (value != nullptr) {
@@ -461,8 +451,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
461 451
         onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
462 452
       }
463 453
       if (onpage) {
464
-        lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
465
-        lcd_put_wchar(' '); // overwrite char if value gets shorter
454
+        lcd_put_wchar(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space
466 455
         lcd_put_u8str(value);
467 456
       }
468 457
     }
@@ -476,8 +465,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
476 465
       u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
477 466
       u8g.setColorIndex(0);
478 467
     }
479
-    lcd_moveto(bx, by);
480
-    lcd_put_u8str_P(pstr);
468
+    lcd_put_u8str_P(bx, by, pstr);
481 469
     if (inv) u8g.setColorIndex(1);
482 470
   }
483 471
 
@@ -562,26 +550,22 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
562 550
       // Show X and Y positions at top of screen
563 551
       u8g.setColorIndex(1);
564 552
       if (PAGE_UNDER(7)) {
565
-        lcd_moveto(5, 7);
566
-        lcd_put_u8str("X:");
553
+        lcd_put_u8str(5, 7, "X:");
567 554
         lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
568
-        lcd_moveto(74, 7);
569
-        lcd_put_u8str("Y:");
555
+        lcd_put_u8str(74, 7, "Y:");
570 556
         lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
571 557
       }
572 558
 
573 559
       // Print plot position
574 560
       if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) {
575
-        lcd_moveto(5, LCD_PIXEL_HEIGHT);
576
-        lcd_put_wchar('(');
561
+        lcd_put_wchar(5, LCD_PIXEL_HEIGHT, '(');
577 562
         u8g.print(x_plot);
578 563
         lcd_put_wchar(',');
579 564
         u8g.print(y_plot);
580 565
         lcd_put_wchar(')');
581 566
 
582 567
         // Show the location value
583
-        lcd_moveto(74, LCD_PIXEL_HEIGHT);
584
-        lcd_put_u8str("Z:");
568
+        lcd_put_u8str(74, LCD_PIXEL_HEIGHT, "Z:");
585 569
         if (!isnan(ubl.z_values[x_plot][y_plot]))
586 570
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
587 571
         else

+ 13
- 2
Marlin/src/lcd/lcdprint.h View File

@@ -39,6 +39,11 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length);
39 39
 int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
40 40
 
41 41
 /**
42
+ * Set the print baseline position
43
+ */
44
+void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row);
45
+
46
+/**
42 47
  * @brief Draw a ROM UTF-8 string
43 48
  *
44 49
  * @param utf8_str_P : the ROM UTF-8 string
@@ -49,13 +54,19 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
49 54
  * Draw a ROM UTF-8 string
50 55
  */
51 56
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
52
-
53
-void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row);
57
+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) {
58
+  lcd_moveto(col, row);
59
+  return lcd_put_u8str_max_P(utf8_str_P, max_length);
60
+}
54 61
 
55 62
 void lcd_put_int(const int i);
63
+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); }
56 64
 
57 65
 inline int lcd_put_u8str_P(PGM_P str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); }
66
+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); }
58 67
 
59 68
 inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }
69
+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); }
60 70
 
61 71
 inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
72
+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); }

+ 1
- 2
Marlin/src/lcd/menu/game/brickout.cpp View File

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

+ 1
- 4
Marlin/src/lcd/menu/game/game.cpp View File

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

+ 1
- 2
Marlin/src/lcd/menu/game/invaders.cpp View File

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

+ 1
- 4
Marlin/src/lcd/menu/game/maze.cpp View File

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

+ 1
- 4
Marlin/src/lcd/menu/game/snake.cpp View File

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

+ 1
- 2
Marlin/src/lcd/menu/menu_configuration.cpp View File

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

Loading…
Cancel
Save