MarlinUI support for up to 5 Material Presets (#18488)

- Add `I` preset parameter to `G26`, `M106`, `M140`, and `M190`.
- Extend menu items to permit a string interpolation.
- Keep material names in a list and interpolate in menu items.
- Extend material presets to support up to 5 predefined materials.

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Giuliano Zaro
2020-07-09 10:11:57 +02:00
committed by GitHub
parent abc5c93986
commit b0c6cfb051
51 changed files with 1179 additions and 870 deletions

View File

@@ -55,13 +55,21 @@ inline PGM_P _change_filament_command() {
}
// Initiate Filament Load/Unload/Change at the specified temperature
static void _change_filament(const uint16_t celsius) {
static void _change_filament_with_temp(const uint16_t celsius) {
char cmd[11];
sprintf_P(cmd, _change_filament_command(), _change_filament_extruder);
thermalManager.setTargetHotend(celsius, _change_filament_extruder);
queue.inject(cmd);
}
static void _change_filament_with_preset() {
_change_filament_with_temp(ui.material_preset[MenuItemBase::itemIndex].hotend_temp);
}
static void _change_filament_with_custom() {
_change_filament_with_temp(thermalManager.temp_hotend[MenuItemBase::itemIndex].target);
}
//
// Menu to choose the temperature and start Filament Change
//
@@ -81,11 +89,14 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t 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(ui.material_preset[0].hotend_temp); });
ACTION_ITEM(MSG_PREHEAT_2, []{ _change_filament(ui.material_preset[1].hotend_temp); });
EDIT_ITEM_FAST(int3, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[_change_filament_extruder].target, EXTRUDE_MINTEMP, thermalManager.heater_maxtemp[extruder] - HOTEND_OVERSHOOT, []{
_change_filament(thermalManager.temp_hotend[_change_filament_extruder].target);
});
#if PREHEAT_COUNT
LOOP_L_N(m, PREHEAT_COUNT)
ACTION_ITEM_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset);
#endif
EDIT_ITEM_FAST_N(int3, extruder, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[extruder].target,
EXTRUDE_MINTEMP, thermalManager.heater_maxtemp[extruder] - HOTEND_OVERSHOOT,
_change_filament_with_custom
);
END_MENU();
}