diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 54c1bfc9b..1a0ee8a4a 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -474,12 +474,72 @@ void lcd_set_home_offsets() { #endif //BABYSTEPPING +/** + * Watch temperature callbacks + */ +#if TEMP_SENSOR_0 != 0 + void watch_temp_callback_E0() { start_watching_heater(0); } +#endif +#if EXTRUDERS > 1 && TEMP_SENSOR_1 != 0 + void watch_temp_callback_E1() { start_watching_heater(1); } + #if EXTRUDERS > 2 && TEMP_SENSOR_2 != 0 + void watch_temp_callback_E2() { start_watching_heater(2); } + #if EXTRUDERS > 3 && TEMP_SENSOR_3 != 0 + void watch_temp_callback_E3() { start_watching_heater(3); } + #endif // EXTRUDERS > 3 + #endif // EXTRUDERS > 2 +#endif // EXTRUDERS > 1 + +/** + * Items shared between Tune and Temperature menus + */ +static void nozzle_bed_fan_menu_items(uint8_t &encoderLine, uint8_t &_lineNr, uint8_t &_drawLineNr, uint8_t &_menuItemNr, bool &wasClicked, bool &itemSelected) { + // + // Nozzle: + // Nozzle [1-4]: + // + #if EXTRUDERS == 1 + #if TEMP_SENSOR_0 != 0 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0); + #endif + #else //EXTRUDERS > 1 + #if TEMP_SENSOR_0 != 0 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N1, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0); + #endif + #if TEMP_SENSOR_1 != 0 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15, watch_temp_callback_E1); + #endif + #if EXTRUDERS > 2 + #if TEMP_SENSOR_2 != 0 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15, watch_temp_callback_E2); + #endif + #if EXTRUDERS > 3 + #if TEMP_SENSOR_3 != 0 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15, watch_temp_callback_E3); + #endif + #endif // EXTRUDERS > 3 + #endif // EXTRUDERS > 2 + #endif // EXTRUDERS > 1 + + // + // Bed: + // + #if TEMP_SENSOR_BED != 0 + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); + #endif + + // + // Fan Speed: + // + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); +} + + /** * * "Tune" submenu * */ - static void lcd_tune_menu() { START_MENU(); @@ -493,52 +553,8 @@ static void lcd_tune_menu() { // MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999); - // - // Nozzle: - // Nozzle 1: - // Nozzle 2: - // Nozzle 3: - // Nozzle 4: - // - #if EXTRUDERS == 1 - #if TEMP_SENSOR_0 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); - #endif - #else //EXTRUDERS > 1 - #if TEMP_SENSOR_0 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N1, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); - #endif - #if TEMP_SENSOR_1 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); - #endif - #if EXTRUDERS > 2 - #if TEMP_SENSOR_2 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); - #endif - #if EXTRUDERS > 3 - #if TEMP_SENSOR_3 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); - #endif - #endif //EXTRUDERS > 3 - #endif //EXTRUDERS > 2 - #endif //EXTRUDERS > 1 - - // - // Bed: - // - #if TEMP_SENSOR_BED != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); - #endif - - // - // Fan Speed: - // - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); - - // - // Flow: - // - MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[active_extruder], 10, 999); + // Nozzle, Bed, and Fan Control + nozzle_bed_fan_menu_items(encoderLine, _lineNr, _drawLineNr, _menuItemNr, wasClicked, itemSelected); // // Flow: @@ -550,6 +566,7 @@ static void lcd_tune_menu() { #if EXTRUDERS == 1 MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[0], 10, 999); #else // EXTRUDERS > 1 + MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[active_extruder], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N1, &extruder_multiplier[0], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N2, &extruder_multiplier[1], 10, 999); #if EXTRUDERS > 2 @@ -1002,44 +1019,8 @@ static void lcd_control_temperature_menu() { // MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); - // - // Nozzle - // Nozzle 1, Nozzle 2, Nozzle 3, Nozzle 4 - // - #if EXTRUDERS == 1 - #if TEMP_SENSOR_0 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); - #endif - #else //EXTRUDERS > 1 - #if TEMP_SENSOR_0 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N1, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); - #endif - #if TEMP_SENSOR_1 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N2, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); - #endif - #if EXTRUDERS > 2 - #if TEMP_SENSOR_2 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N3, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); - #endif - #if EXTRUDERS > 3 - #if TEMP_SENSOR_3 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE MSG_N4, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); - #endif - #endif // EXTRUDERS > 3 - #endif // EXTRUDERS > 2 - #endif // EXTRUDERS > 1 - - // - // Bed - // - #if TEMP_SENSOR_BED != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); - #endif - - // - // Fan Speed - // - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); + // Nozzle, Bed, and Fan Control + nozzle_bed_fan_menu_items(encoderLine, _lineNr, _drawLineNr, _menuItemNr, wasClicked, itemSelected); // // Autotemp, Min, Max, Fact