Browse Source

Use u8g int type for screen coordinates (#14965)

Robby Candra 6 years ago
parent
commit
823178c272

+ 1
- 1
Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp View File

@@ -877,7 +877,7 @@ static int pf_bsearch_cb_comp_hd4map_pgm(void *userdata, size_t idx, void * data
877 877
   return hd44780_charmap_compare(&localval, (hd44780_charmap_t *)data_pin);
878 878
 }
879 879
 
880
-void lcd_moveto(const uint8_t col, const uint8_t row) { lcd.setCursor(col, row); }
880
+void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { lcd.setCursor(col, row); }
881 881
 
882 882
 void lcd_put_int(const int i) { lcd.print(i); }
883 883
 

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

@@ -364,14 +364,14 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
364 364
 
365 365
 #if ENABLED(SHOW_BOOTSCREEN)
366 366
 
367
-  void lcd_erase_line(const int16_t line) {
367
+  void lcd_erase_line(const lcd_uint_t line) {
368 368
     lcd_moveto(0, line);
369 369
     for (uint8_t i = LCD_WIDTH + 1; --i;)
370 370
       lcd_put_wchar(' ');
371 371
   }
372 372
 
373 373
   // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
374
-  void lcd_scroll(const uint8_t col, const uint8_t line, PGM_P const text, const uint8_t len, const int16_t time) {
374
+  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) {
375 375
     uint8_t slen = utf8_strlen_P(text);
376 376
     if (slen < len) {
377 377
       // Fits into,
@@ -1031,9 +1031,9 @@ void MarlinUI::draw_status_screen() {
1031 1031
     if (value != nullptr) {
1032 1032
       lcd_put_wchar(':');
1033 1033
       int len = utf8_strlen(value);
1034
-      const uint8_t valrow = (utf8_strlen_P(pstr) + 1 + len + 1) > (LCD_WIDTH - 2) ? 2 : 1;   // Value on the next row if it won't fit
1035
-      lcd_moveto((LCD_WIDTH - 1) - (len + 1), valrow);                                        // Right-justified, padded by spaces
1036
-      lcd_put_wchar(' ');                                                                     // Overwrite char if value gets shorter
1034
+      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
1035
+      lcd_moveto((LCD_WIDTH - 1) - (len + 1), valrow);                                           // Right-justified, padded by spaces
1036
+      lcd_put_wchar(' ');                                                                        // Overwrite char if value gets shorter
1037 1037
       lcd_put_u8str(value);
1038 1038
     }
1039 1039
   }
@@ -1144,9 +1144,9 @@ void MarlinUI::draw_status_screen() {
1144 1144
     } custom_char;
1145 1145
 
1146 1146
     typedef struct {
1147
-      uint8_t column, row,
1148
-              x_pixel_offset, y_pixel_offset,
1149
-              x_pixel_mask;
1147
+      lcd_uint_t column, row,
1148
+                 x_pixel_offset, y_pixel_offset;
1149
+      uint8_t x_pixel_mask;
1150 1150
     } coordinate;
1151 1151
 
1152 1152
     void add_edges_to_custom_char(custom_char &custom, const coordinate &ul, const coordinate &lr, const coordinate &brc, const uint8_t cell_location);
@@ -1174,16 +1174,16 @@ void MarlinUI::draw_status_screen() {
1174 1174
       return ret_val;
1175 1175
     }
1176 1176
 
1177
-    inline coordinate pixel_location(const uint8_t x, const uint8_t y) { return pixel_location((int16_t)x, (int16_t)y); }
1177
+    inline coordinate pixel_location(const lcd_uint_t x, const lcd_uint_t y) { return pixel_location((int16_t)x, (int16_t)y); }
1178 1178
 
1179
-    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 uint8_t x, const uint8_t y) {
1179
+    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) {
1180 1180
       add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
1181 1181
       lcd.createChar(c, (uint8_t*)&chrdata);
1182 1182
       lcd_moveto(x, y);
1183 1183
       lcd_put_wchar(c);
1184 1184
     }
1185 1185
 
1186
-    void MarlinUI::ubl_plot(const uint8_t x, const uint8_t inverted_y) {
1186
+    void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
1187 1187
 
1188 1188
       #if LCD_WIDTH >= 20
1189 1189
         #define _LCD_W_POS 12
@@ -1209,10 +1209,10 @@ void MarlinUI::draw_status_screen() {
1209 1209
          * Show X and Y positions
1210 1210
          */
1211 1211
         _XLABEL(_PLOT_X, 0);
1212
-        lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x]))));
1212
+        lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1213 1213
 
1214 1214
         _YLABEL(_LCD_W_POS, 0);
1215
-        lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[inverted_y]))));
1215
+        lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1216 1216
 
1217 1217
         lcd_moveto(_PLOT_X, 0);
1218 1218
 
@@ -1220,13 +1220,13 @@ void MarlinUI::draw_status_screen() {
1220 1220
 
1221 1221
         coordinate upper_left, lower_right, bottom_right_corner;
1222 1222
         custom_char new_char;
1223
-        uint8_t i, j, k, l, m, n, n_rows, n_cols, y,
1224
-                bottom_line, right_edge,
1225
-                x_map_pixels, y_map_pixels,
1226
-                pixels_per_x_mesh_pnt, pixels_per_y_mesh_pnt,
1227
-                suppress_x_offset = 0, suppress_y_offset = 0;
1223
+        uint8_t i, n, n_rows, n_cols;
1224
+        lcd_uint_t j, k, l, m, bottom_line, right_edge,
1225
+                   x_map_pixels, y_map_pixels,
1226
+                   pixels_per_x_mesh_pnt, pixels_per_y_mesh_pnt,
1227
+                   suppress_x_offset = 0, suppress_y_offset = 0;
1228 1228
 
1229
-        y = GRID_MAX_POINTS_Y - inverted_y - 1;
1229
+        const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y - 1) - y_plot;
1230 1230
 
1231 1231
         upper_left.column  = 0;
1232 1232
         upper_left.row     = 0;
@@ -1310,12 +1310,12 @@ void MarlinUI::draw_status_screen() {
1310 1310
           new_char.custom_char_bits[j] = (uint8_t)_BV(i);                   // Char #3 is used for the box right edge
1311 1311
         lcd.createChar(CHAR_EDGE_R, (uint8_t*)&new_char);
1312 1312
 
1313
-        i = x * pixels_per_x_mesh_pnt - suppress_x_offset;
1314
-        j = y * pixels_per_y_mesh_pnt - suppress_y_offset;
1313
+        i = x_plot * pixels_per_x_mesh_pnt - suppress_x_offset;
1314
+        j = y_plot_inv * pixels_per_y_mesh_pnt - suppress_y_offset;
1315 1315
         upper_left = pixel_location(i, j);
1316 1316
 
1317
-        k = (x + 1) * pixels_per_x_mesh_pnt - 1 - suppress_x_offset;
1318
-        l = (y + 1) * pixels_per_y_mesh_pnt - 1 - suppress_y_offset;
1317
+        k = (x_plot + 1) * pixels_per_x_mesh_pnt - 1 - suppress_x_offset;
1318
+        l = (y_plot_inv + 1) * pixels_per_y_mesh_pnt - 1 - suppress_y_offset;
1319 1319
         lower_right = pixel_location(k, l);
1320 1320
 
1321 1321
         bottom_right_corner = pixel_location(x_map_pixels, y_map_pixels);
@@ -1327,7 +1327,7 @@ void MarlinUI::draw_status_screen() {
1327 1327
          */
1328 1328
 
1329 1329
         clear_custom_char(&new_char);
1330
-        const uint8_t ypix = _MIN(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, HD44780_CHAR_HEIGHT);
1330
+        const lcd_uint_t ypix = _MIN(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, HD44780_CHAR_HEIGHT);
1331 1331
         for (j = upper_left.y_pixel_offset; j < ypix; j++) {
1332 1332
           i = upper_left.x_pixel_mask;
1333 1333
           for (k = 0; k < pixels_per_x_mesh_pnt; k++) {
@@ -1400,9 +1400,9 @@ void MarlinUI::draw_status_screen() {
1400 1400
        */
1401 1401
       lcd_moveto(_LCD_W_POS, 0);
1402 1402
       lcd_put_wchar('(');
1403
-      lcd_put_u8str(ui8tostr3(x));
1403
+      lcd_put_u8str(ui8tostr3(x_plot));
1404 1404
       lcd_put_wchar(',');
1405
-      lcd_put_u8str(ui8tostr3(inverted_y));
1405
+      lcd_put_u8str(ui8tostr3(y_plot));
1406 1406
       lcd_put_wchar(')');
1407 1407
 
1408 1408
       #if LCD_HEIGHT <= 3   // 16x2 or 20x2 display
@@ -1411,8 +1411,8 @@ void MarlinUI::draw_status_screen() {
1411 1411
          * Print Z values
1412 1412
          */
1413 1413
         _ZLABEL(_LCD_W_POS, 1);
1414
-        if (!isnan(ubl.z_values[x][inverted_y]))
1415
-          lcd_put_u8str(ftostr43sign(ubl.z_values[x][inverted_y]));
1414
+        if (!isnan(ubl.z_values[x_plot][y_plot]))
1415
+          lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1416 1416
         else
1417 1417
           lcd_put_u8str_P(PSTR(" -----"));
1418 1418
 
@@ -1422,16 +1422,16 @@ void MarlinUI::draw_status_screen() {
1422 1422
          * Show all values at right of screen
1423 1423
          */
1424 1424
         _XLABEL(_LCD_W_POS, 1);
1425
-        lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x]))));
1425
+        lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1426 1426
         _YLABEL(_LCD_W_POS, 2);
1427
-        lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[inverted_y]))));
1427
+        lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1428 1428
 
1429 1429
         /**
1430 1430
          * Show the location value
1431 1431
          */
1432 1432
         _ZLABEL(_LCD_W_POS, 3);
1433
-        if (!isnan(ubl.z_values[x][inverted_y]))
1434
-          lcd_put_u8str(ftostr43sign(ubl.z_values[x][inverted_y]));
1433
+        if (!isnan(ubl.z_values[x_plot][y_plot]))
1434
+          lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1435 1435
         else
1436 1436
           lcd_put_u8str_P(PSTR(" -----"));
1437 1437
 

+ 7
- 11
Marlin/src/lcd/dogm/lcdprint_u8g.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 int lcd_glyph_height(void) { return u8g_GetFontBBXHeight(u8g.getU8g()); }
24 24
 
25
-void lcd_moveto(const uint8_t col, const uint8_t row) { u8g.setPrintPos(col, row); }
25
+void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { u8g.setPrintPos(col, row); }
26 26
 
27 27
 void lcd_put_int(const int i) { u8g.print(i); }
28 28
 
@@ -33,26 +33,22 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
33 33
     u8g.print((char)c);
34 34
     return u8g_GetFontBBXWidth(u8g.getU8g());
35 35
   }
36
-  unsigned int x = u8g.getPrintCol(),
37
-               y = u8g.getPrintRow(),
38
-               ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length);
36
+  u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(),
37
+           ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length);
39 38
   u8g.setPrintPos(x + ret, y);
40
-
41 39
   return ret;
42 40
 }
43 41
 
44 42
 int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
45
-  unsigned int x = u8g.getPrintCol(),
46
-               y = u8g.getPrintRow(),
47
-               ret = uxg_DrawUtf8Str(u8g.getU8g(), x, y, utf8_str, max_length);
43
+  u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(),
44
+           ret = uxg_DrawUtf8Str(u8g.getU8g(), x, y, utf8_str, max_length);
48 45
   u8g.setPrintPos(x + ret, y);
49 46
   return ret;
50 47
 }
51 48
 
52 49
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
53
-  unsigned int x = u8g.getPrintCol(),
54
-               y = u8g.getPrintRow(),
55
-               ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_str_P, max_length);
50
+  u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(),
51
+           ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_str_P, max_length);
56 52
   u8g.setPrintPos(x + ret, y);
57 53
   return ret;
58 54
 }

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

@@ -108,7 +108,7 @@ void MarlinUI::set_font(const MarlinFont font_nr) {
108 108
     // Draws a slice of a particular frame of the custom bootscreen, without the u8g loop
109 109
     void MarlinUI::draw_custom_bootscreen(const uint8_t frame/*=0*/) {
110 110
       constexpr u8g_uint_t left = u8g_uint_t((LCD_PIXEL_WIDTH  - (CUSTOM_BOOTSCREEN_BMPWIDTH)) / 2),
111
-                           top = u8g_uint_t((LCD_PIXEL_HEIGHT - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) / 2);
111
+                            top = u8g_uint_t((LCD_PIXEL_HEIGHT - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) / 2);
112 112
       #if ENABLED(CUSTOM_BOOTSCREEN_INVERTED)
113 113
         constexpr u8g_uint_t right = left + CUSTOM_BOOTSCREEN_BMPWIDTH,
114 114
                             bottom = top + CUSTOM_BOOTSCREEN_BMPHEIGHT;
@@ -160,23 +160,23 @@ void MarlinUI::set_font(const MarlinFont font_nr) {
160 160
   // Draws a slice of the Marlin bootscreen, without the u8g loop
161 161
   void MarlinUI::draw_marlin_bootscreen() {
162 162
     // Screen dimensions.
163
-    //const uint8_t width = u8g.getWidth(), height = u8g.getHeight();
164
-    constexpr uint8_t width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT;
163
+    //const u8g_uint_t width = u8g.getWidth(), height = u8g.getHeight();
164
+    constexpr u8g_uint_t width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT;
165 165
 
166 166
     // Determine text space needed
167 167
     #ifndef STRING_SPLASH_LINE2
168
-      constexpr uint8_t text_total_height = MENU_FONT_HEIGHT,
169
-                        text_width_1 = uint8_t(sizeof(STRING_SPLASH_LINE1) - 1) * uint8_t(MENU_FONT_WIDTH),
170
-                        text_width_2 = 0;
168
+      constexpr u8g_uint_t text_total_height = MENU_FONT_HEIGHT,
169
+                           text_width_1 = u8g_uint_t(sizeof(STRING_SPLASH_LINE1) - 1) * u8g_uint_t(MENU_FONT_WIDTH),
170
+                           text_width_2 = 0;
171 171
     #else
172
-      constexpr uint8_t text_total_height = uint8_t(MENU_FONT_HEIGHT) * 2,
173
-                        text_width_1 = uint8_t(sizeof(STRING_SPLASH_LINE1) - 1) * uint8_t(MENU_FONT_WIDTH),
174
-                        text_width_2 = uint8_t(sizeof(STRING_SPLASH_LINE2) - 1) * uint8_t(MENU_FONT_WIDTH);
172
+      constexpr u8g_uint_t text_total_height = u8g_uint_t(MENU_FONT_HEIGHT) * 2,
173
+                           text_width_1 = u8g_uint_t(sizeof(STRING_SPLASH_LINE1) - 1) * u8g_uint_t(MENU_FONT_WIDTH),
174
+                           text_width_2 = u8g_uint_t(sizeof(STRING_SPLASH_LINE2) - 1) * u8g_uint_t(MENU_FONT_WIDTH);
175 175
     #endif
176
-    constexpr uint8_t text_max_width = _MAX(text_width_1, text_width_2),
177
-                      rspace = width - (START_BMPWIDTH);
176
+    constexpr u8g_uint_t text_max_width = _MAX(text_width_1, text_width_2),
177
+                         rspace = width - (START_BMPWIDTH);
178 178
 
179
-    int8_t offx, offy, txt_base, txt_offx_1, txt_offx_2;
179
+    u8g_int_t offx, offy, txt_base, txt_offx_1, txt_offx_2;
180 180
 
181 181
     // Can the text fit to the right of the bitmap?
182 182
     if (text_max_width < rspace) {
@@ -299,7 +299,7 @@ void MarlinUI::draw_kill_screen() {
299 299
   #if ENABLED(LIGHTWEIGHT_UI)
300 300
     ST7920_Lite_Status_Screen::clear_text_buffer();
301 301
   #endif
302
-  const uint8_t h4 = u8g.getHeight() / 4;
302
+  const u8g_uint_t h4 = u8g.getHeight() / 4;
303 303
   u8g.firstPage();
304 304
   do {
305 305
     set_font(FONT_MENU);
@@ -316,7 +316,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
316 316
 
317 317
 #if HAS_LCD_MENU
318 318
 
319
-  uint8_t row_y1, row_y2;
319
+  u8g_uint_t row_y1, row_y2;
320 320
 
321 321
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
322 322
 
@@ -373,7 +373,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
373 373
 
374 374
     if (mark_as_selected(row, invert)) {
375 375
 
376
-      uint8_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
376
+      u8g_uint_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
377 377
 
378 378
       if (center && !valstr) {
379 379
         int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
@@ -390,7 +390,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
390 390
     UNUSED(pre_char);
391 391
 
392 392
     if (mark_as_selected(row, sel)) {
393
-      uint8_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
393
+      u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
394 394
       n -= lcd_put_u8str_max_P(pstr, n);
395 395
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
396 396
       lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2);
@@ -403,7 +403,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
403 403
   void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) {
404 404
     if (mark_as_selected(row, sel)) {
405 405
       const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data));
406
-      uint8_t n = (LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
406
+      u8g_uint_t n = (LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
407 407
       n -= lcd_put_u8str_max_P(pstr, n);
408 408
       lcd_put_wchar(':');
409 409
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
@@ -415,13 +415,13 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
415 415
   void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
416 416
     ui.encoder_direction_normal();
417 417
 
418
-    const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value);
418
+    const u8g_uint_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value);
419 419
     bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
420 420
 
421 421
     #if ENABLED(USE_BIG_EDIT_FONT)
422 422
       // Use the menu font if the label won't fit on a single line
423
-      constexpr uint8_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH);
424
-      uint8_t lcd_chr_fit, one_chr_width;
423
+      constexpr u8g_uint_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH);
424
+      u8g_uint_t lcd_chr_fit, one_chr_width;
425 425
       if (labellen <= lcd_edit_width - 1) {
426 426
         if (labellen + vallen + 1 > lcd_edit_width) extra_row = true;
427 427
         lcd_chr_fit = lcd_edit_width + 1;
@@ -434,13 +434,13 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
434 434
         ui.set_font(FONT_MENU);
435 435
       }
436 436
     #else
437
-      constexpr uint8_t lcd_chr_fit = LCD_WIDTH,
438
-                        one_chr_width = MENU_FONT_WIDTH;
437
+      constexpr u8g_uint_t lcd_chr_fit = LCD_WIDTH,
438
+                           one_chr_width = MENU_FONT_WIDTH;
439 439
     #endif
440 440
 
441 441
     // Center the label and value lines on the middle line
442
-    uint8_t baseline = extra_row ? (LCD_PIXEL_HEIGHT) / 2 - 1
443
-                                 : (LCD_PIXEL_HEIGHT + EDIT_FONT_ASCENT) / 2;
442
+    u8g_uint_t baseline = extra_row ? (LCD_PIXEL_HEIGHT) / 2 - 1
443
+                                    : (LCD_PIXEL_HEIGHT + EDIT_FONT_ASCENT) / 2;
444 444
 
445 445
     // Assume the label is alpha-numeric (with a descender)
446 446
     bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
@@ -465,9 +465,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
465 465
     }
466 466
   }
467 467
 
468
-  inline void draw_boxed_string(const uint8_t x, const uint8_t y, PGM_P const pstr, const bool inv) {
469
-    const uint8_t len = utf8_strlen_P(pstr), bw = len * (MENU_FONT_WIDTH),
470
-                  bx = x * (MENU_FONT_WIDTH), by = (y + 1) * (MENU_FONT_HEIGHT);
468
+  inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) {
469
+    const u8g_uint_t len = utf8_strlen_P(pstr), bw = len * (MENU_FONT_WIDTH),
470
+                     bx = x * (MENU_FONT_WIDTH), by = (y + 1) * (MENU_FONT_HEIGHT);
471 471
     if (inv) {
472 472
       u8g.setColorIndex(1);
473 473
       u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
@@ -492,8 +492,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
492 492
       if (mark_as_selected(row, sel)) {
493 493
         if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
494 494
         constexpr uint8_t maxlen = LCD_WIDTH - 1;
495
-        const uint8_t pixw = maxlen * (MENU_FONT_WIDTH);
496
-        uint8_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw);
495
+        const u8g_uint_t pixw = maxlen * (MENU_FONT_WIDTH);
496
+        u8g_uint_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw);
497 497
         while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
498 498
       }
499 499
     }
@@ -512,8 +512,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
512 512
 
513 513
     void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
514 514
       // Scale the box pixels appropriately
515
-      uint8_t x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X),
516
-              y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y),
515
+      u8g_uint_t x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X),
516
+                 y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y),
517 517
 
518 518
               pixels_per_x_mesh_pnt = x_map_pixels / (GRID_MAX_POINTS_X),
519 519
               pixels_per_y_mesh_pnt = y_map_pixels / (GRID_MAX_POINTS_Y),
@@ -535,8 +535,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
535 535
       // Display Mesh Point Locations
536 536
 
537 537
       u8g.setColorIndex(1);
538
-      const uint8_t sx = x_offset + pixels_per_x_mesh_pnt / 2;
539
-            uint8_t  y = y_offset + pixels_per_y_mesh_pnt / 2;
538
+      const u8g_uint_t sx = x_offset + pixels_per_x_mesh_pnt / 2;
539
+            u8g_uint_t  y = y_offset + pixels_per_y_mesh_pnt / 2;
540 540
       for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt)
541 541
         if (PAGE_CONTAINS(y, y))
542 542
           for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt)
@@ -544,10 +544,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
544 544
 
545 545
       // Fill in the Specified Mesh Point
546 546
 
547
-      uint8_t inverted_y = GRID_MAX_POINTS_Y - y_plot - 1;  // The origin is typically in the lower right corner.  We need to
548
-                                                            // invert the Y to get it to plot in the right location.
547
+      const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y - 1) - y_plot;  // The origin is typically in the lower right corner.  We need to
548
+                                                                    // invert the Y to get it to plot in the right location.
549 549
 
550
-      const uint8_t by = y_offset + inverted_y * pixels_per_y_mesh_pnt;
550
+      const u8g_uint_t by = y_offset + y_plot_inv * pixels_per_y_mesh_pnt;
551 551
       if (PAGE_CONTAINS(by, by + pixels_per_y_mesh_pnt))
552 552
         u8g.drawBox(
553 553
           x_offset + x_plot * pixels_per_x_mesh_pnt, by,

+ 3
- 1
Marlin/src/lcd/lcdprint.h View File

@@ -14,8 +14,10 @@
14 14
 
15 15
 #if HAS_GRAPHICAL_LCD
16 16
   #include "dogm/u8g_fontutf8.h"
17
+  typedef u8g_uint_t lcd_uint_t;
17 18
 #else
18 19
   #define _UxGT(a) a
20
+  typedef uint8_t lcd_uint_t;
19 21
 #endif
20 22
 
21 23
 #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
@@ -48,7 +50,7 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
48 50
  */
49 51
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
50 52
 
51
-void lcd_moveto(const uint8_t col, const uint8_t row);
53
+void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row);
52 54
 
53 55
 void lcd_put_int(const int i);
54 56
 

+ 4
- 5
Marlin/src/lcd/menu/menu_ubl.cpp View File

@@ -37,10 +37,9 @@ static int16_t ubl_storage_slot = 0,
37 37
                custom_hotend_temp = 190,
38 38
                side_points = 3,
39 39
                ubl_fillin_amount = 5,
40
-               ubl_height_amount = 1,
41
-               n_edit_pts = 1,
42
-               x_plot = 0,
43
-               y_plot = 0;
40
+               ubl_height_amount = 1;
41
+
42
+static uint8_t n_edit_pts = 1, x_plot = 0, y_plot = 0;
44 43
 
45 44
 #if HAS_HEATED_BED
46 45
   static int16_t custom_bed_temp = 50;
@@ -423,7 +422,7 @@ void _lcd_ubl_map_lcd_edit_cmd() {
423 422
   char ubl_lcd_gcode[50], str[10], str2[10];
424 423
   dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
425 424
   dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
426
-  snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
425
+  snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
427 426
   lcd_enqueue_one_now(ubl_lcd_gcode);
428 427
 }
429 428
 

+ 16
- 16
Marlin/src/lcd/ultralcd.cpp View File

@@ -205,13 +205,13 @@ millis_t next_button_update_ms;
205 205
 
206 206
   #endif
207 207
 
208
-  void _wrap_string(uint8_t &x, uint8_t &y, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
209
-    SETCURSOR(x, y);
208
+  void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
209
+    SETCURSOR(col, row);
210 210
     if (!string) return;
211 211
 
212
-    auto _newline = [&x, &y]() {
213
-      x = 0; y++;               // move x to string len (plus space)
214
-      SETCURSOR(0, y);          // simulate carriage return
212
+    auto _newline = [&col, &row]() {
213
+      col = 0; row++;                 // Move col to string len (plus space)
214
+      SETCURSOR(0, row);              // Simulate carriage return
215 215
     };
216 216
 
217 217
     uint8_t *p = (uint8_t*)string;
@@ -227,9 +227,9 @@ millis_t next_button_update_ms;
227 227
         if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
228 228
           if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
229 229
           // Past the right and the word is not too long?
230
-          if (x + c > LCD_WIDTH && x >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
230
+          if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
231 231
           c += !eol;                  // +1 so the space will be printed
232
-          x += c;                     // advance x to new position
232
+          col += c;                   // advance col to new position
233 233
           while (c) {                 // character countdown
234 234
             --c;                      // count down to zero
235 235
             wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
@@ -246,25 +246,25 @@ millis_t next_button_update_ms;
246 246
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
247 247
         if (!ch) break;
248 248
         lcd_put_wchar(ch);
249
-        x++;
250
-        if (x >= LCD_WIDTH) _newline();
249
+        col++;
250
+        if (col >= LCD_WIDTH) _newline();
251 251
       }
252 252
     }
253 253
   }
254 254
 
255 255
   void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
256 256
     const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
257
-    uint8_t x = 0, y = 0;
257
+    uint8_t row = 0, col = 0;
258 258
     if (!string && plen + slen <= LCD_WIDTH) {
259
-      x = (LCD_WIDTH - plen - slen) / 2;
260
-      y = LCD_HEIGHT > 3 ? 1 : 0;
259
+      row = (LCD_WIDTH - plen - slen) / 2;
260
+      col = LCD_HEIGHT > 3 ? 1 : 0;
261 261
     }
262
-    wrap_string_P(x, y, pref, true);
262
+    wrap_string_P(row, col, pref, true);
263 263
     if (string) {
264
-      if (x) { x = 0; y++; } // Move to the start of the next line
265
-      wrap_string(x, y, string);
264
+      if (row) { row = 0; col++; } // Move to the start of the next line
265
+      wrap_string(row, col, string);
266 266
     }
267
-    if (suff) wrap_string_P(x, y, suff);
267
+    if (suff) wrap_string_P(row, col, suff);
268 268
   }
269 269
 
270 270
 #endif // HAS_LCD_MENU

+ 5
- 5
Marlin/src/lcd/ultralcd.h View File

@@ -76,11 +76,11 @@
76 76
       #define LCDWRITE(c) lcd_put_wchar(c)
77 77
     #endif
78 78
 
79
-    #include "fontutils.h"
79
+    #include "lcdprint.h"
80 80
 
81
-    void _wrap_string(uint8_t &x, uint8_t &y, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
82
-    inline void wrap_string_P(uint8_t &x, uint8_t &y, PGM_P const pstr, const bool wordwrap=false) { _wrap_string(x, y, pstr, read_byte_rom, wordwrap); }
83
-    inline void wrap_string(uint8_t &x, uint8_t &y, const char * const string, const bool wordwrap=false) { _wrap_string(x, y, string, read_byte_ram, wordwrap); }
81
+    void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
82
+    inline void wrap_string_P(uint8_t &col, uint8_t &row, PGM_P const pstr, const bool wordwrap=false) { _wrap_string(col, row, pstr, read_byte_rom, wordwrap); }
83
+    inline void wrap_string(uint8_t &col, uint8_t &row, const char * const string, const bool wordwrap=false) { _wrap_string(col, row, string, read_byte_ram, wordwrap); }
84 84
 
85 85
     #if ENABLED(SDSUPPORT)
86 86
       #include "../sd/cardreader.h"
@@ -486,7 +486,7 @@ public:
486 486
     #endif
487 487
 
488 488
     #if ENABLED(AUTO_BED_LEVELING_UBL)
489
-      static void ubl_plot(const uint8_t x, const uint8_t inverted_y);
489
+      static void ubl_plot(const uint8_t x_plot, const uint8_t y_plot);
490 490
     #endif
491 491
 
492 492
     static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);

Loading…
Cancel
Save