Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcode: Fix issue on unloaded filament temperature being higher temperature than loaded filament (lower temperature) #3681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion src/marlin_stubs/pause/M701_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ using namespace filament_gcodes;
bool filament_gcodes::load_unload([[maybe_unused]] LoadUnloadMode type, filament_gcodes::Func f_load_unload, pause::Settings &rSettings) {
float disp_temp = marlin_vars()->active_hotend().display_nozzle;
float targ_temp = Temperature::degTargetHotend(rSettings.GetExtruder());

float previous_filament_temp = filament::get_description(config_store().get_previous_filament_type(rSettings.GetExtruder())).nozzle;
if (previous_filament_temp > disp_temp) {
targ_temp = targ_temp + ((previous_filament_temp - targ_temp) * 0.6);
}
if (disp_temp > targ_temp) {
thermalManager.setTargetHotend(disp_temp, rSettings.GetExtruder());
}
Expand Down Expand Up @@ -188,6 +191,7 @@ void filament_gcodes::M70X_process_user_response(PreheatStatus::Result res, uint
switch (res) {
case PreheatStatus::Result::DoneHasFilament: {
auto filament = config_store().get_filament_type(target_extruder);
config_store().set_previous_filament_type(target_extruder, filament);
auto preheat_temp = filament::get_description(filament).nozzle_preheat;
thermalManager.setTargetHotend(preheat_temp, 0);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,62 @@ void CurrentStore::set_filament_type([[maybe_unused]] uint8_t index, filament::T
#endif
}

filament::Type CurrentStore::get_previous_filament_type([[maybe_unused]] uint8_t index) {
#if EXTRUDERS <= 1
assert(index == 0);
return filament_prev_type_0.get();
#else
switch (index) {
case 0:
return filament_prev_type_0.get();
case 1:
return filament_prev_type_1.get();
case 2:
return filament_prev_type_2.get();
case 3:
return filament_prev_type_3.get();
case 4:
return filament_prev_type_4.get();
case 5:
return filament_prev_type_5.get();
default:
assert(false && "invalid index");
return {};
}
#endif
}

void CurrentStore::set_previous_filament_type([[maybe_unused]] uint8_t index, filament::Type value) {
#if EXTRUDERS <= 1
assert(index == 0);
filament_type_0.set(value);
#else
switch (index) {
case 0:
filament_prev_type_0.set(value);
break;
case 1:
filament_prev_type_1.set(value);
break;
case 2:
filament_prev_type_2.set(value);
break;
case 3:
filament_prev_type_3.set(value);
break;
case 4:
filament_prev_type_4.set(value);
break;
case 5:
filament_prev_type_5.set(value);
break;
default:
assert(false && "invalid index");
return;
}
#endif
}

float CurrentStore::get_nozzle_diameter([[maybe_unused]] uint8_t index) {
#if HOTENDS <= 1
assert(index == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,19 @@ struct CurrentStore
StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Type 5")> filament_type_5;
#endif

StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Previous Type 0")> filament_prev_type_0;
#if EXTRUDERS > 1 // for now only doing one ifdef for simplicity
StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Previous Type 1")> filament_prev_type_1;
StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Previous Type 2")> filament_prev_type_2;
StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Previous Type 3")> filament_prev_type_3;
StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Previous Type 4")> filament_prev_type_4;
StoreItem<filament::Type, defaults::filament_type, journal::hash("Filament Previous Type 5")> filament_prev_type_5;
#endif

filament::Type get_filament_type(uint8_t index);
void set_filament_type(uint8_t index, filament::Type value);
filament::Type get_previous_filament_type(uint8_t index);
void set_previous_filament_type(uint8_t index, filament::Type value);

StoreItem<bool, false, journal::hash("Heatup Bed")> heatup_bed;

Expand Down