Verify XYZAC panel button parity

This commit is contained in:
2026-09-01 23:47:34 +08:00
parent 1342cff3f0
commit 492d862e45
12 changed files with 417 additions and 12 deletions

View File

@@ -263,6 +263,38 @@ int sim_io_spindle_command(sim_io *io, uint32_t spindle, double rpm, uint32_t en
return SIM_IO_OK;
}
int sim_io_spindle_adjust(sim_io *io, uint32_t spindle, double delta) {
sim_io_spindle_state *state;
double target;
if (!valid_spindle(io, spindle)) return SIM_IO_ERR_ARGUMENT;
if (!isfinite(delta)) { set_last(io, SIM_IO_ERR_NONFINITE); return SIM_IO_ERR_NONFINITE; }
if (io->state.estop) { set_last(io, SIM_IO_ERR_ESTOP); return SIM_IO_ERR_ESTOP; }
if (!io->state.ready) { set_last(io, SIM_IO_ERR_NOT_READY); return SIM_IO_ERR_NOT_READY; }
state = &io->state.spindles[spindle];
// Match LinuxCNC EMCMOT_SPINDLE_INCREASE/DECREASE: change the signed
// speed only while the spindle is running and keep its direction.
if (state->command_rpm > 0.0) target = state->command_rpm + delta;
else if (state->command_rpm < 0.0) target = state->command_rpm - delta;
else target = 0.0;
target = fmax(-state->max_rpm, fmin(state->max_rpm, target));
state->command_rpm = state->enabled && !state->inhibit && !state->amp_fault ? target : 0.0;
set_last(io, SIM_IO_OK);
mirror_pins(io);
return SIM_IO_OK;
}
int sim_io_spindle_brake(sim_io *io, uint32_t spindle, uint32_t engaged) {
sim_io_spindle_state *state;
if (!valid_spindle(io, spindle) || engaged > 1U) return SIM_IO_ERR_ARGUMENT;
if (io->state.estop) { set_last(io, SIM_IO_ERR_ESTOP); return SIM_IO_ERR_ESTOP; }
state = &io->state.spindles[spindle];
state->brake = engaged;
if (engaged) { state->command_rpm = 0.0; state->enabled = 0; state->speed_rpm = 0.0; state->forward = 0; state->reverse = 0; state->at_speed = 1; }
set_last(io, SIM_IO_OK);
mirror_pins(io);
return SIM_IO_OK;
}
int sim_io_spindle_set_inhibit(sim_io *io, uint32_t spindle, uint32_t inhibit) {
if (!valid_spindle(io, spindle) || inhibit > 1U) return SIM_IO_ERR_ARGUMENT;
io->state.spindles[spindle].inhibit = inhibit;