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
   return hd44780_charmap_compare(&localval, (hd44780_charmap_t *)data_pin);
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
 void lcd_put_int(const int i) { lcd.print(i); }
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
 
364
 
365
 #if ENABLED(SHOW_BOOTSCREEN)
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
     lcd_moveto(0, line);
368
     lcd_moveto(0, line);
369
     for (uint8_t i = LCD_WIDTH + 1; --i;)
369
     for (uint8_t i = LCD_WIDTH + 1; --i;)
370
       lcd_put_wchar(' ');
370
       lcd_put_wchar(' ');
371
   }
371
   }
372
 
372
 
373
   // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
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
     uint8_t slen = utf8_strlen_P(text);
375
     uint8_t slen = utf8_strlen_P(text);
376
     if (slen < len) {
376
     if (slen < len) {
377
       // Fits into,
377
       // Fits into,
1031
     if (value != nullptr) {
1031
     if (value != nullptr) {
1032
       lcd_put_wchar(':');
1032
       lcd_put_wchar(':');
1033
       int len = utf8_strlen(value);
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
       lcd_put_u8str(value);
1037
       lcd_put_u8str(value);
1038
     }
1038
     }
1039
   }
1039
   }
1144
     } custom_char;
1144
     } custom_char;
1145
 
1145
 
1146
     typedef struct {
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
     } coordinate;
1150
     } coordinate;
1151
 
1151
 
1152
     void add_edges_to_custom_char(custom_char &custom, const coordinate &ul, const coordinate &lr, const coordinate &brc, const uint8_t cell_location);
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
       return ret_val;
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
       add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
1180
       add_edges_to_custom_char(chrdata, ul, lr, brc, cl);
1181
       lcd.createChar(c, (uint8_t*)&chrdata);
1181
       lcd.createChar(c, (uint8_t*)&chrdata);
1182
       lcd_moveto(x, y);
1182
       lcd_moveto(x, y);
1183
       lcd_put_wchar(c);
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
       #if LCD_WIDTH >= 20
1188
       #if LCD_WIDTH >= 20
1189
         #define _LCD_W_POS 12
1189
         #define _LCD_W_POS 12
1209
          * Show X and Y positions
1209
          * Show X and Y positions
1210
          */
1210
          */
1211
         _XLABEL(_PLOT_X, 0);
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
         _YLABEL(_LCD_W_POS, 0);
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
         lcd_moveto(_PLOT_X, 0);
1217
         lcd_moveto(_PLOT_X, 0);
1218
 
1218
 
1220
 
1220
 
1221
         coordinate upper_left, lower_right, bottom_right_corner;
1221
         coordinate upper_left, lower_right, bottom_right_corner;
1222
         custom_char new_char;
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
         upper_left.column  = 0;
1231
         upper_left.column  = 0;
1232
         upper_left.row     = 0;
1232
         upper_left.row     = 0;
1310
           new_char.custom_char_bits[j] = (uint8_t)_BV(i);                   // Char #3 is used for the box right edge
1310
           new_char.custom_char_bits[j] = (uint8_t)_BV(i);                   // Char #3 is used for the box right edge
1311
         lcd.createChar(CHAR_EDGE_R, (uint8_t*)&new_char);
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
         upper_left = pixel_location(i, j);
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
         lower_right = pixel_location(k, l);
1319
         lower_right = pixel_location(k, l);
1320
 
1320
 
1321
         bottom_right_corner = pixel_location(x_map_pixels, y_map_pixels);
1321
         bottom_right_corner = pixel_location(x_map_pixels, y_map_pixels);
1327
          */
1327
          */
1328
 
1328
 
1329
         clear_custom_char(&new_char);
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
         for (j = upper_left.y_pixel_offset; j < ypix; j++) {
1331
         for (j = upper_left.y_pixel_offset; j < ypix; j++) {
1332
           i = upper_left.x_pixel_mask;
1332
           i = upper_left.x_pixel_mask;
1333
           for (k = 0; k < pixels_per_x_mesh_pnt; k++) {
1333
           for (k = 0; k < pixels_per_x_mesh_pnt; k++) {
1400
        */
1400
        */
1401
       lcd_moveto(_LCD_W_POS, 0);
1401
       lcd_moveto(_LCD_W_POS, 0);
1402
       lcd_put_wchar('(');
1402
       lcd_put_wchar('(');
1403
-      lcd_put_u8str(ui8tostr3(x));
1403
+      lcd_put_u8str(ui8tostr3(x_plot));
1404
       lcd_put_wchar(',');
1404
       lcd_put_wchar(',');
1405
-      lcd_put_u8str(ui8tostr3(inverted_y));
1405
+      lcd_put_u8str(ui8tostr3(y_plot));
1406
       lcd_put_wchar(')');
1406
       lcd_put_wchar(')');
1407
 
1407
 
1408
       #if LCD_HEIGHT <= 3   // 16x2 or 20x2 display
1408
       #if LCD_HEIGHT <= 3   // 16x2 or 20x2 display
1411
          * Print Z values
1411
          * Print Z values
1412
          */
1412
          */
1413
         _ZLABEL(_LCD_W_POS, 1);
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
         else
1416
         else
1417
           lcd_put_u8str_P(PSTR(" -----"));
1417
           lcd_put_u8str_P(PSTR(" -----"));
1418
 
1418
 
1422
          * Show all values at right of screen
1422
          * Show all values at right of screen
1423
          */
1423
          */
1424
         _XLABEL(_LCD_W_POS, 1);
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
         _YLABEL(_LCD_W_POS, 2);
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
          * Show the location value
1430
          * Show the location value
1431
          */
1431
          */
1432
         _ZLABEL(_LCD_W_POS, 3);
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
         else
1435
         else
1436
           lcd_put_u8str_P(PSTR(" -----"));
1436
           lcd_put_u8str_P(PSTR(" -----"));
1437
 
1437
 

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

22
 
22
 
23
 int lcd_glyph_height(void) { return u8g_GetFontBBXHeight(u8g.getU8g()); }
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
 void lcd_put_int(const int i) { u8g.print(i); }
27
 void lcd_put_int(const int i) { u8g.print(i); }
28
 
28
 
33
     u8g.print((char)c);
33
     u8g.print((char)c);
34
     return u8g_GetFontBBXWidth(u8g.getU8g());
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
   u8g.setPrintPos(x + ret, y);
38
   u8g.setPrintPos(x + ret, y);
40
-
41
   return ret;
39
   return ret;
42
 }
40
 }
43
 
41
 
44
 int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
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
   u8g.setPrintPos(x + ret, y);
45
   u8g.setPrintPos(x + ret, y);
49
   return ret;
46
   return ret;
50
 }
47
 }
51
 
48
 
52
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
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
   u8g.setPrintPos(x + ret, y);
52
   u8g.setPrintPos(x + ret, y);
57
   return ret;
53
   return ret;
58
 }
54
 }

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

108
     // Draws a slice of a particular frame of the custom bootscreen, without the u8g loop
108
     // Draws a slice of a particular frame of the custom bootscreen, without the u8g loop
109
     void MarlinUI::draw_custom_bootscreen(const uint8_t frame/*=0*/) {
109
     void MarlinUI::draw_custom_bootscreen(const uint8_t frame/*=0*/) {
110
       constexpr u8g_uint_t left = u8g_uint_t((LCD_PIXEL_WIDTH  - (CUSTOM_BOOTSCREEN_BMPWIDTH)) / 2),
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
       #if ENABLED(CUSTOM_BOOTSCREEN_INVERTED)
112
       #if ENABLED(CUSTOM_BOOTSCREEN_INVERTED)
113
         constexpr u8g_uint_t right = left + CUSTOM_BOOTSCREEN_BMPWIDTH,
113
         constexpr u8g_uint_t right = left + CUSTOM_BOOTSCREEN_BMPWIDTH,
114
                             bottom = top + CUSTOM_BOOTSCREEN_BMPHEIGHT;
114
                             bottom = top + CUSTOM_BOOTSCREEN_BMPHEIGHT;
160
   // Draws a slice of the Marlin bootscreen, without the u8g loop
160
   // Draws a slice of the Marlin bootscreen, without the u8g loop
161
   void MarlinUI::draw_marlin_bootscreen() {
161
   void MarlinUI::draw_marlin_bootscreen() {
162
     // Screen dimensions.
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
     // Determine text space needed
166
     // Determine text space needed
167
     #ifndef STRING_SPLASH_LINE2
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
     #else
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
     #endif
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
     // Can the text fit to the right of the bitmap?
181
     // Can the text fit to the right of the bitmap?
182
     if (text_max_width < rspace) {
182
     if (text_max_width < rspace) {
299
   #if ENABLED(LIGHTWEIGHT_UI)
299
   #if ENABLED(LIGHTWEIGHT_UI)
300
     ST7920_Lite_Status_Screen::clear_text_buffer();
300
     ST7920_Lite_Status_Screen::clear_text_buffer();
301
   #endif
301
   #endif
302
-  const uint8_t h4 = u8g.getHeight() / 4;
302
+  const u8g_uint_t h4 = u8g.getHeight() / 4;
303
   u8g.firstPage();
303
   u8g.firstPage();
304
   do {
304
   do {
305
     set_font(FONT_MENU);
305
     set_font(FONT_MENU);
316
 
316
 
317
 #if HAS_LCD_MENU
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
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
321
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
322
 
322
 
373
 
373
 
374
     if (mark_as_selected(row, invert)) {
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
       if (center && !valstr) {
378
       if (center && !valstr) {
379
         int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
379
         int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
390
     UNUSED(pre_char);
390
     UNUSED(pre_char);
391
 
391
 
392
     if (mark_as_selected(row, sel)) {
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
       n -= lcd_put_u8str_max_P(pstr, n);
394
       n -= lcd_put_u8str_max_P(pstr, n);
395
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
395
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
396
       lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2);
396
       lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2);
403
   void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) {
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
     if (mark_as_selected(row, sel)) {
404
     if (mark_as_selected(row, sel)) {
405
       const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data));
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
       n -= lcd_put_u8str_max_P(pstr, n);
407
       n -= lcd_put_u8str_max_P(pstr, n);
408
       lcd_put_wchar(':');
408
       lcd_put_wchar(':');
409
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
409
       while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
415
   void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
415
   void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
416
     ui.encoder_direction_normal();
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
     bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
419
     bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
420
 
420
 
421
     #if ENABLED(USE_BIG_EDIT_FONT)
421
     #if ENABLED(USE_BIG_EDIT_FONT)
422
       // Use the menu font if the label won't fit on a single line
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
       if (labellen <= lcd_edit_width - 1) {
425
       if (labellen <= lcd_edit_width - 1) {
426
         if (labellen + vallen + 1 > lcd_edit_width) extra_row = true;
426
         if (labellen + vallen + 1 > lcd_edit_width) extra_row = true;
427
         lcd_chr_fit = lcd_edit_width + 1;
427
         lcd_chr_fit = lcd_edit_width + 1;
434
         ui.set_font(FONT_MENU);
434
         ui.set_font(FONT_MENU);
435
       }
435
       }
436
     #else
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
     #endif
439
     #endif
440
 
440
 
441
     // Center the label and value lines on the middle line
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
     // Assume the label is alpha-numeric (with a descender)
445
     // Assume the label is alpha-numeric (with a descender)
446
     bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
446
     bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
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
     if (inv) {
471
     if (inv) {
472
       u8g.setColorIndex(1);
472
       u8g.setColorIndex(1);
473
       u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
473
       u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
492
       if (mark_as_selected(row, sel)) {
492
       if (mark_as_selected(row, sel)) {
493
         if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
493
         if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
494
         constexpr uint8_t maxlen = LCD_WIDTH - 1;
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
         while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
497
         while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
498
       }
498
       }
499
     }
499
     }
512
 
512
 
513
     void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
513
     void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
514
       // Scale the box pixels appropriately
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
               pixels_per_x_mesh_pnt = x_map_pixels / (GRID_MAX_POINTS_X),
518
               pixels_per_x_mesh_pnt = x_map_pixels / (GRID_MAX_POINTS_X),
519
               pixels_per_y_mesh_pnt = y_map_pixels / (GRID_MAX_POINTS_Y),
519
               pixels_per_y_mesh_pnt = y_map_pixels / (GRID_MAX_POINTS_Y),
535
       // Display Mesh Point Locations
535
       // Display Mesh Point Locations
536
 
536
 
537
       u8g.setColorIndex(1);
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
       for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt)
540
       for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt)
541
         if (PAGE_CONTAINS(y, y))
541
         if (PAGE_CONTAINS(y, y))
542
           for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt)
542
           for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt)
544
 
544
 
545
       // Fill in the Specified Mesh Point
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
       if (PAGE_CONTAINS(by, by + pixels_per_y_mesh_pnt))
551
       if (PAGE_CONTAINS(by, by + pixels_per_y_mesh_pnt))
552
         u8g.drawBox(
552
         u8g.drawBox(
553
           x_offset + x_plot * pixels_per_x_mesh_pnt, by,
553
           x_offset + x_plot * pixels_per_x_mesh_pnt, by,

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

14
 
14
 
15
 #if HAS_GRAPHICAL_LCD
15
 #if HAS_GRAPHICAL_LCD
16
   #include "dogm/u8g_fontutf8.h"
16
   #include "dogm/u8g_fontutf8.h"
17
+  typedef u8g_uint_t lcd_uint_t;
17
 #else
18
 #else
18
   #define _UxGT(a) a
19
   #define _UxGT(a) a
20
+  typedef uint8_t lcd_uint_t;
19
 #endif
21
 #endif
20
 
22
 
21
 #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
23
 #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
48
  */
50
  */
49
 int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
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
 void lcd_put_int(const int i);
55
 void lcd_put_int(const int i);
54
 
56
 

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

37
                custom_hotend_temp = 190,
37
                custom_hotend_temp = 190,
38
                side_points = 3,
38
                side_points = 3,
39
                ubl_fillin_amount = 5,
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
 #if HAS_HEATED_BED
44
 #if HAS_HEATED_BED
46
   static int16_t custom_bed_temp = 50;
45
   static int16_t custom_bed_temp = 50;
423
   char ubl_lcd_gcode[50], str[10], str2[10];
422
   char ubl_lcd_gcode[50], str[10], str2[10];
424
   dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
423
   dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
425
   dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
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
   lcd_enqueue_one_now(ubl_lcd_gcode);
426
   lcd_enqueue_one_now(ubl_lcd_gcode);
428
 }
427
 }
429
 
428
 

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

205
 
205
 
206
   #endif
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
     if (!string) return;
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
     uint8_t *p = (uint8_t*)string;
217
     uint8_t *p = (uint8_t*)string;
227
         if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
227
         if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
228
           if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
228
           if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
229
           // Past the right and the word is not too long?
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
           c += !eol;                  // +1 so the space will be printed
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
           while (c) {                 // character countdown
233
           while (c) {                 // character countdown
234
             --c;                      // count down to zero
234
             --c;                      // count down to zero
235
             wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
235
             wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
246
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
246
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
247
         if (!ch) break;
247
         if (!ch) break;
248
         lcd_put_wchar(ch);
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
   void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
255
   void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
256
     const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
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
     if (!string && plen + slen <= LCD_WIDTH) {
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
     if (string) {
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
 #endif // HAS_LCD_MENU
270
 #endif // HAS_LCD_MENU

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

76
       #define LCDWRITE(c) lcd_put_wchar(c)
76
       #define LCDWRITE(c) lcd_put_wchar(c)
77
     #endif
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
     #if ENABLED(SDSUPPORT)
85
     #if ENABLED(SDSUPPORT)
86
       #include "../sd/cardreader.h"
86
       #include "../sd/cardreader.h"
486
     #endif
486
     #endif
487
 
487
 
488
     #if ENABLED(AUTO_BED_LEVELING_UBL)
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
     #endif
490
     #endif
491
 
491
 
492
     static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
492
     static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);

Loading…
Cancel
Save