From 5c56e472fe2fd394ecfb1772b71afc5be72b9b62 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 22 Jul 2016 10:31:30 +0200 Subject: [PATCH] Show the Toshiba FlashAir IP address in the menu. --- Firmware/ultralcd.cpp | 13 +++++++++- .../ultralcd_implementation_hitachi_HD44780.h | 26 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6afcd59a..da7b1647 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -137,6 +137,7 @@ static void lcd_quick_feedback();//Cause an LCD refresh, and give the user visua /* Different types of actions that can be used in menu items. */ static void menu_action_back(menuFunc_t data); +#define menu_action_back_RAM menu_action_back static void menu_action_submenu(menuFunc_t data); static void menu_action_gcode(const char* pgcode); static void menu_action_function(menuFunc_t data); @@ -750,6 +751,16 @@ static void lcd_support_menu() MENU_ITEM(back, PSTR("Date: "), lcd_main_menu); MENU_ITEM(back, PSTR(__DATE__), lcd_main_menu); + // Show the FlashAir IP address, if the card is available. + uint8_t ip[4]; + bool hasIP = card.ToshibaFlashAir_GetIP(ip); + if (hasIP) { + MENU_ITEM(back, PSTR("FlashAir IP Addr:"), lcd_main_menu); + char buf[30]; + sprintf_P(buf, PSTR("%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); + MENU_ITEM(back_RAM, buf, lcd_main_menu); + } + END_MENU(); } @@ -2279,7 +2290,7 @@ static void lcd_main_menu() } - if ( movesplanned() || IS_SD_PRINTING || is_usb_printing ) + if ( moves_planned() || IS_SD_PRINTING || is_usb_printing ) { MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu); } else diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index b4676add..bb03c142 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -916,6 +916,30 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c lcd.print(post_char); lcd.print(' '); } + +static void lcd_implementation_drawmenu_generic_RAM(uint8_t row, const char* str, char pre_char, char post_char) +{ + char c; + //Use all characters in narrow LCDs + #if LCD_WIDTH < 20 + uint8_t n = LCD_WIDTH - 1 - 1; + #else + uint8_t n = LCD_WIDTH - 1 - 2; + #endif + lcd.setCursor(0, row); + lcd.print(pre_char); + while( ((c = *str) != '\0') && (n>0) ) + { + lcd.print(c); + str++; + n--; + } + while(n--) + lcd.print(' '); + lcd.print(post_char); + lcd.print(' '); +} + static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data) { char c; @@ -1147,6 +1171,8 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst } #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0]) +#define lcd_implementation_drawmenu_back_RAM_selected(row, str, data) lcd_implementation_drawmenu_generic_RAM(row, str, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) +#define lcd_implementation_drawmenu_back_RAM(row, str, data) lcd_implementation_drawmenu_generic_RAM(row, str, ' ', LCD_STR_UPLEVEL[0]) #define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) #define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0]) #define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')