Skip to content

Commit

Permalink
Merge pull request #646 from Paciente8159/stop-delay-on-alarm
Browse files Browse the repository at this point in the history
fixed dwell to resume on alarm or error
  • Loading branch information
Paciente8159 authored Feb 25, 2024
2 parents c9a4e32 + e051c32 commit bba19db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions uCNC/src/cnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void cnc_clear_exec_state(uint8_t statemask)
{
if (!planner_buffer_is_empty())
{
cnc_delay_ms(DELAY_ON_RESUME_COOLANT * 1000);
cnc_dwell_ms(DELAY_ON_RESUME_COOLANT * 1000);
}
}
#endif
Expand All @@ -583,7 +583,7 @@ void cnc_clear_exec_state(uint8_t statemask)
protocol_send_feedback(MSG_FEEDBACK_10);
if (!planner_buffer_is_empty())
{
cnc_delay_ms(DELAY_ON_RESUME_SPINDLE * 1000);
cnc_dwell_ms(DELAY_ON_RESUME_SPINDLE * 1000);
}
}
#endif
Expand All @@ -594,6 +594,7 @@ void cnc_clear_exec_state(uint8_t statemask)
CLEARFLAG(cnc_state.exec_state, statemask);
}

// executes delay
void cnc_delay_ms(uint32_t milliseconds)
{
milliseconds += mcu_millis();
Expand All @@ -603,6 +604,15 @@ void cnc_delay_ms(uint32_t milliseconds)
} while (mcu_millis() < milliseconds);
}

//executes delay (resumes earlier on error)
void cnc_dwell_ms(uint32_t milliseconds)
{
milliseconds += mcu_millis();
do
{
} while ((mcu_millis() < milliseconds) && cnc_dotasks());
}

void cnc_reset(void)
{
// resets all realtime command flags
Expand Down
1 change: 1 addition & 0 deletions uCNC/src/cnc.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ extern "C"
void cnc_stop(void);
uint8_t cnc_unlock(bool force);
void cnc_delay_ms(uint32_t miliseconds);
void cnc_dwell_ms(uint32_t miliseconds);
void cnc_store_motion(void);
void cnc_restore_motion(void);
uint8_t cnc_parse_cmd(void);
Expand Down
2 changes: 1 addition & 1 deletion uCNC/src/core/motion_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ uint8_t mc_dwell(motion_data_t *block_data)
if (!mc_checkmode) // check mode (gcode simulation) doesn't send code to planner
{
mc_update_tools(block_data);
cnc_delay_ms(block_data->dwell);
cnc_dwell_ms(block_data->dwell);
}

return STATUS_OK;
Expand Down

0 comments on commit bba19db

Please sign in to comment.