|
@@ -60,18 +60,14 @@
|
60
|
60
|
#include "../../feature/bedlevel/ubl/ubl.h"
|
61
|
61
|
#endif
|
62
|
62
|
|
63
|
|
-#define FONT_SPECIAL_NAME ISO10646_1_5x7
|
64
|
|
-#define FONT_MENU_NAME ISO10646_1_5x7
|
65
|
63
|
#include "fontdata/fontdata_ISO10646_1.h"
|
66
|
64
|
#if ENABLED(USE_SMALL_INFOFONT)
|
67
|
65
|
#include "fontdata/fontdata_6x9_marlin.h"
|
68
|
66
|
#define FONT_STATUSMENU_NAME u8g_font_6x9
|
69
|
67
|
#else
|
70
|
|
- #define FONT_STATUSMENU_NAME FONT_MENU_NAME
|
|
68
|
+ #define FONT_STATUSMENU_NAME MENU_FONT_NAME
|
71
|
69
|
#endif
|
72
|
70
|
|
73
|
|
-#define START_COL 0
|
74
|
|
-
|
75
|
71
|
U8G_CLASS u8g(U8G_PARAM);
|
76
|
72
|
U8GLIB *pu8g = &u8g;
|
77
|
73
|
|
|
@@ -93,10 +89,9 @@ void lcd_setFont(const MarlinFont font_nr) {
|
93
|
89
|
if (font_nr != currentfont) {
|
94
|
90
|
switch ((currentfont = font_nr)) {
|
95
|
91
|
case FONT_STATUSMENU : u8g.setFont(FONT_STATUSMENU_NAME); break;
|
|
92
|
+ case FONT_EDIT : u8g.setFont(EDIT_FONT_NAME); break;
|
96
|
93
|
default:
|
97
|
|
- case FONT_MENU : u8g.setFont(FONT_MENU_NAME); break;
|
98
|
|
- case FONT_SPECIAL : u8g.setFont(FONT_SPECIAL_NAME); break;
|
99
|
|
- case FONT_MENU_EDIT : u8g.setFont(FONT_MENU_EDIT_NAME); break;
|
|
94
|
+ case FONT_MENU : u8g.setFont(MENU_FONT_NAME); break;
|
100
|
95
|
}
|
101
|
96
|
}
|
102
|
97
|
}
|
|
@@ -155,7 +150,7 @@ void lcd_setFont(const MarlinFont font_nr) {
|
155
|
150
|
#if ENABLED(START_BMPHIGH)
|
156
|
151
|
(LCD_PIXEL_HEIGHT - (START_BMPHEIGHT)) / 2
|
157
|
152
|
#else
|
158
|
|
- DOG_CHAR_HEIGHT
|
|
153
|
+ MENU_FONT_HEIGHT
|
159
|
154
|
#endif
|
160
|
155
|
;
|
161
|
156
|
|
|
@@ -167,13 +162,13 @@ void lcd_setFont(const MarlinFont font_nr) {
|
167
|
162
|
u8g.drawBitmapP(offx, offy, (START_BMPWIDTH + 7) / 8, START_BMPHEIGHT, start_bmp);
|
168
|
163
|
lcd_setFont(FONT_MENU);
|
169
|
164
|
#ifndef STRING_SPLASH_LINE2
|
170
|
|
- const uint8_t txt1X = width - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH);
|
171
|
|
- u8g.drawStr(txt1X, (height + DOG_CHAR_HEIGHT) / 2, STRING_SPLASH_LINE1);
|
|
165
|
+ const uint8_t txt1X = width - (sizeof(STRING_SPLASH_LINE1) - 1) * (MENU_FONT_WIDTH);
|
|
166
|
+ u8g.drawStr(txt1X, (height + MENU_FONT_HEIGHT) / 2, STRING_SPLASH_LINE1);
|
172
|
167
|
#else
|
173
|
|
- const uint8_t txt1X = (width - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2,
|
174
|
|
- txt2X = (width - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
175
|
|
- u8g.drawStr(txt1X, height - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
|
176
|
|
- u8g.drawStr(txt2X, height - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
|
|
168
|
+ const uint8_t txt1X = (width - (sizeof(STRING_SPLASH_LINE1) - 1) * (MENU_FONT_WIDTH)) / 2,
|
|
169
|
+ txt2X = (width - (sizeof(STRING_SPLASH_LINE2) - 1) * (MENU_FONT_WIDTH)) / 2;
|
|
170
|
+ u8g.drawStr(txt1X, height - (MENU_FONT_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
|
|
171
|
+ u8g.drawStr(txt2X, height - (MENU_FONT_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
|
177
|
172
|
#endif
|
178
|
173
|
} while (u8g.nextPage());
|
179
|
174
|
safe_delay(BOOTSCREEN_TIMEOUT);
|
|
@@ -252,12 +247,12 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
252
|
247
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
253
|
248
|
|
254
|
249
|
void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
|
255
|
|
- row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
|
256
|
|
- row_y2 = row_y1 + DOG_CHAR_HEIGHT - 1;
|
|
250
|
+ row_y1 = row * (MENU_FONT_HEIGHT) + 1;
|
|
251
|
+ row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
|
257
|
252
|
|
258
|
253
|
if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return;
|
259
|
254
|
|
260
|
|
- lcd_moveto(LCD_PIXEL_WIDTH - 11 * (DOG_CHAR_WIDTH), row_y2);
|
|
255
|
+ lcd_moveto(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2);
|
261
|
256
|
lcd_put_wchar('E');
|
262
|
257
|
lcd_put_wchar((char)('1' + extruder));
|
263
|
258
|
lcd_put_wchar(' ');
|
|
@@ -272,8 +267,8 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
272
|
267
|
|
273
|
268
|
// Set the colors for a menu item based on whether it is selected
|
274
|
269
|
static bool mark_as_selected(const uint8_t row, const bool isSelected) {
|
275
|
|
- row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
|
276
|
|
- row_y2 = row_y1 + DOG_CHAR_HEIGHT - 1;
|
|
270
|
+ row_y1 = row * (MENU_FONT_HEIGHT) + 1;
|
|
271
|
+ row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
|
277
|
272
|
|
278
|
273
|
if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return false;
|
279
|
274
|
|
|
@@ -283,7 +278,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
283
|
278
|
u8g.drawHLine(0, row_y2 + 2, LCD_PIXEL_WIDTH);
|
284
|
279
|
#else
|
285
|
280
|
u8g.setColorIndex(1); // black on white
|
286
|
|
- u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT - 1);
|
|
281
|
+ u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
|
287
|
282
|
u8g.setColorIndex(0); // white on black
|
288
|
283
|
#endif
|
289
|
284
|
}
|
|
@@ -295,7 +290,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
295
|
290
|
|
296
|
291
|
if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
|
297
|
292
|
|
298
|
|
- lcd_moveto((START_COL) * (DOG_CHAR_WIDTH), row_y2);
|
|
293
|
+ lcd_moveto(0, row_y2);
|
299
|
294
|
return true;
|
300
|
295
|
}
|
301
|
296
|
|
|
@@ -304,7 +299,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
304
|
299
|
|
305
|
300
|
if (mark_as_selected(row, invert)) {
|
306
|
301
|
|
307
|
|
- uint8_t n = LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * (START_COL); // pixel width of string allowed
|
|
302
|
+ uint8_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
|
308
|
303
|
|
309
|
304
|
if (center && !valstr) {
|
310
|
305
|
int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
|
|
@@ -315,7 +310,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
315
|
310
|
n -= lcd_put_u8str_max(valstr, n);
|
316
|
311
|
}
|
317
|
312
|
|
318
|
|
- while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
|
313
|
+ while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
319
|
314
|
}
|
320
|
315
|
}
|
321
|
316
|
|
|
@@ -324,11 +319,11 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
324
|
319
|
UNUSED(pre_char);
|
325
|
320
|
|
326
|
321
|
if (mark_as_selected(row, isSelected)) {
|
327
|
|
- uint8_t n = LCD_WIDTH - (START_COL) - 2;
|
328
|
|
- n *= DOG_CHAR_WIDTH;
|
|
322
|
+ uint8_t n = LCD_WIDTH - 2;
|
|
323
|
+ n *= MENU_FONT_WIDTH;
|
329
|
324
|
n -= lcd_put_u8str_max_P(pstr, n);
|
330
|
|
- while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
331
|
|
- lcd_moveto(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), row_y2);
|
|
325
|
+ while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
|
326
|
+ lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2);
|
332
|
327
|
lcd_put_wchar(post_char);
|
333
|
328
|
lcd_put_wchar(' ');
|
334
|
329
|
}
|
|
@@ -338,60 +333,62 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
338
|
333
|
void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
|
339
|
334
|
if (mark_as_selected(row, isSelected)) {
|
340
|
335
|
const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data));
|
341
|
|
- uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
|
342
|
|
- n *= DOG_CHAR_WIDTH;
|
|
336
|
+ uint8_t n = LCD_WIDTH - 2 - vallen;
|
|
337
|
+ n *= MENU_FONT_WIDTH;
|
343
|
338
|
n -= lcd_put_u8str_max_P(pstr, n);
|
344
|
339
|
lcd_put_wchar(':');
|
345
|
|
- while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
346
|
|
- lcd_moveto(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, row_y2);
|
|
340
|
+ while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
|
341
|
+ lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH) * vallen, row_y2);
|
347
|
342
|
if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str((char*)data);
|
348
|
343
|
}
|
349
|
344
|
}
|
350
|
345
|
|
351
|
346
|
void lcd_implementation_drawedit(PGM_P const pstr, const char* const value/*=NULL*/) {
|
352
|
|
- const uint8_t labellen = utf8_strlen_P(pstr),
|
353
|
|
- vallen = utf8_strlen(value);
|
|
347
|
+ const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value);
|
354
|
348
|
|
355
|
|
- uint8_t rows = (labellen > LCD_WIDTH - 2 - vallen) ? 2 : 1;
|
|
349
|
+ bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
|
356
|
350
|
|
357
|
351
|
#if ENABLED(USE_BIG_EDIT_FONT)
|
358
|
|
- constexpr uint8_t lcd_width_edit = (LCD_PIXEL_WIDTH) / (DOG_CHAR_WIDTH_EDIT);
|
359
|
|
-
|
360
|
|
- uint8_t lcd_width, char_width;
|
361
|
|
- if (labellen <= lcd_width_edit - 1) {
|
362
|
|
- if (labellen + vallen + 2 >= lcd_width_edit) rows = 2;
|
363
|
|
- lcd_width = lcd_width_edit + 1;
|
364
|
|
- char_width = DOG_CHAR_WIDTH_EDIT;
|
365
|
|
- lcd_setFont(FONT_MENU_EDIT);
|
|
352
|
+ // Use the menu font if the label won't fit on a single line
|
|
353
|
+ constexpr uint8_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH);
|
|
354
|
+ uint8_t lcd_chr_fit, one_chr_width;
|
|
355
|
+ if (labellen <= lcd_edit_width - 1) {
|
|
356
|
+ if (labellen + vallen + 1 > lcd_edit_width) extra_row = true;
|
|
357
|
+ lcd_chr_fit = lcd_edit_width + 1;
|
|
358
|
+ one_chr_width = EDIT_FONT_WIDTH;
|
|
359
|
+ lcd_setFont(FONT_EDIT);
|
366
|
360
|
}
|
367
|
361
|
else {
|
368
|
|
- lcd_width = LCD_WIDTH - (START_COL);
|
369
|
|
- char_width = DOG_CHAR_WIDTH;
|
|
362
|
+ lcd_chr_fit = LCD_WIDTH;
|
|
363
|
+ one_chr_width = MENU_FONT_WIDTH;
|
370
|
364
|
lcd_setFont(FONT_MENU);
|
371
|
365
|
}
|
372
|
366
|
#else
|
373
|
|
- constexpr uint8_t lcd_width = LCD_WIDTH - (START_COL),
|
374
|
|
- char_width = DOG_CHAR_WIDTH;
|
|
367
|
+ constexpr uint8_t lcd_chr_fit = LCD_WIDTH,
|
|
368
|
+ one_chr_width = MENU_FONT_WIDTH;
|
375
|
369
|
#endif
|
376
|
370
|
|
377
|
|
- // Center either one or two rows
|
378
|
|
- const uint8_t segmentHeight = u8g.getHeight() / (rows + 1); // 1 / (rows+1) = 1/2 or 1/3
|
379
|
|
- uint8_t baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2;
|
|
371
|
+ // Center the label and value lines on the middle line
|
|
372
|
+ uint8_t baseline = extra_row ? (LCD_PIXEL_HEIGHT) / 2
|
|
373
|
+ : (LCD_PIXEL_HEIGHT + EDIT_FONT_ASCENT) / 2;
|
380
|
374
|
|
381
|
|
- bool onpage = PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline);
|
|
375
|
+ // Assume the label is alpha-numeric (with a descender)
|
|
376
|
+ bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
|
382
|
377
|
if (onpage) {
|
383
|
378
|
lcd_moveto(0, baseline);
|
384
|
379
|
lcd_put_u8str_P(pstr);
|
385
|
380
|
}
|
386
|
381
|
|
|
382
|
+ // If a value is included, print a colon, then print the value right-justified
|
387
|
383
|
if (value != NULL) {
|
388
|
384
|
lcd_put_wchar(':');
|
389
|
|
- if (rows == 2) {
|
390
|
|
- baseline += segmentHeight;
|
391
|
|
- onpage = PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline);
|
|
385
|
+ if (extra_row) {
|
|
386
|
+ // Assume the value is numeric (with no descender)
|
|
387
|
+ baseline += EDIT_FONT_ASCENT;
|
|
388
|
+ onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
|
392
|
389
|
}
|
393
|
390
|
if (onpage) {
|
394
|
|
- lcd_moveto(((lcd_width - 1) - (vallen + 1)) * char_width, baseline); // Right-justified, leaving padded by spaces
|
|
391
|
+ lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
|
395
|
392
|
lcd_put_wchar(' '); // overwrite char if value gets shorter
|
396
|
393
|
lcd_put_u8str(value);
|
397
|
394
|
}
|
|
@@ -407,7 +404,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
407
|
404
|
|
408
|
405
|
if (!PAGE_CONTAINS(row_y1, row_y2)) return;
|
409
|
406
|
|
410
|
|
- constexpr uint8_t maxlen = LCD_WIDTH - (START_COL) - 1;
|
|
407
|
+ constexpr uint8_t maxlen = LCD_WIDTH - 1;
|
411
|
408
|
const char *outstr = theCard.longest_filename();
|
412
|
409
|
if (theCard.longFilename[0]) {
|
413
|
410
|
#if ENABLED(SCROLL_LONG_FILENAMES)
|
|
@@ -432,9 +429,9 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
432
|
429
|
if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
|
433
|
430
|
|
434
|
431
|
int n;
|
435
|
|
- n = lcd_put_u8str_max(outstr, maxlen * (DOG_CHAR_WIDTH));
|
436
|
|
- n = maxlen * (DOG_CHAR_WIDTH) - n;
|
437
|
|
- while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
|
432
|
+ n = lcd_put_u8str_max(outstr, maxlen * (MENU_FONT_WIDTH));
|
|
433
|
+ n = maxlen * (MENU_FONT_WIDTH) - n;
|
|
434
|
+ while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
|
438
|
435
|
}
|
439
|
436
|
|
440
|
437
|
#endif // SDSUPPORT
|