diff --git a/uCNC/src/hal/tools/tools/laser_ppi.c b/uCNC/src/hal/tools/tools/laser_ppi.c index 85af14434..4e1b08997 100644 --- a/uCNC/src/hal/tools/tools/laser_ppi.c +++ b/uCNC/src/hal/tools/tools/laser_ppi.c @@ -191,7 +191,7 @@ bool laser_ppi_mcodes_exec(void *args) *(ptr->error) = STATUS_GCODE_VALUE_WORD_MISSING; return EVENT_HANDLED; } - + *(ptr->error) = STATUS_OK; break; } @@ -230,6 +230,16 @@ bool laser_ppi_mcodes_exec(void *args) CREATE_EVENT_LISTENER(gcode_exec, laser_ppi_mcodes_exec); #endif +DECL_MODULE(laser_ppi) +{ + #ifdef ENABLE_PARSER_MODULES + ADD_EVENT_LISTENER(gcode_parse, laser_ppi_mcodes_parse); + ADD_EVENT_LISTENER(gcode_exec, laser_ppi_mcodes_exec); + #else + #warning "Parser extensions are not enabled. M126, M127 and M128 code extensions will not work." + #endif +} + /** * Now starts the actual tool functions definitions * These functions will then be called by the tool HAL @@ -248,13 +258,6 @@ static void startup_code(void) g_settings.laser_mode |= LASER_PPI_MODE; laser_ppi_config_parameters(); HOOK_ATTACH_CALLBACK(itp_rt_stepbits, laser_ppi_pulse); - - RUNONCE - { - ADD_EVENT_LISTENER(gcode_parse, laser_ppi_mcodes_parse); - ADD_EVENT_LISTENER(gcode_exec, laser_ppi_mcodes_exec); - RUNONCE_COMPLETE(); - } } static void shutdown_code(void) diff --git a/uCNC/src/hal/tools/tools/plasma_thc.c b/uCNC/src/hal/tools/tools/plasma_thc.c index 7972267cb..45694fdc8 100644 --- a/uCNC/src/hal/tools/tools/plasma_thc.c +++ b/uCNC/src/hal/tools/tools/plasma_thc.c @@ -426,17 +426,6 @@ static void pid_update(void) } } -DECL_MODULE(plasma_thc) -{ -#ifdef ENABLE_PARSER_MODULES - ADD_EVENT_LISTENER(gcode_parse, m103_parse); - ADD_EVENT_LISTENER(gcode_exec, m103_exec); - ADD_EVENT_LISTENER(gcode_exec, plasma_virtual_pins); -#else -#error "Parser extensions are not enabled. M103 code extension will not work." -#endif -} - // uses similar status to grblhal bool plasma_protocol_send_status(void *args) { @@ -485,20 +474,24 @@ bool plasma_protocol_send_status(void *args) CREATE_EVENT_LISTENER(protocol_send_status, plasma_protocol_send_status); -static void startup_code(void) +DECL_MODULE(plasma_thc) { - static bool run_once = false; + ADD_EVENT_LISTENER(protocol_send_status, plasma_protocol_send_status); +#ifdef ENABLE_PARSER_MODULES + ADD_EVENT_LISTENER(gcode_parse, m103_parse); + ADD_EVENT_LISTENER(gcode_exec, m103_exec); + ADD_EVENT_LISTENER(gcode_exec, plasma_virtual_pins); +#else +#error "Parser extensions are not enabled. M103 code extension will not work." +#endif +} +static void startup_code(void) +{ // force plasma off #if ASSERT_PIN(PLASMA_ON_OUTPUT) io_clear_output(PLASMA_ON_OUTPUT); #endif - - if (!run_once) - { - ADD_EVENT_LISTENER(protocol_send_status, plasma_protocol_send_status); - run_once = true; - } } static void shutdown_code(void) diff --git a/uCNC/src/module.c b/uCNC/src/module.c index d5522d828..f44aabeff 100644 --- a/uCNC/src/module.c +++ b/uCNC/src/module.c @@ -56,6 +56,10 @@ void mod_init(void) LOAD_MODULE(tmcdriver); #endif +#ifdef ENABLE_LASER_PPI + LOAD_MODULE(laser_ppi); +#endif + #ifdef ENABLE_PLASMA_THC LOAD_MODULE(plasma_thc); #endif