Minor VARIABLE_SPINDLE feature toggle refactoring (#16)
* Modify code CSV format. - Wrap value in quotes to avoid issue with embedded commas. This occurs in one of the alarm codes. - Change header row format to allow same parsing code as data rows. * VARIABLE_SPINDLE feature flag experiment. - Use a macro for 'spindle_set_speed' and 'spindle_sync' to reduce the number of required VARIABLE_SPINDLE checks.
This commit is contained in:
parent
8b76a39d5d
commit
8e638f0054
@ -911,7 +911,7 @@ uint8_t gc_execute_line(char *line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (gc_state.modal.spindle != SPINDLE_DISABLE) { spindle_sync(gc_state.modal.spindle); }
|
if (gc_state.modal.spindle != SPINDLE_DISABLE) { spindle_sync(gc_state.modal.spindle, 0.0); }
|
||||||
#endif
|
#endif
|
||||||
gc_state.spindle_speed = gc_block.values.s;
|
gc_state.spindle_speed = gc_block.values.s;
|
||||||
}
|
}
|
||||||
@ -925,11 +925,7 @@ uint8_t gc_execute_line(char *line)
|
|||||||
// [7. Spindle control ]:
|
// [7. Spindle control ]:
|
||||||
if (gc_state.modal.spindle != gc_block.modal.spindle) {
|
if (gc_state.modal.spindle != gc_block.modal.spindle) {
|
||||||
// Update spindle control and apply spindle speed when enabling it in this block.
|
// Update spindle control and apply spindle speed when enabling it in this block.
|
||||||
#ifdef VARIABLE_SPINDLE
|
|
||||||
spindle_sync(gc_block.modal.spindle, gc_state.spindle_speed);
|
spindle_sync(gc_block.modal.spindle, gc_state.spindle_speed);
|
||||||
#else
|
|
||||||
spindle_sync(gc_block.modal.spindle);
|
|
||||||
#endif
|
|
||||||
gc_state.modal.spindle = gc_block.modal.spindle;
|
gc_state.modal.spindle = gc_block.modal.spindle;
|
||||||
}
|
}
|
||||||
pl_data->condition |= gc_state.modal.spindle; // Set condition flag for planner use.
|
pl_data->condition |= gc_state.modal.spindle; // Set condition flag for planner use.
|
||||||
|
@ -650,11 +650,7 @@ static void protocol_exec_rt_suspend()
|
|||||||
// When in laser mode, ignore spindle spin-up delay. Set to turn on laser when cycle starts.
|
// When in laser mode, ignore spindle spin-up delay. Set to turn on laser when cycle starts.
|
||||||
bit_true(sys.step_control, STEP_CONTROL_UPDATE_SPINDLE_PWM);
|
bit_true(sys.step_control, STEP_CONTROL_UPDATE_SPINDLE_PWM);
|
||||||
} else {
|
} else {
|
||||||
#ifdef VARIABLE_SPINDLE
|
|
||||||
spindle_set_state((restore_condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)), restore_spindle_speed);
|
spindle_set_state((restore_condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)), restore_spindle_speed);
|
||||||
#else
|
|
||||||
spindle_set_state((restore_condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)));
|
|
||||||
#endif
|
|
||||||
delay_sec(SAFETY_DOOR_SPINDLE_DELAY, DELAY_MODE_SYS_SUSPEND);
|
delay_sec(SAFETY_DOOR_SPINDLE_DELAY, DELAY_MODE_SYS_SUSPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -712,11 +708,7 @@ static void protocol_exec_rt_suspend()
|
|||||||
// When in laser mode, ignore spindle spin-up delay. Set to turn on laser when cycle starts.
|
// When in laser mode, ignore spindle spin-up delay. Set to turn on laser when cycle starts.
|
||||||
bit_true(sys.step_control, STEP_CONTROL_UPDATE_SPINDLE_PWM);
|
bit_true(sys.step_control, STEP_CONTROL_UPDATE_SPINDLE_PWM);
|
||||||
} else {
|
} else {
|
||||||
#ifdef VARIABLE_SPINDLE
|
|
||||||
spindle_set_state((restore_condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)), restore_spindle_speed);
|
spindle_set_state((restore_condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)), restore_spindle_speed);
|
||||||
#else
|
|
||||||
spindle_set_state((restore_condition & (PL_COND_FLAG_SPINDLE_CW | PL_COND_FLAG_SPINDLE_CCW)));
|
|
||||||
#endif
|
|
||||||
delay_sec(SAFETY_DOOR_SPINDLE_DELAY, DELAY_MODE_SYS_SUSPEND);
|
delay_sec(SAFETY_DOOR_SPINDLE_DELAY, DELAY_MODE_SYS_SUSPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ void spindle_stop()
|
|||||||
#ifdef VARIABLE_SPINDLE
|
#ifdef VARIABLE_SPINDLE
|
||||||
void spindle_set_state(uint8_t state, float rpm)
|
void spindle_set_state(uint8_t state, float rpm)
|
||||||
#else
|
#else
|
||||||
void spindle_set_state(uint8_t state)
|
void _spindle_set_state(uint8_t state)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (sys.abort) { return; } // Block during abort.
|
if (sys.abort) { return; } // Block during abort.
|
||||||
@ -219,10 +219,10 @@ void spindle_stop()
|
|||||||
spindle_set_state(state,rpm);
|
spindle_set_state(state,rpm);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void spindle_sync(uint8_t state)
|
void _spindle_sync(uint8_t state)
|
||||||
{
|
{
|
||||||
if (sys.state == STATE_CHECK_MODE) { return; }
|
if (sys.state == STATE_CHECK_MODE) { return; }
|
||||||
protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
|
protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
|
||||||
spindle_set_state(state);
|
_spindle_set_state(state);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -57,10 +57,12 @@ uint8_t spindle_get_state();
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Called by g-code parser when setting spindle state and requires a buffer sync.
|
// Called by g-code parser when setting spindle state and requires a buffer sync.
|
||||||
void spindle_sync(uint8_t state);
|
#define spindle_sync(state, rpm) _spindle_sync(state)
|
||||||
|
void _spindle_sync(uint8_t state);
|
||||||
|
|
||||||
// Sets spindle running state with direction and enable.
|
// Sets spindle running state with direction and enable.
|
||||||
void spindle_set_state(uint8_t state);
|
#define spindle_set_state(state, rpm) _spindle_set_state(state)
|
||||||
|
void _spindle_set_state(uint8_t state);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user