From 4d3a2bd22cd259ae5fb05231d0a70c6b55183187 Mon Sep 17 00:00:00 2001
From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com>
Date: Sat, 25 Apr 2020 17:56:56 +0200
Subject: [PATCH] Clean up filament change menu (#17702)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
---
Marlin/src/lcd/menu/menu_filament.cpp | 44 ++++++++++++---------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp
index f7bc8c284c..46aee8f7a9 100644
--- a/Marlin/src/lcd/menu/menu_filament.cpp
+++ b/Marlin/src/lcd/menu/menu_filament.cpp
@@ -39,28 +39,26 @@
//
// Change Filament > Change/Unload/Load Filament
//
-static PauseMode _change_filament_temp_mode; // =PAUSE_MODE_PAUSE_PRINT
-static int8_t _change_filament_temp_extruder; // =0
+static PauseMode _change_filament_mode; // = PAUSE_MODE_PAUSE_PRINT
+static int8_t _change_filament_extruder; // = 0
-inline PGM_P _change_filament_temp_command() {
- switch (_change_filament_temp_mode) {
- case PAUSE_MODE_LOAD_FILAMENT:
- return PSTR("M701 T%d");
- case PAUSE_MODE_UNLOAD_FILAMENT:
- return _change_filament_temp_extruder >= 0 ? PSTR("M702 T%d") : PSTR("M702 ;%d");
+inline PGM_P _change_filament_command() {
+ switch (_change_filament_mode) {
+ case PAUSE_MODE_LOAD_FILAMENT: return PSTR("M701 T%d");
+ case PAUSE_MODE_UNLOAD_FILAMENT: return _change_filament_extruder >= 0
+ ? PSTR("M702 T%d") : PSTR("M702 ;%d");
case PAUSE_MODE_CHANGE_FILAMENT:
case PAUSE_MODE_PAUSE_PRINT:
- default:
- return PSTR("M600 B0 T%d");
+ default: break;
}
- return GET_TEXT(MSG_FILAMENTCHANGE);
+ return PSTR("M600 B0 T%d");
}
// Initiate Filament Load/Unload/Change at the specified temperature
-static void _change_filament_temp(const uint16_t temperature) {
+static void _change_filament(const uint16_t celsius) {
char cmd[11];
- sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
- thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
+ sprintf_P(cmd, _change_filament_command(), _change_filament_extruder);
+ thermalManager.setTargetHotend(celsius, _change_filament_extruder);
queue.inject(cmd);
}
@@ -70,25 +68,23 @@ static void _change_filament_temp(const uint16_t temperature) {
inline PGM_P change_filament_header(const PauseMode mode) {
switch (mode) {
- case PAUSE_MODE_LOAD_FILAMENT:
- return GET_TEXT(MSG_FILAMENTLOAD);
- case PAUSE_MODE_UNLOAD_FILAMENT:
- return GET_TEXT(MSG_FILAMENTUNLOAD);
+ case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT(MSG_FILAMENTLOAD);
+ case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT(MSG_FILAMENTUNLOAD);
default: break;
}
return GET_TEXT(MSG_FILAMENTCHANGE);
}
void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
- _change_filament_temp_mode = mode;
- _change_filament_temp_extruder = extruder;
+ _change_filament_mode = mode;
+ _change_filament_extruder = extruder;
START_MENU();
if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), SS_CENTER|SS_INVERT);
BACK_ITEM(MSG_BACK);
- ACTION_ITEM(MSG_PREHEAT_1, []{ _change_filament_temp(ui.preheat_hotend_temp[0]); });
- ACTION_ITEM(MSG_PREHEAT_2, []{ _change_filament_temp(ui.preheat_hotend_temp[1]); });
- EDIT_ITEM_FAST(int3, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[_change_filament_temp_extruder].target, EXTRUDE_MINTEMP, heater_maxtemp[extruder] - 15, []{
- _change_filament_temp(thermalManager.temp_hotend[_change_filament_temp_extruder].target);
+ ACTION_ITEM(MSG_PREHEAT_1, []{ _change_filament(ui.preheat_hotend_temp[0]); });
+ ACTION_ITEM(MSG_PREHEAT_2, []{ _change_filament(ui.preheat_hotend_temp[1]); });
+ EDIT_ITEM_FAST(int3, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[_change_filament_extruder].target, EXTRUDE_MINTEMP, heater_maxtemp[extruder] - 15, []{
+ _change_filament(thermalManager.temp_hotend[_change_filament_extruder].target);
});
END_MENU();
}
--
GitLab