Added timeout for stepper drivers

This commit is contained in:
2026-01-05 00:34:54 +01:00
parent 457307a656
commit 3d8a16ffa0
2 changed files with 7 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ static double wheel_ratio_r = 1;
static uint prev_time;
static int prev_position_l = 0;
static int prev_position_r = 0;
static uint last_speed_change = 100;
static unsigned char stepper_instr[2+sizeof(double)*2] = {};
@@ -212,6 +213,7 @@ void stepper_fifo(char c, uint8_t itf) {
double vr = btod(stepper_instr + 10);
set_speeds(vl, vr);
last_speed_change = SPEED_SET_TIMEOUT;
// tud_cdc_n_write(itf, (uint8_t const *) stepper_instr, 18);
// tud_cdc_n_write_flush(itf);
@@ -263,6 +265,10 @@ int main()
while (true) {
if(last_speed_change--) {
set_speeds(0, 0);
last_speed_change = SPEED_SET_TIMEOUT;
}
tud_task();
sleep_ms(1);
}