Static menu items take an optional string, LJ by default

This commit is contained in:
Scott Lahteine 2016-07-02 13:57:24 -07:00
parent fa9b2a925d
commit 439e78147d
2 changed files with 43 additions and 27 deletions

View file

@ -473,21 +473,29 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
u8g.setPrintPos((START_ROW) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT)); u8g.setPrintPos((START_ROW) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
} }
static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true) { #if ENABLED(LCD_INFO_MENU)
char c;
uint8_t n = LCD_WIDTH; static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char* valstr=NULL, bool center=false) {
u8g.setPrintPos(0, (row + 1) * (DOG_CHAR_HEIGHT)); char c;
u8g.setColorIndex(1); // normal text int8_t n = LCD_WIDTH;
if (center) { u8g.setPrintPos(0, (row + 1) * (DOG_CHAR_HEIGHT));
int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; u8g.setColorIndex(1); // normal text
while (--pad >= 0) { lcd_print(' '); n--; } if (center) {
int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
while (--pad >= 0) { lcd_print(' '); n--; }
}
while (c = pgm_read_byte(pstr)) {
n -= lcd_print(c);
pstr++;
}
if (valstr) {
lcd_print(valstr);
n -= lcd_strlen(valstr);
}
while (n-- > 0) lcd_print(' ');
} }
while (c = pgm_read_byte(pstr)) {
n -= lcd_print(c); #endif // LCD_INFO_MENU
pstr++;
}
while (n--) lcd_print(' ');
}
static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) { static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
UNUSED(pstr); UNUSED(pstr);

View file

@ -815,20 +815,28 @@ static void lcd_implementation_status_screen() {
lcd_print(lcd_status_message); lcd_print(lcd_status_message);
} }
static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true) { #if ENABLED(LCD_INFO_MENU)
char c;
uint8_t n = LCD_WIDTH; static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char *valstr=NULL, bool center=true) {
lcd.setCursor(0, row); char c;
if (center) { int8_t n = LCD_WIDTH;
int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; lcd.setCursor(0, row);
while (--pad >= 0) { lcd.print(' '); n--; } if (center) {
int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
while (--pad >= 0) { lcd.print(' '); n--; }
}
while ((c = pgm_read_byte(pstr)) && n > 0) {
n -= lcd_print(c);
pstr++;
}
if (valstr) {
lcd_print(valstr);
n -= lcd_strlen(valstr);
}
while (n-- > 0) lcd.print(' ');
} }
while ((c = pgm_read_byte(pstr)) && n > 0) {
n -= lcd_print(c); #endif // LCD_INFO_MENU
pstr++;
}
while (n--) lcd.print(' ');
}
static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) { static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
char c; char c;