Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions Marlin/src/lcd/menu/menu_filament.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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();
}
Expand Down