Skip to content

Commit

Permalink
adds on_idle macro which allows chaining or looping gcode files
Browse files Browse the repository at this point in the history
  • Loading branch information
vector76 committed Sep 23, 2023
1 parent 3ee2c61 commit ebdba7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions FluidNC/src/Machine/Macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Macro Macros::_macro[n_macros] = { { "macro0" }, { "macro1" }, { "
Macro Macros::_after_homing = { "after_homing" };
Macro Macros::_after_reset = { "after_reset" };
Macro Macros::_after_unlock = { "after_unlock" };
Macro Macros::_on_idle = { "on_idle" };

MacroEvent macro0Event { 0 };
MacroEvent macro1Event { 1 };
Expand Down
2 changes: 2 additions & 0 deletions FluidNC/src/Machine/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace Machine {
static Macro _after_homing;
static Macro _after_reset;
static Macro _after_unlock;
static Macro _on_idle;

Macros() = default;

Expand All @@ -59,6 +60,7 @@ namespace Machine {
handler.item(_after_homing._name.c_str(), _after_homing._gcode);
handler.item(_after_reset._name.c_str(), _after_reset._gcode);
handler.item(_after_unlock._name.c_str(), _after_unlock._gcode);
handler.item(_on_idle._name.c_str(), _on_idle._gcode);
}

~Macros() {}
Expand Down
4 changes: 4 additions & 0 deletions FluidNC/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,12 @@ void protocol_do_cycle_stop() {
sys.suspend.bit.holdComplete = true;
sys.state = State::SafetyDoor;
} else {
State prev_state = sys.state;
sys.suspend.value = 0;
sys.state = State::Idle;
if (prev_state == State::Cycle) {
config->_macros->_on_idle.run();
}
}
break;
case State::Homing:
Expand Down

0 comments on commit ebdba7f

Please sign in to comment.