Skip to content

Commit

Permalink
Add option to automatically cooldown after filament unload
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler committed Jan 21, 2024
1 parent 0ba6a80 commit bc04d04
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/gui/MItem_filament.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,18 @@ MI_COOLDOWN::MI_COOLDOWN()
void MI_COOLDOWN::click(IWindowMenu & /*window_menu*/) {
Screens::Access()->WindowEvent(GUI_event_t::CHILD_CLICK, (void *)this);
}

/*****************************************************************************/
// MI_AUTO_COOLDOWN
/*****************************************************************************/
bool MI_AUTO_COOLDOWN::init_index() const {
return config_store().auto_cooldown_enabled.get();
}

void MI_AUTO_COOLDOWN::OnChange(size_t old_index) {
if (old_index) {
config_store().auto_cooldown_enabled.set(false);
} else {
config_store().auto_cooldown_enabled.set(true);
}
}
13 changes: 13 additions & 0 deletions src/gui/MItem_filament.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once
#include "menu_item_event_dispatcher.hpp"
#include "i18n.h"
#include "WindowMenuItems.hpp"

class MI_LOAD : public MI_event_dispatcher {
constexpr static const char *const label = N_("Load Filament");
Expand Down Expand Up @@ -71,3 +72,15 @@ class MI_COOLDOWN : public WI_LABEL_t {
protected:
virtual void click(IWindowMenu & /*window_menu*/) override;
};

class MI_AUTO_COOLDOWN : public WI_ICON_SWITCH_OFF_ON_t {
constexpr static const char *const label = N_("Cooldown after unload");
bool init_index() const;

public:
MI_AUTO_COOLDOWN()
: WI_ICON_SWITCH_OFF_ON_t(init_index(), _(label), nullptr, is_enabled_t::yes, is_hidden_t::no) {}

protected:
virtual void OnChange(size_t old_index) override;
};
2 changes: 1 addition & 1 deletion src/gui/screen_menu_temperature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using ScreenMenuTemperature__ = ScreenMenu<
#if HAS_TOOLCHANGER()
MI_NOZZLE<1>, MI_NOZZLE<2>, MI_NOZZLE<3>, MI_NOZZLE<4>,
#endif
MI_HEATBED, MI_PRINTFAN, MI_COOLDOWN>;
MI_HEATBED, MI_PRINTFAN, MI_AUTO_COOLDOWN, MI_COOLDOWN>;

class ScreenMenuTemperature : public ScreenMenuTemperature__ {
public:
Expand Down
7 changes: 7 additions & 0 deletions src/marlin_stubs/pause/M701_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ void filament_gcodes::M70X_process_user_response(PreheatStatus::Result res, uint
thermalManager.set_fan_speed(0, 0);
break;
case PreheatStatus::Result::DoneNoFilament:
if (config_store().auto_cooldown_enabled.get()) {
thermalManager.setTargetHotend(0, 0);
thermalManager.setTargetBed(0);
marlin_server::set_temp_to_display(0, 0);
thermalManager.set_fan_speed(0, 0);
}
break;
case PreheatStatus::Result::Aborted:
case PreheatStatus::Result::Error:
case PreheatStatus::Result::DidNotFinish: // cannot happen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ struct CurrentStore : public journal::CurrentStoreConfig<journal::Backend, backe
StoreItem<bool, input_shaper::weight_adjust_enabled_default, journal::hash("Input Shaper Weight Adjust Y Enabled V2")> input_shaper_weight_adjust_y_enabled;
StoreItem<input_shaper::WeightAdjustConfig, input_shaper::weight_adjust_y_default, journal::hash("Input Shaper Weight Adjust Y Config")> input_shaper_weight_adjust_y_config;

StoreItem<bool, defaults::bool_false, journal::hash("Enable auto cooldown on unload")> auto_cooldown_enabled;

input_shaper::Config get_input_shaper_config();
void set_input_shaper_config(const input_shaper::Config &);
};
Expand Down

0 comments on commit bc04d04

Please sign in to comment.