Skip to content

Commit

Permalink
Optimize coolant delays
Browse files Browse the repository at this point in the history
Removed M9 delay
Delay does not occur if M7 or M8 state does not change
  • Loading branch information
bdring committed Sep 29, 2023
1 parent 3ee2c61 commit c203e90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FluidNC/src/CoolantControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ void CoolantControl::write(CoolantState state) {
bool pinState = state.Mist;
_mist.synchronousWrite(pinState);
}

_previous_state = state;
}

// Directly called by coolant_init(), coolant_set_state(), which can be at
Expand All @@ -68,11 +70,13 @@ void CoolantControl::stop() {
// parser program end, and g-code parser CoolantControl::sync().

void CoolantControl::set_state(CoolantState state) {
if (sys.abort) {
return; // Block during abort.
if (sys.abort || (_previous_state.Mist == state.Mist && _previous_state.Flood == state.Flood)) {
return; // Block during abort or if no change
}
write(state);
delay_msec(_delay_ms, DwellMode::SysSuspend);

if (state.Mist || state.Flood) // ignore delay on turn off
delay_msec(_delay_ms, DwellMode::SysSuspend);
}

void CoolantControl::off() {
Expand Down
2 changes: 2 additions & 0 deletions FluidNC/src/CoolantControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class CoolantControl : public Configuration::Configurable {

uint32_t _delay_ms = 0;

CoolantState _previous_state = {};

void write(CoolantState state);

public:
Expand Down

0 comments on commit c203e90

Please sign in to comment.