Skip to content

Commit

Permalink
after_homing, after_unlock, after_reset macros
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchBradley committed Aug 3, 2023
1 parent 2f02a9f commit 50f06ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion FluidNC/src/Machine/Macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void MacroEvent::run(void* arg) {

std::string Macros::_startup_line[n_startup_lines];
std::string Macros::_macro[n_macros];
std::string Macros::_post_homing_line;
std::string Macros::_after_homing_line;
std::string Macros::_after_reset_line;
std::string Macros::_after_unlock_line;

MacroEvent macro0Event { 0 };
MacroEvent macro1Event { 1 };
Expand Down
8 changes: 6 additions & 2 deletions FluidNC/src/Machine/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ namespace Machine {

public:
static std::string _startup_line[n_startup_lines];
static std::string _post_homing_line;
static std::string _after_homing_line;
static std::string _after_reset_line;
static std::string _after_unlock_line;

Macros() = default;

Expand All @@ -52,7 +54,9 @@ namespace Machine {
handler.item("macro1", _macro[1]);
handler.item("macro2", _macro[2]);
handler.item("macro3", _macro[3]);
handler.item("post_homing", _post_homing_line);
handler.item("after_homing", _after_homing_line);
handler.item("after_reset", _after_reset_line);
handler.item("after_unlock", _after_unlock_line);
}

~Macros() {}
Expand Down
4 changes: 2 additions & 2 deletions FluidNC/src/ProcessSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static Error disable_alarm_lock(const char* value, WebUI::AuthenticationLevel au
report_feedback_message(Message::AlarmUnlock);
sys.state = State::Idle;

// Don't run startup script. Prevents stored moves in startup from causing accidents.
config->_macros->run_macro(Macros::_after_unlock_line);
} // Otherwise, no effect.
return Error::Ok;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ static Error home(AxisMask axisMask) {
protocol_execute_realtime();
} while (sys.state == State::Homing);

config->_macros->run_macro(Macros::_post_homing_line);
config->_macros->run_macro(Macros::_after_homing_line);

return Error::Ok;
}
Expand Down
4 changes: 4 additions & 0 deletions FluidNC/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ static void protocol_do_restart() {
mc_critical(ExecAlarm::HardLimit);
} else if (config->_control->startup_check()) {
send_alarm(ExecAlarm::ControlPin);
} else {
if (sys.state == State::Idle) {
config->_macros->run_macro(Macros::_after_reset_line);
}
}
}

Expand Down

0 comments on commit 50f06ab

Please sign in to comment.