Browse Source

MENU_HOLLOW_FRAME for the menu screens

MENU_HOLLOW_FRAME for the menu screens and
some pixel shifting to optimize the look with tall fonts. (cn)
AnHardt 8 years ago
parent
commit
7a9fa78822
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

508
 
508
 
509
   // Enable to save many cycles by drawing a hollow frame
509
   // Enable to save many cycles by drawing a hollow frame
510
   #define XYZ_HOLLOW_FRAME
510
   #define XYZ_HOLLOW_FRAME
511
+  #define MENU_HOLLOW_FRAME
511
 
512
 
512
   #if ENABLED(XYZ_HOLLOW_FRAME)
513
   #if ENABLED(XYZ_HOLLOW_FRAME)
513
     #define XYZ_FRAME_TOP 29
514
     #define XYZ_FRAME_TOP 29
514
     #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
515
     #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
515
   #else
516
   #else
516
     #define XYZ_FRAME_TOP 30
517
     #define XYZ_FRAME_TOP 30
517
-    #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 2
518
+    #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
518
   #endif
519
   #endif
519
 
520
 
520
   // Before homing the axis letters are blinking 'X' <-> '?'.
521
   // Before homing the axis letters are blinking 'X' <-> '?'.
569
   // Feedrate
570
   // Feedrate
570
   //
571
   //
571
 
572
 
572
-  if (PAGE_CONTAINS(50 - INFO_FONT_HEIGHT, 49)) {
573
+  if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
573
     lcd_setFont(FONT_MENU);
574
     lcd_setFont(FONT_MENU);
574
-    u8g.setPrintPos(3, 49);
575
+    u8g.setPrintPos(3, 50);
575
     lcd_print(LCD_STR_FEEDRATE[0]);
576
     lcd_print(LCD_STR_FEEDRATE[0]);
576
 
577
 
577
     lcd_setFont(FONT_STATUSMENU);
578
     lcd_setFont(FONT_STATUSMENU);
578
-    u8g.setPrintPos(12, 49);
579
+    u8g.setPrintPos(12, 50);
579
     lcd_print(itostr3(feedrate_percentage));
580
     lcd_print(itostr3(feedrate_percentage));
580
     u8g.print('%');
581
     u8g.print('%');
581
   }
582
   }
584
   // Status line
585
   // Status line
585
   //
586
   //
586
 
587
 
587
-  #define STATUS_BASELINE (54 + INFO_FONT_HEIGHT)
588
+  #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
588
 
589
 
589
   if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
590
   if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
590
     u8g.setPrintPos(0, STATUS_BASELINE);
591
     u8g.setPrintPos(0, STATUS_BASELINE);
613
   // Set the colors for a menu item based on whether it is selected
614
   // Set the colors for a menu item based on whether it is selected
614
   static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
615
   static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
615
 
616
 
616
-    row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
617
-    row_y2 = row_y1 + (DOG_CHAR_HEIGHT) - 1;
617
+    row_y1 = row * (DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION)) + 1;
618
+    row_y2 = row_y1 + (DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION)) - 1;
618
 
619
 
619
-    if (!PAGE_CONTAINS(row_y1 + 2 - (TALL_FONT_CORRECTION), row_y2 + 2 - (TALL_FONT_CORRECTION))) return;
620
+    if (!PAGE_CONTAINS(row_y1 + 1, row_y1 + 1 + DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION))) return;
620
 
621
 
621
     if (isSelected) {
622
     if (isSelected) {
622
-      u8g.setColorIndex(1);  // black on white
623
-      u8g.drawBox(0, row_y1 + 2 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
624
-      u8g.setColorIndex(0);  // following text must be white on black
625
-    }
626
-    else {
627
-      u8g.setColorIndex(1); // unmarked text is black on white
623
+      #if ENABLED(MENU_HOLLOW_FRAME)
624
+        u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH);
625
+        u8g.drawHLine(0, row_y1 + 1 + DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH);
626
+      #else
627
+        u8g.setColorIndex(1); // black on white
628
+        u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT - 1 + 2 * (TALL_FONT_CORRECTION));
629
+        u8g.setColorIndex(0); // white on black
630
+      #endif
628
     }
631
     }
632
+    #if DISABLED(MENU_HOLLOW_FRAME)
633
+      else {
634
+        u8g.setColorIndex(1); // unmarked text is black on white
635
+      }
636
+    #endif
629
     u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
637
     u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
630
   }
638
   }
631
 
639
 

Loading…
Cancel
Save