Browse Source

Merge pull request #5304 from AnHardt/pixel-shifting

MENU_HOLLOW_FRAME for the menu screens
Scott Lahteine 7 years ago
parent
commit
59fafb93b2
2 changed files with 30 additions and 18 deletions
  1. 8
    4
      Marlin/ultralcd.cpp
  2. 22
    14
      Marlin/ultralcd_impl_DOGM.h

+ 8
- 4
Marlin/ultralcd.cpp View File

@@ -215,6 +215,10 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
215 215
     #define ENCODER_PULSES_PER_STEP 1
216 216
   #endif
217 217
 
218
+  #ifndef TALL_FONT_CORRECTION
219
+    #define TALL_FONT_CORRECTION 0
220
+  #endif
221
+
218 222
   /**
219 223
    * START_SCREEN_OR_MENU generates init code for a screen or menu
220 224
    *
@@ -238,7 +242,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
238 242
 
239 243
   #define SCREEN_OR_MENU_LOOP() \
240 244
     int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
241
-    for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
245
+    for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT - TALL_FONT_CORRECTION; _lcdLineNr++, _menuLineNr++) { \
242 246
       _thisItemNr = 0
243 247
 
244 248
   /**
@@ -249,7 +253,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
249 253
    *               Scroll as-needed to keep the selected line in view.
250 254
    */
251 255
   #define START_SCREEN() \
252
-    START_SCREEN_OR_MENU(LCD_HEIGHT); \
256
+    START_SCREEN_OR_MENU(LCD_HEIGHT - TALL_FONT_CORRECTION); \
253 257
     encoderTopLine = encoderLine; \
254 258
     bool _skipStatic = false; \
255 259
     SCREEN_OR_MENU_LOOP()
@@ -257,8 +261,8 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
257 261
   #define START_MENU() \
258 262
     START_SCREEN_OR_MENU(1); \
259 263
     NOMORE(encoderTopLine, encoderLine); \
260
-    if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
261
-      encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
264
+    if (encoderLine >= encoderTopLine + LCD_HEIGHT - TALL_FONT_CORRECTION) { \
265
+      encoderTopLine = encoderLine - (LCD_HEIGHT - TALL_FONT_CORRECTION - 1); \
262 266
     } \
263 267
     bool _skipStatic = true; \
264 268
     SCREEN_OR_MENU_LOOP()

+ 22
- 14
Marlin/ultralcd_impl_DOGM.h View File

@@ -519,13 +519,14 @@ static void lcd_implementation_status_screen() {
519 519
 
520 520
   // Enable to save many cycles by drawing a hollow frame
521 521
   #define XYZ_HOLLOW_FRAME
522
+  #define MENU_HOLLOW_FRAME
522 523
 
523 524
   #if ENABLED(XYZ_HOLLOW_FRAME)
524 525
     #define XYZ_FRAME_TOP 29
525 526
     #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
526 527
   #else
527 528
     #define XYZ_FRAME_TOP 30
528
-    #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 2
529
+    #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
529 530
   #endif
530 531
 
531 532
   // Before homing the axis letters are blinking 'X' <-> '?'.
@@ -580,13 +581,13 @@ static void lcd_implementation_status_screen() {
580 581
   // Feedrate
581 582
   //
582 583
 
583
-  if (PAGE_CONTAINS(50 - INFO_FONT_HEIGHT, 49)) {
584
+  if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
584 585
     lcd_setFont(FONT_MENU);
585
-    u8g.setPrintPos(3, 49);
586
+    u8g.setPrintPos(3, 50);
586 587
     lcd_print(LCD_STR_FEEDRATE[0]);
587 588
 
588 589
     lcd_setFont(FONT_STATUSMENU);
589
-    u8g.setPrintPos(12, 49);
590
+    u8g.setPrintPos(12, 50);
590 591
     lcd_print(itostr3(feedrate_percentage));
591 592
     u8g.print('%');
592 593
   }
@@ -595,7 +596,7 @@ static void lcd_implementation_status_screen() {
595 596
   // Status line
596 597
   //
597 598
 
598
-  #define STATUS_BASELINE (54 + INFO_FONT_HEIGHT)
599
+  #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
599 600
 
600 601
   if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
601 602
     u8g.setPrintPos(0, STATUS_BASELINE);
@@ -624,19 +625,26 @@ static void lcd_implementation_status_screen() {
624 625
   // Set the colors for a menu item based on whether it is selected
625 626
   static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
626 627
 
627
-    row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
628
-    row_y2 = row_y1 + (DOG_CHAR_HEIGHT) - 1;
628
+    row_y1 = row * (DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION)) + 1;
629
+    row_y2 = row_y1 + (DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION)) - 1;
629 630
 
630
-    if (!PAGE_CONTAINS(row_y1 + 2 - (TALL_FONT_CORRECTION), row_y2 + 2 - (TALL_FONT_CORRECTION))) return;
631
+    if (!PAGE_CONTAINS(row_y1 + 1, row_y1 + 1 + DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION))) return;
631 632
 
632 633
     if (isSelected) {
633
-      u8g.setColorIndex(1);  // black on white
634
-      u8g.drawBox(0, row_y1 + 2 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
635
-      u8g.setColorIndex(0);  // following text must be white on black
636
-    }
637
-    else {
638
-      u8g.setColorIndex(1); // unmarked text is black on white
634
+      #if ENABLED(MENU_HOLLOW_FRAME)
635
+        u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH);
636
+        u8g.drawHLine(0, row_y1 + 1 + DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH);
637
+      #else
638
+        u8g.setColorIndex(1); // black on white
639
+        u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT - 1 + 2 * (TALL_FONT_CORRECTION));
640
+        u8g.setColorIndex(0); // white on black
641
+      #endif
639 642
     }
643
+    #if DISABLED(MENU_HOLLOW_FRAME)
644
+      else {
645
+        u8g.setColorIndex(1); // unmarked text is black on white
646
+      }
647
+    #endif
640 648
     u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
641 649
   }
642 650
 

Loading…
Cancel
Save