diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 865c8492..33e6184c 100644 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -8,6 +8,7 @@ #include "lcd.h" #include "Configuration.h" #include "Marlin.h" +#include "ultralcd.h" @@ -269,7 +270,7 @@ void menu_draw_float13(char chr, const char* str, float val) lcd_printf_P(menu_fmt_float13, chr, str, spaces, val); } -#define _menu_data (*((menu_data_edit_t*)menu_data)) +#define _menu_data menuData.edit_menu void _menu_edit_int3(void) { if (lcd_draw_update) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 556f8836..4b20c9fb 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -48,90 +48,10 @@ char longFilenameOLD[LONG_FILENAME_LENGTH]; static void lcd_sd_updir(); -struct EditMenuParentState -{ - //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings. - menu_func_t prevMenu; - uint16_t prevEncoderPosition; - //Variables used when editing values. - const char* editLabel; - void* editValue; - int32_t minEditValue, maxEditValue; - // menu_func_t callbackFunc; -}; - -union MenuData -{ - struct BabyStep - { - // 29B total - int8_t status; - int babystepMem[3]; - float babystepMemMM[3]; - } babyStep; - - struct SupportMenu - { - // 6B+16B=22B total - int8_t status; - bool is_flash_air; - uint8_t ip[4]; - char ip_str[3*4+3+1]; - } supportMenu; - - struct AdjustBed - { - // 6+13+16=35B - // editMenuParentState is used when an edit menu is entered, so it knows - // the return menu and encoder state. - struct EditMenuParentState editMenuParentState; - int8_t status; - int8_t left; - int8_t right; - int8_t front; - int8_t rear; - int left2; - int right2; - int front2; - int rear2; - } adjustBed; - - struct TuneMenu - { - // editMenuParentState is used when an edit menu is entered, so it knows - // the return menu and encoder state. - struct EditMenuParentState editMenuParentState; - // To recognize, whether the menu has been just initialized. - int8_t status; - // Backup of extrudemultiply, to recognize, that the value has been changed and - // it needs to be applied. - int16_t extrudemultiply; - } tuneMenu; - - // editMenuParentState is used when an edit menu is entered, so it knows - // the return menu and encoder state. - struct EditMenuParentState editMenuParentState; - - struct AutoLoadFilamentMenu - { - //ShortTimer timer; - char dummy; - } autoLoadFilamentMenu; - struct _Lcd_moveMenu - { - bool initialized; - bool endstopsEnabledPrevious; - } _lcd_moveMenu; - struct sdcard_menu_t - { - uint8_t viewState; - } sdcard_menu; -}; // State of the currently active menu. // C Union manages sharing of the static memory by all the menus. -//union MenuData menuData = { 0 }; -#define menuData (*((MenuData*)menu_data)) +union MenuData menuData = { 0 }; int8_t ReInitLCD = 0; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 323c2331..df887456 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -4,6 +4,7 @@ #include "Marlin.h" #include "lcd.h" #include "conv2str.h" +#include "menu.h" extern int lcd_puts_P(const char* str); extern int lcd_printf_P(const char* format, ...); @@ -12,6 +13,91 @@ extern void menu_lcd_longpress_func(void); extern void menu_lcd_charsetup_func(void); extern void menu_lcd_lcdupdate_func(void); +struct EditMenuParentState +{ + //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings. + menu_func_t prevMenu; + uint16_t prevEncoderPosition; + //Variables used when editing values. + const char* editLabel; + void* editValue; + int32_t minEditValue, maxEditValue; + // menu_func_t callbackFunc; +}; + +union MenuData +{ + struct BabyStep + { + // 29B total + int8_t status; + int babystepMem[3]; + float babystepMemMM[3]; + } babyStep; + + struct SupportMenu + { + // 6B+16B=22B total + int8_t status; + bool is_flash_air; + uint8_t ip[4]; + char ip_str[3*4+3+1]; + } supportMenu; + + struct AdjustBed + { + // 6+13+16=35B + // editMenuParentState is used when an edit menu is entered, so it knows + // the return menu and encoder state. + struct EditMenuParentState editMenuParentState; + int8_t status; + int8_t left; + int8_t right; + int8_t front; + int8_t rear; + int left2; + int right2; + int front2; + int rear2; + } adjustBed; + + struct TuneMenu + { + // editMenuParentState is used when an edit menu is entered, so it knows + // the return menu and encoder state. + struct EditMenuParentState editMenuParentState; + // To recognize, whether the menu has been just initialized. + int8_t status; + // Backup of extrudemultiply, to recognize, that the value has been changed and + // it needs to be applied. + int16_t extrudemultiply; + } tuneMenu; + + // editMenuParentState is used when an edit menu is entered, so it knows + // the return menu and encoder state. + struct EditMenuParentState editMenuParentState; + + struct AutoLoadFilamentMenu + { + //ShortTimer timer; + char dummy; + } autoLoadFilamentMenu; + struct _Lcd_moveMenu + { + bool initialized; + bool endstopsEnabledPrevious; + } _lcd_moveMenu; + struct sdcard_menu_t + { + uint8_t viewState; + } sdcard_menu; + menu_data_edit_t edit_menu; +}; + +// State of the currently active menu. +// C Union manages sharing of the static memory by all the menus. +extern union MenuData menuData; + // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. void ultralcd_init();