Skip to content

Commit

Permalink
Merge branch 'master' into printnc_config
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmarles committed Jul 12, 2022
2 parents bac7ad1 + 5cf91f3 commit 73c3ecc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions grblHAL_Teensy4/src/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ static void spindleSetState (spindle_state_t state, float rpm)
static void spindle_set_speed (uint_fast16_t pwm_value)
{
if (pwm_value == spindle_pwm.off_value) {
if(settings.spindle.flags.pwm_action == SpindleAction_DisableWithZeroSPeed)
if(settings.spindle.flags.enable_rpm_controlled)
spindle_off();
pwmEnabled = false;
if(spindle_pwm.always_on) {
Expand Down Expand Up @@ -1215,16 +1215,19 @@ static uint_fast16_t spindleGetPWM (float rpm)
// Start or stop spindle.
static void spindleSetStateVariable (spindle_state_t state, float rpm)
{
if (!state.on || rpm == 0.0f) {
spindle_set_speed(spindle_pwm.off_value);
spindle_off();
} else {
#ifdef SPINDLE_DIRECTION_PIN
if (state.on)
spindle_dir(state.ccw);
#endif
spindle_set_speed(spindle_compute_pwm_value(&spindle_pwm, rpm, false));
if(!settings.spindle.flags.enable_rpm_controlled) {
if (state.on)
spindle_on();
else
spindle_off();
}

spindle_set_speed(state.on ? spindle_compute_pwm_value(&spindle_pwm, rpm, false) : spindle_pwm.off_value);

#if SPINDLE_SYNC_ENABLE
if(settings.spindle.at_speed_tolerance > 0.0f) {
float tolerance = rpm * settings.spindle.at_speed_tolerance / 100.0f;
Expand Down Expand Up @@ -1278,7 +1281,7 @@ static void spindlePulseOn (uint_fast16_t pulse_length)

bool spindleConfig (void)
{
if((hal.spindle.cap.variable = spindle_precompute_pwm_values(&spindle_pwm, F_BUS_ACTUAL / 2))) {
if((hal.spindle.cap.variable = !settings.spindle.flags.pwm_disable && spindle_precompute_pwm_values(&spindle_pwm, F_BUS_ACTUAL / 2))) {
#if SPINDLE_PWM_PIN == 12
TMR1_COMP11 = spindle_pwm.period;
TMR1_CMPLD11 = spindle_pwm.period;
Expand All @@ -1295,8 +1298,17 @@ bool spindleConfig (void)
TMR2_SCTRL0 &= ~TMR_SCTRL_OPS;
#endif
hal.spindle.set_state = spindleSetStateVariable;
} else
} else {
if(pwmEnabled)
hal.spindle.set_state((spindle_state_t){0}, 0.0f);
hal.spindle.set_state = spindleSetState;
}

#if SPINDLE_SYNC_ENABLE
hal.spindle.cap.at_speed = hal.spindle.get_data == spindleGetData;
#endif

spindle_update_caps(hal.spindle.cap.variable);

return true;
}
Expand Down Expand Up @@ -1478,8 +1490,6 @@ static void settings_changed (settings_t *settings)
{
if(IOInitDone) {

stepperEnable(settings->steppers.deenergize);

#ifdef SQUARING_ENABLED
hal.stepper.disable_motors((axes_signals_t){0}, SquaringMode_Both);
#endif
Expand All @@ -1491,7 +1501,7 @@ static void settings_changed (settings_t *settings)

#if SPINDLE_SYNC_ENABLE

if((hal.spindle.get_data = (hal.driver_cap.spindle_at_speed = settings->spindle.ppr > 0) ? spindleGetData : NULL) &&
if((hal.spindle.get_data = (hal.spindle.cap.at_speed = settings->spindle.ppr > 0) ? spindleGetData : NULL) &&
(spindle_encoder.ppr != settings->spindle.ppr || pidf_config_changed(&spindle_tracker.pid, &settings->position.pid))) {

hal.spindle.reset_data = spindleDataReset;
Expand Down Expand Up @@ -2233,7 +2243,7 @@ bool driver_init (void)
options[strlen(options) - 1] = '\0';

hal.info = "iMXRT1062";
hal.driver_version = "220325";
hal.driver_version = "220710";
#ifdef BOARD_NAME
hal.board = BOARD_NAME;
#endif
Expand Down
Binary file modified patches/sd_sdhc.zip
Binary file not shown.

0 comments on commit 73c3ecc

Please sign in to comment.