modev3devices: allow custom analog sensor
If we get PBIO_ERROR_AGAIN, this means we should try again because it was still busy switching modes.
@@ -588,8 +588,12 @@ STATIC mp_obj_t ev3devices_AnalogSensor_make_new(const mp_obj_type_t *otype, siz
}
else {
// Set the sensor as a custom NXT Analog Sensor
- // (TODO)
- pb_assert(ev3device_get_device(&self->iodev, PBIO_IODEV_TYPE_ID_NXT_ANALOG, port_num));
+ pbio_error_t err = PBIO_ERROR_AGAIN;
+ while (err == PBIO_ERROR_AGAIN) {
+ err = ev3device_get_device(&self->iodev, PBIO_IODEV_TYPE_ID_NXT_ANALOG_CUSTOM, port_num);
+ mp_hal_delay_ms(500);
+ }
+ pb_assert(err);
}
// Initialize NXT sensors to passive state
