mirror of
https://github.com/synthetos/g2.git
synced 2026-02-06 02:51:54 +08:00
Name collision fix with "_handler" and some code rarrangement.
This commit is contained in:
@@ -81,6 +81,44 @@ static stat_t _controller_state(void); // manage controller state trans
|
||||
|
||||
static Motate::OutputPin<Motate::kOutputSAFE_PinNumber> safe_pin;
|
||||
|
||||
gpioDigitalInputHandler _shutdown_input_handler {
|
||||
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
|
||||
if (edge != INPUT_EDGE_LEADING) { return false; }
|
||||
|
||||
cm.shutdown_requested = triggering_pin_number;
|
||||
|
||||
return false; // allow others to see this notice
|
||||
},
|
||||
5, // priority
|
||||
nullptr // next - nullptr to start with
|
||||
};
|
||||
|
||||
gpioDigitalInputHandler _limit_input_handler {
|
||||
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
|
||||
if (edge != INPUT_EDGE_LEADING) { return false; }
|
||||
|
||||
cm.limit_requested = triggering_pin_number;
|
||||
|
||||
return false; // allow others to see this notice
|
||||
},
|
||||
5, // priority
|
||||
nullptr // next - nullptr to start with
|
||||
};
|
||||
|
||||
gpioDigitalInputHandler _interlock_input_handler {
|
||||
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
|
||||
if (edge == INPUT_EDGE_LEADING) {
|
||||
cm.safety_interlock_disengaged = triggering_pin_number;
|
||||
} else { // edge == INPUT_EDGE_TRAILING
|
||||
cm.safety_interlock_reengaged = triggering_pin_number;
|
||||
}
|
||||
|
||||
return false; // allow others to see this notice
|
||||
},
|
||||
5, // priority
|
||||
nullptr // next - nullptr to start with
|
||||
};
|
||||
|
||||
/***********************************************************************************
|
||||
**** CODE *************************************************************************
|
||||
***********************************************************************************/
|
||||
@@ -106,9 +144,9 @@ void controller_init()
|
||||
}
|
||||
// IndicatorLed.setFrequency(100000);
|
||||
|
||||
din_handlers[INPUT_ACTION_SHUTDOWN].registerHandler(&_shutdown_handler);
|
||||
din_handlers[INPUT_ACTION_LIMIT].registerHandler(&_limit_handler);
|
||||
din_handlers[INPUT_ACTION_INTERLOCK].registerHandler(&_interlock_handler);
|
||||
din_handlers[INPUT_ACTION_SHUTDOWN].registerHandler(&_shutdown_input_handler);
|
||||
din_handlers[INPUT_ACTION_LIMIT].registerHandler(&_limit_input_handler);
|
||||
din_handlers[INPUT_ACTION_INTERLOCK].registerHandler(&_interlock_input_handler);
|
||||
}
|
||||
|
||||
void controller_request_enquiry()
|
||||
@@ -466,10 +504,10 @@ static stat_t _sync_to_planner()
|
||||
/* ALARM STATE HANDLERS
|
||||
*
|
||||
* _shutdown_handler() - put system into shutdown state
|
||||
* _shutdown_handler - a gpioDigitalInputHandler to capture pin change events
|
||||
* _shutdown_input_handler - a gpioDigitalInputHandler to capture pin change events
|
||||
* _limit_switch_handler() - shut down system if limit switch fired
|
||||
* _limit_handler - a gpioDigitalInputHandler to capture pin change events
|
||||
* _interlock_handler() - feedhold and resume depending on edge
|
||||
* _limit_input_handler - a gpioDigitalInputHandler to capture pin change events
|
||||
* _interlock_input_handler() - feedhold and resume depending on edge
|
||||
* _interlock_handler - a gpioDigitalInputHandler to capture pin change events
|
||||
*
|
||||
* Some handlers return EAGAIN causing the control loop to never advance beyond that point.
|
||||
@@ -480,18 +518,6 @@ static stat_t _sync_to_planner()
|
||||
* - safety_interlock_requested == INPUT_EDGE_TRAILING is interlock offset
|
||||
*/
|
||||
|
||||
gpioDigitalInputHandler _shutdown_handler {
|
||||
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
|
||||
if (edge != INPUT_EDGE_LEADING) { return false; }
|
||||
|
||||
cm.shutdown_requested = triggering_pin_number;
|
||||
|
||||
return false; // allow others to see this notice
|
||||
},
|
||||
5, // priority
|
||||
nullptr // next - nullptr to start with
|
||||
};
|
||||
|
||||
static stat_t _shutdown_handler(void)
|
||||
{
|
||||
if (cm.shutdown_requested != 0) { // request may contain the (non-zero) input number
|
||||
@@ -503,18 +529,6 @@ static stat_t _shutdown_handler(void)
|
||||
return(STAT_OK);
|
||||
}
|
||||
|
||||
gpioDigitalInputHandler _limit_handler {
|
||||
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
|
||||
if (edge != INPUT_EDGE_LEADING) { return false; }
|
||||
|
||||
cm.limit_requested = triggering_pin_number;
|
||||
|
||||
return false; // allow others to see this notice
|
||||
},
|
||||
5, // priority
|
||||
nullptr // next - nullptr to start with
|
||||
};
|
||||
|
||||
static stat_t _limit_switch_handler(void)
|
||||
{
|
||||
auto machine_state = cm_get_machine_state();
|
||||
@@ -533,20 +547,6 @@ static stat_t _limit_switch_handler(void)
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
gpioDigitalInputHandler _interlock_handler {
|
||||
[&](const bool state, const inputEdgeFlag edge, const uint8_t triggering_pin_number) {
|
||||
if (edge == INPUT_EDGE_LEADING) {
|
||||
cm.safety_interlock_disengaged = triggering_pin_number;
|
||||
} else { // edge == INPUT_EDGE_TRAILING
|
||||
cm.safety_interlock_reengaged = triggering_pin_number;
|
||||
}
|
||||
|
||||
return false; // allow others to see this notice
|
||||
},
|
||||
5, // priority
|
||||
nullptr // next - nullptr to start with
|
||||
};
|
||||
|
||||
static stat_t _interlock_handler(void)
|
||||
{
|
||||
if (cm.safety_interlock_enable) {
|
||||
|
||||
Reference in New Issue
Block a user