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)
This commit is contained in:
AnHardt 2016-11-26 20:55:55 +01:00
parent 668e737893
commit 7a9fa78822
2 changed files with 30 additions and 18 deletions

View file

@ -215,6 +215,10 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
#define ENCODER_PULSES_PER_STEP 1
#endif
#ifndef TALL_FONT_CORRECTION
#define TALL_FONT_CORRECTION 0
#endif
/**
* START_SCREEN_OR_MENU generates init code for a screen or menu
*
@ -238,7 +242,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
#define SCREEN_OR_MENU_LOOP() \
int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT - TALL_FONT_CORRECTION; _lcdLineNr++, _menuLineNr++) { \
_thisItemNr = 0
/**
@ -249,7 +253,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
* Scroll as-needed to keep the selected line in view.
*/
#define START_SCREEN() \
START_SCREEN_OR_MENU(LCD_HEIGHT); \
START_SCREEN_OR_MENU(LCD_HEIGHT - TALL_FONT_CORRECTION); \
encoderTopLine = encoderLine; \
bool _skipStatic = false; \
SCREEN_OR_MENU_LOOP()
@ -257,8 +261,8 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
#define START_MENU() \
START_SCREEN_OR_MENU(1); \
NOMORE(encoderTopLine, encoderLine); \
if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
if (encoderLine >= encoderTopLine + LCD_HEIGHT - TALL_FONT_CORRECTION) { \
encoderTopLine = encoderLine - (LCD_HEIGHT - TALL_FONT_CORRECTION - 1); \
} \
bool _skipStatic = true; \
SCREEN_OR_MENU_LOOP()

View file

@ -508,13 +508,14 @@ static void lcd_implementation_status_screen() {
// Enable to save many cycles by drawing a hollow frame
#define XYZ_HOLLOW_FRAME
#define MENU_HOLLOW_FRAME
#if ENABLED(XYZ_HOLLOW_FRAME)
#define XYZ_FRAME_TOP 29
#define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
#else
#define XYZ_FRAME_TOP 30
#define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 2
#define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
#endif
// Before homing the axis letters are blinking 'X' <-> '?'.
@ -569,13 +570,13 @@ static void lcd_implementation_status_screen() {
// Feedrate
//
if (PAGE_CONTAINS(50 - INFO_FONT_HEIGHT, 49)) {
if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
lcd_setFont(FONT_MENU);
u8g.setPrintPos(3, 49);
u8g.setPrintPos(3, 50);
lcd_print(LCD_STR_FEEDRATE[0]);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(12, 49);
u8g.setPrintPos(12, 50);
lcd_print(itostr3(feedrate_percentage));
u8g.print('%');
}
@ -584,7 +585,7 @@ static void lcd_implementation_status_screen() {
// Status line
//
#define STATUS_BASELINE (54 + INFO_FONT_HEIGHT)
#define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
u8g.setPrintPos(0, STATUS_BASELINE);
@ -613,19 +614,26 @@ static void lcd_implementation_status_screen() {
// Set the colors for a menu item based on whether it is selected
static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
row_y2 = row_y1 + (DOG_CHAR_HEIGHT) - 1;
row_y1 = row * (DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION)) + 1;
row_y2 = row_y1 + (DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION)) - 1;
if (!PAGE_CONTAINS(row_y1 + 2 - (TALL_FONT_CORRECTION), row_y2 + 2 - (TALL_FONT_CORRECTION))) return;
if (!PAGE_CONTAINS(row_y1 + 1, row_y1 + 1 + DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION))) return;
if (isSelected) {
u8g.setColorIndex(1); // black on white
u8g.drawBox(0, row_y1 + 2 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
u8g.setColorIndex(0); // following text must be white on black
}
else {
u8g.setColorIndex(1); // unmarked text is black on white
#if ENABLED(MENU_HOLLOW_FRAME)
u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH);
u8g.drawHLine(0, row_y1 + 1 + DOG_CHAR_HEIGHT + 2 * (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH);
#else
u8g.setColorIndex(1); // black on white
u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT - 1 + 2 * (TALL_FONT_CORRECTION));
u8g.setColorIndex(0); // white on black
#endif
}
#if DISABLED(MENU_HOLLOW_FRAME)
else {
u8g.setColorIndex(1); // unmarked text is black on white
}
#endif
u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), row_y2);
}