|
@@ -54,6 +54,7 @@
|
54
|
54
|
#include "_Bootscreen.h"
|
55
|
55
|
#endif
|
56
|
56
|
|
|
57
|
+// Only Western languages support big / small fonts
|
57
|
58
|
#if DISABLED(DISPLAY_CHARSET_ISO10646_1)
|
58
|
59
|
#undef USE_BIG_EDIT_FONT
|
59
|
60
|
#undef USE_SMALL_INFOFONT
|
|
@@ -122,7 +123,7 @@
|
122
|
123
|
#if ENABLED(USE_BIG_EDIT_FONT)
|
123
|
124
|
#define FONT_MENU_EDIT_NAME u8g_font_9x18
|
124
|
125
|
#define DOG_CHAR_WIDTH_EDIT 9
|
125
|
|
- #define DOG_CHAR_HEIGHT_EDIT 18
|
|
126
|
+ #define DOG_CHAR_HEIGHT_EDIT 13
|
126
|
127
|
#define LCD_WIDTH_EDIT 14
|
127
|
128
|
#else
|
128
|
129
|
#define FONT_MENU_EDIT_NAME FONT_MENU_NAME
|
|
@@ -183,6 +184,13 @@
|
183
|
184
|
int lcd_contrast;
|
184
|
185
|
static char currentfont = 0;
|
185
|
186
|
|
|
187
|
+// The current graphical page being rendered
|
|
188
|
+u8g_page_t &page = ((u8g_pb_t *)((u8g.getU8g())->dev->dev_mem))->p;
|
|
189
|
+
|
|
190
|
+// For selective rendering within a Y range
|
|
191
|
+#define PAGE_UNDER(yb) (u8g.getU8g()->current_page.y0 <= (yb))
|
|
192
|
+#define PAGE_CONTAINS(ya, yb) (PAGE_UNDER(yb) && u8g.getU8g()->current_page.y1 >= (ya))
|
|
193
|
+
|
186
|
194
|
static void lcd_setFont(char font_nr) {
|
187
|
195
|
switch(font_nr) {
|
188
|
196
|
case FONT_STATUSMENU : {u8g.setFont(FONT_STATUSMENU_NAME); currentfont = FONT_STATUSMENU;}; break;
|
|
@@ -321,19 +329,23 @@ FORCE_INLINE void _draw_heater_status(int x, int heater) {
|
321
|
329
|
const bool isBed = false;
|
322
|
330
|
#endif
|
323
|
331
|
|
324
|
|
- _draw_centered_temp((isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater)) + 0.5, x, 7);
|
|
332
|
+ if (PAGE_UNDER(7))
|
|
333
|
+ _draw_centered_temp((isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater)) + 0.5, x, 7);
|
325
|
334
|
|
326
|
|
- _draw_centered_temp((isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)) + 0.5, x, 28);
|
|
335
|
+ if (PAGE_CONTAINS(21, 28))
|
|
336
|
+ _draw_centered_temp((isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)) + 0.5, x, 28);
|
327
|
337
|
|
328
|
|
- int h = isBed ? 7 : 8,
|
329
|
|
- y = isBed ? 18 : 17;
|
330
|
|
- if (isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater)) {
|
331
|
|
- u8g.setColorIndex(0); // white on black
|
332
|
|
- u8g.drawBox(x + h, y, 2, 2);
|
333
|
|
- u8g.setColorIndex(1); // black on white
|
334
|
|
- }
|
335
|
|
- else {
|
336
|
|
- u8g.drawBox(x + h, y, 2, 2);
|
|
338
|
+ if (PAGE_CONTAINS(17, 20)) {
|
|
339
|
+ uint8_t h = isBed ? 7 : 8,
|
|
340
|
+ y = isBed ? 18 : 17;
|
|
341
|
+ if (isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater)) {
|
|
342
|
+ u8g.setColorIndex(0); // white on black
|
|
343
|
+ u8g.drawBox(x + h, y, 2, 2);
|
|
344
|
+ u8g.setColorIndex(1); // black on white
|
|
345
|
+ }
|
|
346
|
+ else {
|
|
347
|
+ u8g.drawBox(x + h, y, 2, 2);
|
|
348
|
+ }
|
337
|
349
|
}
|
338
|
350
|
}
|
339
|
351
|
|
|
@@ -357,49 +369,107 @@ FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink)
|
357
|
369
|
//#define DOGM_SD_PERCENT
|
358
|
370
|
|
359
|
371
|
static void lcd_implementation_status_screen() {
|
360
|
|
- u8g.setColorIndex(1); // black on white
|
361
|
372
|
|
362
|
373
|
bool blink = lcd_blink();
|
363
|
374
|
|
364
|
|
- // Symbols menu graphics, animated fan
|
365
|
|
- u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT,
|
366
|
|
- #if HAS_FAN0
|
367
|
|
- blink && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp
|
368
|
|
- #else
|
369
|
|
- status_screen0_bmp
|
370
|
|
- #endif
|
371
|
|
- );
|
|
375
|
+ // Black color, white background
|
|
376
|
+ u8g.setColorIndex(1);
|
372
|
377
|
|
373
|
|
- // Status Menu Font for SD info, Heater status, Fan, XYZ
|
|
378
|
+ // Status Menu Font
|
374
|
379
|
lcd_setFont(FONT_STATUSMENU);
|
375
|
380
|
|
|
381
|
+ //
|
|
382
|
+ // Fan Animation
|
|
383
|
+ //
|
|
384
|
+
|
|
385
|
+ if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) {
|
|
386
|
+
|
|
387
|
+ u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT,
|
|
388
|
+ #if HAS_FAN0
|
|
389
|
+ blink && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp
|
|
390
|
+ #else
|
|
391
|
+ status_screen0_bmp
|
|
392
|
+ #endif
|
|
393
|
+ );
|
|
394
|
+
|
|
395
|
+ }
|
|
396
|
+
|
|
397
|
+ //
|
|
398
|
+ // Temperature Graphics and Info
|
|
399
|
+ //
|
|
400
|
+
|
|
401
|
+ if (PAGE_UNDER(28)) {
|
|
402
|
+ // Extruders
|
|
403
|
+ HOTEND_LOOP() _draw_heater_status(5 + e * 25, e);
|
|
404
|
+
|
|
405
|
+ // Heated bed
|
|
406
|
+ #if HOTENDS < 4 && HAS_TEMP_BED
|
|
407
|
+ _draw_heater_status(81, -1);
|
|
408
|
+ #endif
|
|
409
|
+
|
|
410
|
+ if (PAGE_CONTAINS(20, 27)) {
|
|
411
|
+ // Fan
|
|
412
|
+ u8g.setPrintPos(104, 27);
|
|
413
|
+ #if HAS_FAN0
|
|
414
|
+ int per = ((fanSpeeds[0] + 1) * 100) / 256;
|
|
415
|
+ if (per) {
|
|
416
|
+ lcd_print(itostr3(per));
|
|
417
|
+ u8g.print('%');
|
|
418
|
+ }
|
|
419
|
+ #endif
|
|
420
|
+ }
|
|
421
|
+ }
|
|
422
|
+
|
376
|
423
|
#if ENABLED(SDSUPPORT)
|
|
424
|
+
|
|
425
|
+ //
|
377
|
426
|
// SD Card Symbol
|
378
|
|
- u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7);
|
379
|
|
- u8g.drawBox(50, 44 - (TALL_FONT_CORRECTION), 2, 5);
|
380
|
|
- u8g.drawFrame(42, 49 - (TALL_FONT_CORRECTION), 10, 4);
|
381
|
|
- u8g.drawPixel(50, 43 - (TALL_FONT_CORRECTION));
|
|
427
|
+ //
|
|
428
|
+
|
|
429
|
+ if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
|
|
430
|
+ // Upper box
|
|
431
|
+ u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7); // 42-48 (or 41-47)
|
|
432
|
+ // Right edge
|
|
433
|
+ u8g.drawBox(50, 44 - (TALL_FONT_CORRECTION), 2, 5); // 44-48 (or 43-47)
|
|
434
|
+ // Bottom hollow box
|
|
435
|
+ u8g.drawFrame(42, 49 - (TALL_FONT_CORRECTION), 10, 4); // 49-52 (or 48-51)
|
|
436
|
+ // Corner pixel
|
|
437
|
+ u8g.drawPixel(50, 43 - (TALL_FONT_CORRECTION)); // 43 (or 42)
|
|
438
|
+ }
|
382
|
439
|
|
|
440
|
+ //
|
383
|
441
|
// Progress bar frame
|
384
|
|
- u8g.drawFrame(54, 49, 73, 4 - (TALL_FONT_CORRECTION));
|
|
442
|
+ //
|
|
443
|
+
|
|
444
|
+ if (PAGE_CONTAINS(49, 52 - (TALL_FONT_CORRECTION)))
|
|
445
|
+ u8g.drawFrame(54, 49, 73, 4 - (TALL_FONT_CORRECTION)); // 49-52 (or 49-51)
|
385
|
446
|
|
386
|
|
- // SD Card Progress bar and clock
|
387
|
447
|
if (IS_SD_PRINTING) {
|
|
448
|
+
|
|
449
|
+ //
|
388
|
450
|
// Progress bar solid part
|
389
|
|
- u8g.drawBox(55, 50, (unsigned int)(71 * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION));
|
390
|
|
-
|
|
451
|
+ //
|
|
452
|
+
|
|
453
|
+ if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION)))
|
|
454
|
+ u8g.drawBox(55, 50, (unsigned int)(71 * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION));
|
|
455
|
+
|
|
456
|
+ //
|
|
457
|
+ // SD Percent Complete
|
|
458
|
+ //
|
|
459
|
+
|
391
|
460
|
#if ENABLED(DOGM_SD_PERCENT)
|
392
|
|
- // Percent complete
|
393
|
|
- u8g.setPrintPos(55, 48);
|
394
|
|
- u8g.print(itostr3(card.percentDone()));
|
395
|
|
- u8g.print('%');
|
|
461
|
+ if (PAGE_CONTAINS(41, 48)) {
|
|
462
|
+ // Percent complete
|
|
463
|
+ u8g.setPrintPos(55, 48);
|
|
464
|
+ u8g.print(itostr3(card.percentDone()));
|
|
465
|
+ u8g.print('%');
|
|
466
|
+ }
|
396
|
467
|
#endif
|
397
|
468
|
}
|
398
|
469
|
|
399
|
|
- char buffer[10];
|
400
|
|
- duration_t elapsed = print_job_timer.duration();
|
401
|
|
- bool has_days = (elapsed.value > 60*60*24L);
|
402
|
|
- elapsed.toDigital(buffer, has_days);
|
|
470
|
+ //
|
|
471
|
+ // Elapsed Time
|
|
472
|
+ //
|
403
|
473
|
|
404
|
474
|
#if DISABLED(DOGM_SD_PERCENT)
|
405
|
475
|
#define SD_DURATION_X 71
|
|
@@ -407,104 +477,156 @@ static void lcd_implementation_status_screen() {
|
407
|
477
|
#define SD_DURATION_X 89
|
408
|
478
|
#endif
|
409
|
479
|
|
410
|
|
- u8g.setPrintPos(SD_DURATION_X + (has_days ? 0 : 9), 48);
|
411
|
|
- lcd_print(buffer);
|
|
480
|
+ if (PAGE_CONTAINS(41, 48)) {
|
|
481
|
+
|
|
482
|
+ char buffer[10];
|
|
483
|
+ duration_t elapsed = print_job_timer.duration();
|
|
484
|
+ bool has_days = (elapsed.value > 60*60*24L);
|
|
485
|
+ elapsed.toDigital(buffer, has_days);
|
|
486
|
+
|
|
487
|
+ u8g.setPrintPos(SD_DURATION_X + (has_days ? 0 : 9), 48);
|
|
488
|
+ lcd_print(buffer);
|
|
489
|
+ }
|
412
|
490
|
|
413
|
491
|
#endif
|
414
|
492
|
|
415
|
|
- // Extruders
|
416
|
|
- HOTEND_LOOP() _draw_heater_status(5 + e * 25, e);
|
|
493
|
+ //
|
|
494
|
+ // XYZ Coordinates
|
|
495
|
+ //
|
417
|
496
|
|
418
|
|
- // Heated bed
|
419
|
|
- #if HOTENDS < 4 && HAS_TEMP_BED
|
420
|
|
- _draw_heater_status(81, -1);
|
|
497
|
+ #if ENABLED(USE_SMALL_INFOFONT)
|
|
498
|
+ #define INFO_FONT_HEIGHT 7
|
|
499
|
+ #else
|
|
500
|
+ #define INFO_FONT_HEIGHT 8
|
421
|
501
|
#endif
|
422
|
502
|
|
423
|
|
- // Fan
|
424
|
|
- u8g.setPrintPos(104, 27);
|
425
|
|
- #if HAS_FAN0
|
426
|
|
- int per = ((fanSpeeds[0] + 1) * 100) / 256;
|
427
|
|
- if (per) {
|
428
|
|
- lcd_print(itostr3(per));
|
429
|
|
- u8g.print('%');
|
430
|
|
- }
|
|
503
|
+ #define XYZ_BASELINE (30 + INFO_FONT_HEIGHT)
|
|
504
|
+
|
|
505
|
+ #define X_LABEL_POS 3
|
|
506
|
+ #define X_VALUE_POS 11
|
|
507
|
+ #define XYZ_SPACING 40
|
|
508
|
+
|
|
509
|
+ // Enable to save many cycles by drawing a hollow frame
|
|
510
|
+ #define XYZ_HOLLOW_FRAME
|
|
511
|
+
|
|
512
|
+ #if ENABLED(XYZ_HOLLOW_FRAME)
|
|
513
|
+ #define XYZ_FRAME_TOP 29
|
|
514
|
+ #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
|
|
515
|
+ #else
|
|
516
|
+ #define XYZ_FRAME_TOP 30
|
|
517
|
+ #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 2
|
431
|
518
|
#endif
|
432
|
519
|
|
433
|
|
- // X, Y, Z-Coordinates
|
434
|
520
|
// Before homing the axis letters are blinking 'X' <-> '?'.
|
435
|
521
|
// When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
|
436
|
522
|
// When everything is ok you see a constant 'X'.
|
437
|
|
- #define XYZ_BASELINE 38
|
438
|
523
|
|
439
|
|
- #if ENABLED(USE_SMALL_INFOFONT)
|
440
|
|
- u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 10);
|
441
|
|
- #else
|
442
|
|
- u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 9);
|
443
|
|
- #endif
|
444
|
|
- u8g.setColorIndex(0); // white on black
|
|
524
|
+ static char xstring[5], ystring[5], zstring[7];
|
445
|
525
|
|
446
|
|
- u8g.setPrintPos(2, XYZ_BASELINE);
|
447
|
|
- _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
|
448
|
|
- u8g.setPrintPos(10, XYZ_BASELINE);
|
449
|
|
- lcd_print(ftostr4sign(current_position[X_AXIS]));
|
|
526
|
+ // At the first page, regenerate the XYZ strings
|
|
527
|
+ if (page.page == 0) {
|
|
528
|
+ strcpy(xstring, ftostr4sign(current_position[X_AXIS]));
|
|
529
|
+ strcpy(ystring, ftostr4sign(current_position[Y_AXIS]));
|
|
530
|
+ strcpy(zstring, ftostr52sp(current_position[Z_AXIS] + 0.00001));
|
|
531
|
+ }
|
450
|
532
|
|
451
|
|
- u8g.setPrintPos(43, XYZ_BASELINE);
|
452
|
|
- _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
|
453
|
|
- u8g.setPrintPos(51, XYZ_BASELINE);
|
454
|
|
- lcd_print(ftostr4sign(current_position[Y_AXIS]));
|
|
533
|
+ if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
|
455
|
534
|
|
456
|
|
- u8g.setPrintPos(83, XYZ_BASELINE);
|
457
|
|
- _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
|
458
|
|
- u8g.setPrintPos(91, XYZ_BASELINE);
|
459
|
|
- lcd_print(ftostr52sp(current_position[Z_AXIS] + 0.00001));
|
|
535
|
+ #if ENABLED(XYZ_HOLLOW_FRAME)
|
|
536
|
+ u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
|
|
537
|
+ #else
|
|
538
|
+ u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
|
|
539
|
+ #endif
|
460
|
540
|
|
461
|
|
- u8g.setColorIndex(1); // black on white
|
|
541
|
+ if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_HEIGHT - 1), XYZ_BASELINE)) {
|
462
|
542
|
|
|
543
|
+ #if DISABLED(XYZ_HOLLOW_FRAME)
|
|
544
|
+ u8g.setColorIndex(0); // white on black
|
|
545
|
+ #endif
|
|
546
|
+
|
|
547
|
+ u8g.setPrintPos(0 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
|
|
548
|
+ _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
|
|
549
|
+ u8g.setPrintPos(0 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
|
|
550
|
+ lcd_print(xstring);
|
|
551
|
+
|
|
552
|
+ u8g.setPrintPos(1 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
|
|
553
|
+ _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
|
|
554
|
+ u8g.setPrintPos(1 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
|
|
555
|
+ lcd_print(ystring);
|
|
556
|
+
|
|
557
|
+ u8g.setPrintPos(2 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
|
|
558
|
+ _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
|
|
559
|
+ u8g.setPrintPos(2 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
|
|
560
|
+ lcd_print(zstring);
|
|
561
|
+
|
|
562
|
+ #if DISABLED(XYZ_HOLLOW_FRAME)
|
|
563
|
+ u8g.setColorIndex(1); // black on white
|
|
564
|
+ #endif
|
|
565
|
+ }
|
|
566
|
+ }
|
|
567
|
+
|
|
568
|
+ //
|
463
|
569
|
// Feedrate
|
464
|
|
- lcd_setFont(FONT_MENU);
|
465
|
|
- u8g.setPrintPos(3, 49);
|
466
|
|
- lcd_print(LCD_STR_FEEDRATE[0]);
|
|
570
|
+ //
|
467
|
571
|
|
468
|
|
- lcd_setFont(FONT_STATUSMENU);
|
469
|
|
- u8g.setPrintPos(12, 49);
|
470
|
|
- lcd_print(itostr3(feedrate_percentage));
|
471
|
|
- u8g.print('%');
|
|
572
|
+ if (PAGE_CONTAINS(50 - INFO_FONT_HEIGHT, 49)) {
|
|
573
|
+ lcd_setFont(FONT_MENU);
|
|
574
|
+ u8g.setPrintPos(3, 49);
|
|
575
|
+ lcd_print(LCD_STR_FEEDRATE[0]);
|
472
|
576
|
|
|
577
|
+ lcd_setFont(FONT_STATUSMENU);
|
|
578
|
+ u8g.setPrintPos(12, 49);
|
|
579
|
+ lcd_print(itostr3(feedrate_percentage));
|
|
580
|
+ u8g.print('%');
|
|
581
|
+ }
|
|
582
|
+
|
|
583
|
+ //
|
473
|
584
|
// Status line
|
474
|
|
- #if ENABLED(USE_SMALL_INFOFONT)
|
475
|
|
- u8g.setPrintPos(0, 62);
|
476
|
|
- #else
|
477
|
|
- u8g.setPrintPos(0, 63);
|
478
|
|
- #endif
|
479
|
|
- #if DISABLED(FILAMENT_LCD_DISPLAY)
|
480
|
|
- lcd_print(lcd_status_message);
|
481
|
|
- #else
|
482
|
|
- if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line
|
|
585
|
+ //
|
|
586
|
+
|
|
587
|
+ #define STATUS_BASELINE (54 + INFO_FONT_HEIGHT)
|
|
588
|
+
|
|
589
|
+ if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
|
|
590
|
+ u8g.setPrintPos(0, STATUS_BASELINE);
|
|
591
|
+
|
|
592
|
+ #if DISABLED(FILAMENT_LCD_DISPLAY)
|
483
|
593
|
lcd_print(lcd_status_message);
|
484
|
|
- }
|
485
|
|
- else {
|
486
|
|
- lcd_printPGM(PSTR("dia:"));
|
487
|
|
- lcd_print(ftostr12ns(filament_width_meas));
|
488
|
|
- lcd_printPGM(PSTR(" factor:"));
|
489
|
|
- lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
|
490
|
|
- u8g.print('%');
|
491
|
|
- }
|
492
|
|
- #endif
|
|
594
|
+ #else
|
|
595
|
+ if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line
|
|
596
|
+ lcd_print(lcd_status_message);
|
|
597
|
+ }
|
|
598
|
+ else {
|
|
599
|
+ lcd_printPGM(PSTR("dia:"));
|
|
600
|
+ lcd_print(ftostr12ns(filament_width_meas));
|
|
601
|
+ lcd_printPGM(PSTR(" factor:"));
|
|
602
|
+ lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
|
|
603
|
+ u8g.print('%');
|
|
604
|
+ }
|
|
605
|
+ #endif
|
|
606
|
+ }
|
493
|
607
|
}
|
494
|
608
|
|
495
|
609
|
#if ENABLED(ULTIPANEL)
|
496
|
610
|
|
|
611
|
+ uint8_t row_y1, row_y2;
|
|
612
|
+
|
497
|
613
|
// Set the colors for a menu item based on whether it is selected
|
498
|
614
|
static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
|
|
615
|
+
|
|
616
|
+ row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
|
|
617
|
+ row_y2 = row_y1 + (DOG_CHAR_HEIGHT) - 1;
|
|
618
|
+
|
|
619
|
+ if (!PAGE_CONTAINS(row_y1 + 2 - (TALL_FONT_CORRECTION), row_y2 + 2 - (TALL_FONT_CORRECTION))) return;
|
|
620
|
+
|
499
|
621
|
if (isSelected) {
|
500
|
622
|
u8g.setColorIndex(1); // black on white
|
501
|
|
- u8g.drawBox(0, row * (DOG_CHAR_HEIGHT) + 3 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
|
|
623
|
+ u8g.drawBox(0, row_y1 + 2 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
|
502
|
624
|
u8g.setColorIndex(0); // following text must be white on black
|
503
|
625
|
}
|
504
|
626
|
else {
|
505
|
627
|
u8g.setColorIndex(1); // unmarked text is black on white
|
506
|
628
|
}
|
507
|
|
- u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
|
|
629
|
+ u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
|
508
|
630
|
}
|
509
|
631
|
|
510
|
632
|
#if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
|
|
@@ -514,6 +636,8 @@ static void lcd_implementation_status_screen() {
|
514
|
636
|
|
515
|
637
|
lcd_implementation_mark_as_selected(row, invert);
|
516
|
638
|
|
|
639
|
+ if (!PAGE_CONTAINS(row_y1, row_y2)) return;
|
|
640
|
+
|
517
|
641
|
char c;
|
518
|
642
|
int8_t n = LCD_WIDTH - (START_COL);
|
519
|
643
|
|
|
@@ -538,17 +662,17 @@ static void lcd_implementation_status_screen() {
|
538
|
662
|
static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
|
539
|
663
|
UNUSED(pre_char);
|
540
|
664
|
|
541
|
|
- char c;
|
542
|
|
- uint8_t n = LCD_WIDTH - (START_COL) - 2;
|
543
|
|
-
|
544
|
665
|
lcd_implementation_mark_as_selected(row, isSelected);
|
545
|
666
|
|
546
|
|
- while (c = pgm_read_byte(pstr)) {
|
|
667
|
+ if (!PAGE_CONTAINS(row_y1, row_y2)) return;
|
|
668
|
+
|
|
669
|
+ uint8_t n = LCD_WIDTH - (START_COL) - 2;
|
|
670
|
+ while (char c = pgm_read_byte(pstr)) {
|
547
|
671
|
n -= lcd_print_and_count(c);
|
548
|
672
|
pstr++;
|
549
|
673
|
}
|
550
|
674
|
while (n--) u8g.print(' ');
|
551
|
|
- u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
|
|
675
|
+ u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), row_y2);
|
552
|
676
|
lcd_print(post_char);
|
553
|
677
|
u8g.print(' ');
|
554
|
678
|
}
|
|
@@ -561,19 +685,21 @@ static void lcd_implementation_status_screen() {
|
561
|
685
|
|
562
|
686
|
// Draw a menu item with an editable value
|
563
|
687
|
static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
|
564
|
|
- char c;
|
565
|
|
- uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
|
566
|
|
- uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
|
567
|
688
|
|
568
|
689
|
lcd_implementation_mark_as_selected(row, isSelected);
|
569
|
690
|
|
570
|
|
- while (c = pgm_read_byte(pstr)) {
|
|
691
|
+ if (!PAGE_CONTAINS(row_y1, row_y2)) return;
|
|
692
|
+
|
|
693
|
+ const uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
|
|
694
|
+ uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
|
|
695
|
+
|
|
696
|
+ while (char c = pgm_read_byte(pstr)) {
|
571
|
697
|
n -= lcd_print_and_count(c);
|
572
|
698
|
pstr++;
|
573
|
699
|
}
|
574
|
700
|
u8g.print(':');
|
575
|
701
|
while (n--) u8g.print(' ');
|
576
|
|
- u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, (row + 1) * (DOG_CHAR_HEIGHT));
|
|
702
|
+ u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, row_y2);
|
577
|
703
|
if (pgm) lcd_printPGM(data); else lcd_print((char*)data);
|
578
|
704
|
}
|
579
|
705
|
|
|
@@ -604,33 +730,43 @@ static void lcd_implementation_status_screen() {
|
604
|
730
|
#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
|
605
|
731
|
|
606
|
732
|
void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
|
607
|
|
- uint8_t rows = 1;
|
608
|
|
- uint8_t lcd_width = LCD_WIDTH - (START_COL), char_width = DOG_CHAR_WIDTH;
|
609
|
|
- uint8_t vallen = lcd_strlen(value);
|
|
733
|
+ uint8_t lcd_width, char_width,
|
|
734
|
+ labellen = lcd_strlen_P(pstr), vallen = lcd_strlen(value),
|
|
735
|
+ rows = (labellen > LCD_WIDTH - 2 - vallen) ? 2 : 1;
|
610
|
736
|
|
611
|
737
|
#if ENABLED(USE_BIG_EDIT_FONT)
|
612
|
|
- if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
|
613
|
|
- lcd_setFont(FONT_MENU_EDIT);
|
|
738
|
+ if (labellen <= LCD_WIDTH_EDIT - 1) {
|
|
739
|
+ if (labellen >= LCD_WIDTH_EDIT - vallen) rows = 2;
|
614
|
740
|
lcd_width = LCD_WIDTH_EDIT + 1;
|
615
|
741
|
char_width = DOG_CHAR_WIDTH_EDIT;
|
616
|
|
- if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
|
|
742
|
+ lcd_setFont(FONT_MENU_EDIT);
|
617
|
743
|
}
|
618
|
744
|
else {
|
|
745
|
+ lcd_width = LCD_WIDTH - (START_COL);
|
|
746
|
+ char_width = DOG_CHAR_WIDTH;
|
619
|
747
|
lcd_setFont(FONT_MENU);
|
620
|
748
|
}
|
|
749
|
+ #else
|
|
750
|
+ lcd_width = LCD_WIDTH - (START_COL);
|
|
751
|
+ char_width = DOG_CHAR_WIDTH;
|
621
|
752
|
#endif
|
622
|
753
|
|
623
|
|
- if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
|
|
754
|
+ // Center either one or two rows
|
|
755
|
+ uint8_t segmentHeight = u8g.getHeight() / (rows + 1), // 1 / (rows+1) = 1/2 or 1/3
|
|
756
|
+ baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2;
|
624
|
757
|
|
625
|
|
- const float kHalfChar = (DOG_CHAR_HEIGHT_EDIT) / 2;
|
626
|
|
- float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
|
|
758
|
+ if (PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline)) {
|
|
759
|
+ u8g.setPrintPos(0, baseline);
|
|
760
|
+ lcd_printPGM(pstr);
|
|
761
|
+ }
|
627
|
762
|
|
628
|
|
- u8g.setPrintPos(0, rowHeight + kHalfChar);
|
629
|
|
- lcd_printPGM(pstr);
|
630
|
763
|
if (value != NULL) {
|
631
|
|
- u8g.print(':');
|
632
|
|
- u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
|
633
|
|
- lcd_print(value);
|
|
764
|
+ baseline += (rows - 1) * segmentHeight;
|
|
765
|
+ if (PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline)) {
|
|
766
|
+ u8g.print(':');
|
|
767
|
+ u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, baseline);
|
|
768
|
+ lcd_print(value);
|
|
769
|
+ }
|
634
|
770
|
}
|
635
|
771
|
}
|
636
|
772
|
|
|
@@ -638,18 +774,20 @@ static void lcd_implementation_status_screen() {
|
638
|
774
|
|
639
|
775
|
static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
|
640
|
776
|
UNUSED(pstr);
|
641
|
|
- char c;
|
642
|
|
- uint8_t n = LCD_WIDTH - (START_COL) - 1;
|
643
|
777
|
|
|
778
|
+ lcd_implementation_mark_as_selected(row, isSelected);
|
|
779
|
+
|
|
780
|
+ if (!PAGE_CONTAINS(row_y1, row_y2)) return;
|
|
781
|
+
|
|
782
|
+ uint8_t n = LCD_WIDTH - (START_COL) - 1;
|
644
|
783
|
if (longFilename[0]) {
|
645
|
784
|
filename = longFilename;
|
646
|
785
|
longFilename[n] = '\0';
|
647
|
786
|
}
|
648
|
787
|
|
649
|
|
- lcd_implementation_mark_as_selected(row, isSelected);
|
650
|
|
-
|
651
|
788
|
if (isDir) lcd_print(LCD_STR_FOLDER[0]);
|
652
|
|
- while ((c = *filename)) {
|
|
789
|
+
|
|
790
|
+ while (char c = *filename) {
|
653
|
791
|
n -= lcd_print_and_count(c);
|
654
|
792
|
filename++;
|
655
|
793
|
}
|