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

Stop fan rotation during safety timer #2444

Open
wants to merge 2 commits 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
7 changes: 6 additions & 1 deletion src/marlin_stubs/feature/safety_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ SafetyTimer::expired_t SafetyTimer::Loop() {

//timer is expired
if (pBoundPause) {
pBoundPause->NotifyExpiredFromSafetyTimer(thermalManager.degTargetHotend(0), thermalManager.degTargetBed());

auto fanSpeed = marlin_server_read_vars().print_fan_speed;
pBoundPause->NotifyExpiredFromSafetyTimer(thermalManager.degTargetHotend(0), thermalManager.degTargetBed(), fanSpeed);

thermalManager.set_fan_speed(0, 0);

if (printingIsPaused()) {
thermalManager.disable_hotend();
set_warning(WarningType::NozzleTimeout);
Expand Down
2 changes: 1 addition & 1 deletion src/marlin_stubs/include/IPause.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class IPause {
public:
virtual void RestoreTemp() = 0;
virtual bool CanSafetyTimerExpire() const = 0;
virtual void NotifyExpiredFromSafetyTimer(float hotend_temp, float bed_temp) = 0;
virtual void NotifyExpiredFromSafetyTimer(float hotend_temp, float bed_temp, uint8_t pwm_value) = 0;
virtual bool HasTempToRestore() const = 0;
};
3 changes: 2 additions & 1 deletion src/marlin_stubs/include/pause_stubbed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PausePrivatePhase : public IPause {

float nozzle_restore_temp;
float bed_restore_temp;
uint8_t m_pwm_value;

public:
static constexpr int intFinishVal = INT_MAX;
Expand Down Expand Up @@ -98,7 +99,7 @@ class PausePrivatePhase : public IPause {
public:
virtual void RestoreTemp() override;
virtual bool CanSafetyTimerExpire() const override; //evaluate if client can click == safety timer can expire
virtual void NotifyExpiredFromSafetyTimer(float hotend_temp, float bed_temp) override;
virtual void NotifyExpiredFromSafetyTimer(float hotend_temp, float bed_temp, uint8_t pwm_value) override;
virtual bool HasTempToRestore() const override;
};

Expand Down
10 changes: 10 additions & 0 deletions src/marlin_stubs/pause/M600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ void GcodeSuite::M600() {
NOZZLE_PARK_POINT;
#endif

// get fan speed before stopping it
uint8_t pwm_value;
pwm_value = marlin_server_read_vars().print_fan_speed;

// fan stop during material change
thermalManager.set_fan_speed(0, 0);

// Lift Z axis
if (parser.seenval('Z'))
park_point.z = parser.linearval('Z');
Expand Down Expand Up @@ -111,4 +118,7 @@ void GcodeSuite::M600() {
if (disp_temp > targ_temp) {
thermalManager.setTargetHotend(targ_temp, target_extruder);
}

// fan speed return
thermalManager.set_fan_speed(0, pwm_value);
}
6 changes: 5 additions & 1 deletion src/marlin_stubs/pause/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ bool PausePrivatePhase::CanSafetyTimerExpire() const {
return ClientResponses::HasButton(getPhase()); // button in current phase == can wait on user == can timeout
}

void PausePrivatePhase::NotifyExpiredFromSafetyTimer(float hotend_temp, float bed_temp) {
void PausePrivatePhase::NotifyExpiredFromSafetyTimer(float hotend_temp, float bed_temp, uint8_t pwm_value) {
if (CanSafetyTimerExpire()) {
nozzle_restore_temp = hotend_temp;
bed_restore_temp = bed_temp;
m_pwm_value = pwm_value;
}
}

Expand All @@ -172,6 +173,9 @@ void PausePrivatePhase::RestoreTemp() {
marlin_server_set_temp_to_display(nozzle_restore_temp);
nozzle_restore_temp = NAN;
}

thermalManager.set_fan_speed(0, m_pwm_value);

if (!isnan(bed_restore_temp)) {
thermalManager.setTargetBed(bed_restore_temp);
bed_restore_temp = NAN;
Expand Down