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
     #define ENCODER_PULSES_PER_STEP 1
215
     #define ENCODER_PULSES_PER_STEP 1
216
   #endif
216
   #endif
217
 
217
 
218
+  #ifndef TALL_FONT_CORRECTION
219
+    #define TALL_FONT_CORRECTION 0
220
+  #endif
221
+
218
   /**
222
   /**
219
    * START_SCREEN_OR_MENU generates init code for a screen or menu
223
    * START_SCREEN_OR_MENU generates init code for a screen or menu
220
    *
224
    *
238
 
242
 
239
   #define SCREEN_OR_MENU_LOOP() \
243
   #define SCREEN_OR_MENU_LOOP() \
240
     int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
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
       _thisItemNr = 0
246
       _thisItemNr = 0
243
 
247
 
244
   /**
248
   /**
249
    *               Scroll as-needed to keep the selected line in view.
253
    *               Scroll as-needed to keep the selected line in view.
250
    */
254
    */
251
   #define START_SCREEN() \
255
   #define START_SCREEN() \
252
-    START_SCREEN_OR_MENU(LCD_HEIGHT); \
256
+    START_SCREEN_OR_MENU(LCD_HEIGHT - TALL_FONT_CORRECTION); \
253
     encoderTopLine = encoderLine; \
257
     encoderTopLine = encoderLine; \
254
     bool _skipStatic = false; \
258
     bool _skipStatic = false; \
255
     SCREEN_OR_MENU_LOOP()
259
     SCREEN_OR_MENU_LOOP()
257
   #define START_MENU() \
261
   #define START_MENU() \
258
     START_SCREEN_OR_MENU(1); \
262
     START_SCREEN_OR_MENU(1); \
259
     NOMORE(encoderTopLine, encoderLine); \
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
     bool _skipStatic = true; \
267
     bool _skipStatic = true; \
264
     SCREEN_OR_MENU_LOOP()
268
     SCREEN_OR_MENU_LOOP()

+ 22
- 14
Marlin/ultralcd_impl_DOGM.h View File

519
 
519
 
520
   // Enable to save many cycles by drawing a hollow frame
520
   // Enable to save many cycles by drawing a hollow frame
521
   #define XYZ_HOLLOW_FRAME
521
   #define XYZ_HOLLOW_FRAME
522
+  #define MENU_HOLLOW_FRAME
522
 
523
 
523
   #if ENABLED(XYZ_HOLLOW_FRAME)
524
   #if ENABLED(XYZ_HOLLOW_FRAME)
524
     #define XYZ_FRAME_TOP 29
525
     #define XYZ_FRAME_TOP 29
525
     #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
526
     #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
526
   #else
527
   #else
527
     #define XYZ_FRAME_TOP 30
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
   #endif
530
   #endif
530
 
531
 
531
   // Before homing the axis letters are blinking 'X' <-> '?'.
532
   // Before homing the axis letters are blinking 'X' <-> '?'.
580
   // Feedrate
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
     lcd_setFont(FONT_MENU);
585
     lcd_setFont(FONT_MENU);
585
-    u8g.setPrintPos(3, 49);
586
+    u8g.setPrintPos(3, 50);
586
     lcd_print(LCD_STR_FEEDRATE[0]);
587
     lcd_print(LCD_STR_FEEDRATE[0]);
587
 
588
 
588
     lcd_setFont(FONT_STATUSMENU);
589
     lcd_setFont(FONT_STATUSMENU);
589
-    u8g.setPrintPos(12, 49);
590
+    u8g.setPrintPos(12, 50);
590
     lcd_print(itostr3(feedrate_percentage));
591
     lcd_print(itostr3(feedrate_percentage));
591
     u8g.print('%');
592
     u8g.print('%');
592
   }
593
   }
595
   // Status line
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
   if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
601
   if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
601
     u8g.setPrintPos(0, STATUS_BASELINE);
602
     u8g.setPrintPos(0, STATUS_BASELINE);
624
   // Set the colors for a menu item based on whether it is selected
625
   // Set the colors for a menu item based on whether it is selected
625
   static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
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
     if (isSelected) {
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
     u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
648
     u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
641
   }
649
   }
642
 
650
 

Loading…
Cancel
Save