Skip to content

Commit

Permalink
pbio/servo: Swap dcmotor and tacho inits.
Browse files Browse the repository at this point in the history
At the drv level, the dc motor getter is performing several checks whether the motor is ready, so do those first.

pybricks/support#361
  • Loading branch information
laurensvalk committed Jun 4, 2021
1 parent f910978 commit f128560
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/pbio/src/servo.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ pbio_error_t pbio_servo_setup(pbio_servo_t *srv, pbio_direction_t direction, fix
return PBIO_ERROR_INVALID_OP;
}

// Get and reset tacho
err = pbio_tacho_get(srv->port, &srv->tacho, direction, gear_ratio);
// Get, coast, and configure dc motor
err = pbio_dcmotor_get(srv->port, &srv->dcmotor, direction, true);
if (err != PBIO_SUCCESS) {
return err;
}

// Get, coast, and configure dc motor
err = pbio_dcmotor_get(srv->port, &srv->dcmotor, direction, true);
// Get and reset tacho
err = pbio_tacho_get(srv->port, &srv->tacho, direction, gear_ratio);
if (err != PBIO_SUCCESS) {
return err;
}
Expand Down

0 comments on commit f128560

Please sign in to comment.