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
   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) {
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
     uint8_t slen = utf8_strlen_P(text);
402
     uint8_t slen = utf8_strlen_P(text);
403
     if (slen < len) {
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
       for (; slen < len; ++slen) lcd_put_wchar(' ');
405
       for (; slen < len; ++slen) lcd_put_wchar(' ');
408
       safe_delay(time);
406
       safe_delay(time);
409
     }
407
     }
412
       int dly = time / _MAX(slen, 1);
410
       int dly = time / _MAX(slen, 1);
413
       for (uint8_t i = 0; i <= slen; i++) {
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
         // Fill with spaces
416
         // Fill with spaces
422
         for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_wchar(' ');
417
         for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_wchar(' ');
433
 
428
 
434
   static void logo_lines(PGM_P const extra) {
429
   static void logo_lines(PGM_P const extra) {
435
     int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2;
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
   void MarlinUI::show_bootscreen() {
436
   void MarlinUI::show_bootscreen() {
447
     #define CENTER_OR_SCROLL(STRING,DELAY) \
442
     #define CENTER_OR_SCROLL(STRING,DELAY) \
448
       lcd_erase_line(3); \
443
       lcd_erase_line(3); \
449
       if (utf8_strlen(STRING) <= LCD_WIDTH) { \
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
         safe_delay(DELAY); \
446
         safe_delay(DELAY); \
453
       } \
447
       } \
454
       else { \
448
       else { \
518
 #endif // SHOW_BOOTSCREEN
512
 #endif // SHOW_BOOTSCREEN
519
 
513
 
520
 void MarlinUI::draw_kill_screen() {
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
   #endif
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
 
876
 
887
     #if LCD_HEIGHT > 3
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
       lcd_put_u8str(i16tostr3(feedrate_percentage));
880
       lcd_put_u8str(i16tostr3(feedrate_percentage));
892
       lcd_put_wchar('%');
881
       lcd_put_wchar('%');
893
 
882
 
895
       duration_t elapsed = print_job_timer.duration();
884
       duration_t elapsed = print_job_timer.duration();
896
       const uint8_t len = elapsed.toDigital(buffer),
885
       const uint8_t len = elapsed.toDigital(buffer),
897
                     timepos = LCD_WIDTH - len - 1;
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
       lcd_put_u8str(buffer);
888
       lcd_put_u8str(buffer);
901
 
889
 
902
       #if LCD_WIDTH >= 20
890
       #if LCD_WIDTH >= 20
945
     _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink);
933
     _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink);
946
 
934
 
947
     #if HAS_LEVELING && (HOTENDS > 1 || !HAS_HEATED_BED)
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
     #endif
937
     #endif
951
 
938
 
952
     // ========== Line 2 ==========
939
     // ========== Line 2 ==========
961
       _draw_bed_status(blink);
948
       _draw_bed_status(blink);
962
     #endif
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
     lcd_put_u8str(i16tostr3(feedrate_percentage));
952
     lcd_put_u8str(i16tostr3(feedrate_percentage));
967
     lcd_put_wchar('%');
953
     lcd_put_wchar('%');
968
 
954
 
1033
 
1019
 
1034
   void draw_menu_item(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
1020
   void draw_menu_item(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
1035
     uint8_t n = LCD_WIDTH - 2;
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
     n -= lcd_put_u8str_max_P(pstr, n);
1023
     n -= lcd_put_u8str_max_P(pstr, n);
1039
     for (; n; --n) lcd_put_wchar(' ');
1024
     for (; n; --n) lcd_put_wchar(' ');
1040
     lcd_put_wchar(post_char);
1025
     lcd_put_wchar(post_char);
1042
 
1027
 
1043
   void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
1028
   void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
1044
     uint8_t n = LCD_WIDTH - 2 - (pgm ? utf8_strlen_P(data) : utf8_strlen(data));
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
     n -= lcd_put_u8str_max_P(pstr, n);
1031
     n -= lcd_put_u8str_max_P(pstr, n);
1048
     lcd_put_wchar(':');
1032
     lcd_put_wchar(':');
1049
     for (; n; --n) lcd_put_wchar(' ');
1033
     for (; n; --n) lcd_put_wchar(' ');
1053
   void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
1037
   void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
1054
     ui.encoder_direction_normal();
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
     if (value != nullptr) {
1041
     if (value != nullptr) {
1059
       lcd_put_wchar(':');
1042
       lcd_put_wchar(':');
1060
       int len = utf8_strlen(value);
1043
       int len = utf8_strlen(value);
1061
       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
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
       lcd_put_u8str(value);
1046
       lcd_put_u8str(value);
1065
     }
1047
     }
1066
   }
1048
   }
1078
     void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
1060
     void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
1079
       UNUSED(pstr);
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
       constexpr uint8_t maxlen = LCD_WIDTH - 2;
1064
       constexpr uint8_t maxlen = LCD_WIDTH - 2;
1084
       uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
1065
       uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
1085
       for (; n; --n) lcd_put_wchar(' ');
1066
       for (; n; --n) lcd_put_wchar(' ');
1206
     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) {
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
       add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
1188
       add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
1208
       lcd.createChar(c, (uint8_t*)&chrdata);
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
     void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
1193
     void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
1216
         #define _LCD_W_POS 12
1196
         #define _LCD_W_POS 12
1217
         #define _PLOT_X 1
1197
         #define _PLOT_X 1
1218
         #define _MAP_X 3
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
         #define _XLABEL(X,Y) _LABEL("X:",X,Y)
1200
         #define _XLABEL(X,Y) _LABEL("X:",X,Y)
1221
         #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
1201
         #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
1222
         #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
1202
         #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
1224
         #define _LCD_W_POS 8
1204
         #define _LCD_W_POS 8
1225
         #define _PLOT_X 0
1205
         #define _PLOT_X 0
1226
         #define _MAP_X 1
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
         #define _XLABEL(X,Y) _LABEL('X',X,Y)
1208
         #define _XLABEL(X,Y) _LABEL('X',X,Y)
1229
         #define _YLABEL(X,Y) _LABEL('Y',X,Y)
1209
         #define _YLABEL(X,Y) _LABEL('Y',X,Y)
1230
         #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
1210
         #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
1288
         n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1;
1268
         n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1;
1289
 
1269
 
1290
         for (i = 0; i < n_cols; i++) {
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
         for (j = 0; j < n_rows; j++) {
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
         k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2;
1284
         k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2;
1309
         l = (HD44780_CHAR_HEIGHT) * n_rows;
1285
         l = (HD44780_CHAR_HEIGHT) * n_rows;
1310
         if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) {
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
         clear_custom_char(&new_char);
1291
         clear_custom_char(&new_char);
1425
       /**
1399
       /**
1426
        * Print plot position
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
       lcd_put_u8str(ui8tostr3(x_plot));
1403
       lcd_put_u8str(ui8tostr3(x_plot));
1431
       lcd_put_wchar(',');
1404
       lcd_put_wchar(',');
1432
       lcd_put_u8str(ui8tostr3(y_plot));
1405
       lcd_put_u8str(ui8tostr3(y_plot));

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

100
 FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
100
 FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
101
   const char *str = i16tostr3(temp);
101
   const char *str = i16tostr3(temp);
102
   const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
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
   lcd_put_wchar(LCD_STR_DEGREE[0]);
104
   lcd_put_wchar(LCD_STR_DEGREE[0]);
106
 }
105
 }
107
 
106
 
264
 //
263
 //
265
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
264
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
266
   const uint8_t offs = (XYZ_SPACING) * axis;
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
   lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
267
   lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
270
   if (blink)
268
   if (blink)
271
     lcd_put_u8str(value);
269
     lcd_put_u8str(value);
429
               c = '*';
427
               c = '*';
430
             }
428
             }
431
           #endif
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
           lcd_put_wchar(c);
431
           lcd_put_wchar(c);
435
         }
432
         }
436
       }
433
       }
488
       #if ENABLED(DOGM_SD_PERCENT)
485
       #if ENABLED(DOGM_SD_PERCENT)
489
         if (PAGE_CONTAINS(41, 48)) {
486
         if (PAGE_CONTAINS(41, 48)) {
490
           // Percent complete
487
           // Percent complete
491
-          lcd_moveto(55, 48);
492
-          lcd_put_u8str(ui8tostr3(progress));
488
+          lcd_put_u8str(55, 48, ui8tostr3(progress));
493
           lcd_put_wchar('%');
489
           lcd_put_wchar('%');
494
         }
490
         }
495
       #endif
491
       #endif
510
       duration_t elapsed = print_job_timer.duration();
506
       duration_t elapsed = print_job_timer.duration();
511
       bool has_days = (elapsed.value >= 60*60*24L);
507
       bool has_days = (elapsed.value >= 60*60*24L);
512
       uint8_t len = elapsed.toDigital(buffer, has_days);
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
   #endif // HAS_PRINT_PROGRESS
512
   #endif // HAS_PRINT_PROGRESS
546
 
541
 
547
         // Two-component mix / gradient instead of XY
542
         // Two-component mix / gradient instead of XY
548
 
543
 
549
-        lcd_moveto(X_LABEL_POS, XYZ_BASELINE);
550
-
551
         char mixer_messages[12];
544
         char mixer_messages[12];
552
         const char *mix_label;
545
         const char *mix_label;
553
         #if ENABLED(GRADIENT_MIX)
546
         #if ENABLED(GRADIENT_MIX)
562
             mix_label = "Mx";
555
             mix_label = "Mx";
563
           }
556
           }
564
         sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
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
       #else
560
       #else
568
 
561
 
587
 
580
 
588
   if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
581
   if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
589
     set_font(FONT_MENU);
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
     set_font(FONT_STATUSMENU);
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
     lcd_put_wchar('%');
587
     lcd_put_wchar('%');
597
 
588
 
598
     //
589
     //
599
     // Filament sensor display if SD is disabled
590
     // Filament sensor display if SD is disabled
600
     //
591
     //
601
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
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
       lcd_put_wchar('%');
595
       lcd_put_wchar('%');
607
       set_font(FONT_MENU);
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
     #endif
599
     #endif
613
   }
600
   }
614
 
601
 

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

201
     auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
201
     auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
202
       u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
202
       u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
203
       set_font(FONT_MENU);
203
       set_font(FONT_MENU);
204
-      const u8g_pgm_uint8_t splash1[] U8G_PROGMEM  = STRING_SPLASH_LINE1;
205
       #ifndef STRING_SPLASH_LINE2
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
       #else
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
       #endif
209
       #endif
212
     };
210
     };
213
 
211
 
306
   u8g.firstPage();
304
   u8g.firstPage();
307
   do {
305
   do {
308
     set_font(FONT_MENU);
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
   } while (u8g.nextPage());
310
   } while (u8g.nextPage());
316
 }
311
 }
317
 
312
 
329
 
324
 
330
       if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return;
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
       lcd_put_wchar((char)('1' + extruder));
328
       lcd_put_wchar((char)('1' + extruder));
335
       lcd_put_wchar(' ');
329
       lcd_put_wchar(' ');
336
       lcd_put_u8str(i16tostr3(thermalManager.degHotend(extruder)));
330
       lcd_put_u8str(i16tostr3(thermalManager.degHotend(extruder)));
396
       u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
390
       u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
397
       n -= lcd_put_u8str_max_P(pstr, n);
391
       n -= lcd_put_u8str_max_P(pstr, n);
398
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
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
       lcd_put_wchar(' ');
394
       lcd_put_wchar(' ');
402
     }
395
     }
403
   }
396
   }
447
 
440
 
448
     // Assume the label is alpha-numeric (with a descender)
441
     // Assume the label is alpha-numeric (with a descender)
449
     bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
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
     // If a value is included, print a colon, then print the value right-justified
445
     // If a value is included, print a colon, then print the value right-justified
456
     if (value != nullptr) {
446
     if (value != nullptr) {
461
         onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
451
         onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
462
       }
452
       }
463
       if (onpage) {
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
         lcd_put_u8str(value);
455
         lcd_put_u8str(value);
467
       }
456
       }
468
     }
457
     }
476
       u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
465
       u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
477
       u8g.setColorIndex(0);
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
     if (inv) u8g.setColorIndex(1);
469
     if (inv) u8g.setColorIndex(1);
482
   }
470
   }
483
 
471
 
562
       // Show X and Y positions at top of screen
550
       // Show X and Y positions at top of screen
563
       u8g.setColorIndex(1);
551
       u8g.setColorIndex(1);
564
       if (PAGE_UNDER(7)) {
552
       if (PAGE_UNDER(7)) {
565
-        lcd_moveto(5, 7);
566
-        lcd_put_u8str("X:");
553
+        lcd_put_u8str(5, 7, "X:");
567
         lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
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
         lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
556
         lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
571
       }
557
       }
572
 
558
 
573
       // Print plot position
559
       // Print plot position
574
       if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) {
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
         u8g.print(x_plot);
562
         u8g.print(x_plot);
578
         lcd_put_wchar(',');
563
         lcd_put_wchar(',');
579
         u8g.print(y_plot);
564
         u8g.print(y_plot);
580
         lcd_put_wchar(')');
565
         lcd_put_wchar(')');
581
 
566
 
582
         // Show the location value
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
         if (!isnan(ubl.z_values[x_plot][y_plot]))
569
         if (!isnan(ubl.z_values[x_plot][y_plot]))
586
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
570
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
587
         else
571
         else

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

39
 int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
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
  * @brief Draw a ROM UTF-8 string
47
  * @brief Draw a ROM UTF-8 string
43
  *
48
  *
44
  * @param utf8_str_P : the ROM UTF-8 string
49
  * @param utf8_str_P : the ROM UTF-8 string
49
  * Draw a ROM UTF-8 string
54
  * Draw a ROM UTF-8 string
50
  */
55
  */
51
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
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
 void lcd_put_int(const int i);
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
 inline int lcd_put_u8str_P(PGM_P str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); }
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
 inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }
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
 inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
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
     // Score Digits
180
     // Score Digits
181
     //const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
181
     //const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
182
     constexpr uint8_t sx = 0;
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
     // Balls Left
185
     // Balls Left
187
     lcd_moveto(LCD_PIXEL_WIDTH - MENU_FONT_WIDTH * 3, MENU_FONT_ASCENT - 1);
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
     u8g.setColorIndex(0);
48
     u8g.setColorIndex(0);
49
     u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2);
49
     u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2);
50
     u8g.setColorIndex(1);
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
     // Draw Score
416
     // Draw Score
417
     //const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
417
     //const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
418
     constexpr uint8_t sx = 0;
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
     // Draw lives
421
     // Draw lives
423
     if (idat.cannons_left)
422
     if (idat.cannons_left)

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

80
   u8g.setColorIndex(1);
80
   u8g.setColorIndex(1);
81
 
81
 
82
   // Draw Score
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
   // Draw the maze
85
   // Draw the maze
89
   // for (uint8_t n = 0; n < head_ind; ++n) {
86
   // for (uint8_t n = 0; n < head_ind; ++n) {

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

231
   u8g.setColorIndex(1);
231
   u8g.setColorIndex(1);
232
 
232
 
233
   // Draw Score
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
   // DRAW THE PLAYFIELD BORDER
236
   // DRAW THE PLAYFIELD BORDER
240
   u8g.drawFrame(BOARD_L - 2, BOARD_T - 2, BOARD_R - BOARD_L + 4, BOARD_B - BOARD_T + 4);
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
     LIMIT(bar_percent, 0, 100);
76
     LIMIT(bar_percent, 0, 100);
77
     ui.encoderPosition = 0;
77
     ui.encoderPosition = 0;
78
     draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
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
     lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent);
80
     lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent);
82
   }
81
   }
83
 
82
 

Loading…
Cancel
Save