From b063b1b7229c1706690f167a99528e13d4ff371d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 28 Oct 2018 02:59:21 -0500 Subject: [PATCH] Reorganize includes and declarations --- .../src/lcd/HD44780/ultralcd_common_HD44780.h | 4 +- Marlin/src/lcd/menu/menu.cpp | 51 +++++++++---------- Marlin/src/lcd/menu/menu.h | 7 ++- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 + Marlin/src/lcd/menu/menu_temperature.cpp | 4 ++ Marlin/src/lcd/ultralcd.cpp | 7 +++ 6 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Marlin/src/lcd/HD44780/ultralcd_common_HD44780.h b/Marlin/src/lcd/HD44780/ultralcd_common_HD44780.h index b9e1e6bc9..d4dd2afae 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_common_HD44780.h +++ b/Marlin/src/lcd/HD44780/ultralcd_common_HD44780.h @@ -50,8 +50,6 @@ #endif #endif -extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array. - //////////////////////////////////// // Setup button and encode mappings for each panel (into 'buttons' variable // @@ -61,6 +59,8 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt #if ENABLED(ULTIPANEL) + extern volatile uint8_t buttons; + // // Setup other button mappings of each panel // diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index e31a12d93..181d06733 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -25,34 +25,32 @@ #if ENABLED(ULTIPANEL) #include "menu.h" - #include "../ultralcd.h" #include "../../module/planner.h" #include "../../module/motion.h" -#include "../../module/probe.h" -#include "../../module/printcounter.h" -#include "../../gcode/gcode.h" #include "../../gcode/queue.h" -#include "../../module/configuration_store.h" -#include "../../module/tool_change.h" -#include "../../Marlin.h" +#include "../../sd/cardreader.h" -#include +#if ENABLED(EEPROM_SETTINGS) + #include "../../module/configuration_store.h" +#endif + +#if WATCH_HOTENDS || WATCH_THE_BED + #include "../../module/temperature.h" +#endif -#if ENABLED(SDSUPPORT) - #include "../../sd/cardreader.h" +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) + #include "../../module/probe.h" +#endif + +#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) || ENABLED(AUTO_BED_LEVELING_UBL) + #include "../../feature/bedlevel/bedlevel.h" #endif //////////////////////////////////////////// ///////////// Global Variables ///////////// //////////////////////////////////////////// -// Buttons -volatile uint8_t buttons; -#if ENABLED(REPRAPWORLD_KEYPAD) - volatile uint8_t buttons_reprapworld_keypad; -#endif - // Menu Navigation int8_t encoderTopLine; typedef struct { @@ -70,12 +68,9 @@ int32_t minEditValue, maxEditValue; screenFunc_t callbackFunc; bool liveEdit; +// Prevent recursion into screen handlers bool no_reentry = false; -// Initialized by settings.load() -int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2]; -uint8_t lcd_preheat_fan_speed[2]; - //////////////////////////////////////////// //////// Menu Navigation & History ///////// //////////////////////////////////////////// @@ -110,7 +105,7 @@ void lcd_goto_previous_menu_no_defer() { } //////////////////////////////////////////// -/////////////// Menu Actions /////////////// +/////////// Common Menu Actions //////////// //////////////////////////////////////////// void _menu_action_back() { lcd_goto_previous_menu(); } @@ -355,14 +350,14 @@ void lcd_completion_feedback(const bool good/*=true*/) { else lcd_buzz(20, 440); } -inline void line_to_current_z() { - planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder); -} +#if HAS_LINE_TO_Z -void line_to_z(const float &z) { - current_position[Z_AXIS] = z; - line_to_current_z(); -} + void line_to_z(const float &z) { + current_position[Z_AXIS] = z; + planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder); + } + +#endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 1f8f8f69b..fbbb00392 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -348,7 +348,6 @@ void menu_move(); void lcd_move_z(); void lcd_synchronize(PGM_P const msg=NULL); -void line_to_z(const float &z); void _lcd_draw_homing(); void watch_temp_callback_E0(); @@ -359,6 +358,12 @@ void watch_temp_callback_E4(); void watch_temp_callback_E5(); void watch_temp_callback_bed(); +#define HAS_LINE_TO_Z (ENABLED(DELTA) || ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING) || ENABLED(LEVEL_BED_CORNERS)) + +#if HAS_LINE_TO_Z + void line_to_z(const float &z); +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE) void lcd_enqueue_command(const char * const cmd); void lcd_enqueue_commands_P(PGM_P const cmd); diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index a351d427f..0299867cb 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -45,6 +45,8 @@ void _man_probe_pt(const float &rx, const float &ry) { #if ENABLED(DELTA_AUTO_CALIBRATION) + #include "../../gcode/gcode.h" + float lcd_probe_pt(const float &rx, const float &ry) { _man_probe_pt(rx, ry); KEEPALIVE_STATE(PAUSED_FOR_USER); diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index ec924ae34..6b90fc1e2 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -35,6 +35,10 @@ #include "../../module/motion.h" #endif +// Initialized by settings.load() +int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2]; +uint8_t lcd_preheat_fan_speed[2]; + // // "Temperature" submenu items // diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 679cd7bc3..6d67683bc 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -74,6 +74,9 @@ #include "../libs/buzzer.h" #endif +// Buttons +volatile uint8_t buttons; + #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) uint8_t lcd_sd_status; #endif @@ -219,6 +222,10 @@ bool lcd_blink() { ///////////// Keypad Handling ////////////// //////////////////////////////////////////// +#if ENABLED(REPRAPWORLD_KEYPAD) + volatile uint8_t buttons_reprapworld_keypad; +#endif + #if ENABLED(ADC_KEYPAD) #define KEYPAD_HOME EN_REPRAPWORLD_KEYPAD_F1