From 8663f4bbaf38afad897d33b6ecef3ae82d1f71b8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 3 Feb 2015 11:48:49 -0800 Subject: [PATCH] Apply some cleanup for recent merge Combine 1/(rows+1) with u8g.getHeight() to get rowHeight and just use that. --- Marlin/dogm_lcd_implementation.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 27f1fadbcd..0ddf18c575 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -379,24 +379,27 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { uint8_t lcd_width = LCD_WIDTH; uint8_t char_width = DOG_CHAR_WIDTH; -#ifdef USE_BIG_EDIT_FONT - if (strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) { - u8g.setFont(FONT_MENU_EDIT); - lcd_width = LCD_WIDTH_EDIT + 1; - char_width = DOG_CHAR_WIDTH_EDIT; - if (strlen_P(pstr) >= LCD_WIDTH_EDIT - strlen(value)) rows = 2; - } - else { - u8g.setFont(FONT_MENU); - } -#endif + #ifdef USE_BIG_EDIT_FONT + if (strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) { + u8g.setFont(FONT_MENU_EDIT); + lcd_width = LCD_WIDTH_EDIT + 1; + char_width = DOG_CHAR_WIDTH_EDIT; + if (strlen_P(pstr) >= LCD_WIDTH_EDIT - strlen(value)) rows = 2; + } + else { + u8g.setFont(FONT_MENU); + } + #endif + + if (strlen_P(pstr) > LCD_WIDTH - 2 - strlen(value)) rows = 2; - if ( strlen_P(pstr) > LCD_WIDTH - 2 - strlen(value) ) rows = 2; + const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2; + float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3 - u8g.setPrintPos( 0, u8g.getHeight() * 1/(1+rows) + DOG_CHAR_HEIGHT_EDIT/2); //1/(1+rows) = 1/2 or 1/3 + u8g.setPrintPos(0, rowHeight + kHalfChar); lcd_printPGM(pstr); u8g.print(':'); - u8g.setPrintPos((lcd_width-1-strlen(value))*char_width, u8g.getHeight()*rows/(1+rows) + DOG_CHAR_HEIGHT_EDIT/2); //rows/(1+rows) = 1/2 or 2/3 + u8g.setPrintPos((lcd_width-1-strlen(value)) * char_width, rows * rowHeight + kHalfChar); u8g.print(value); }