modev3devices: negate device check option
This makes it match the API:
pybricks/pybricks-api/commit/b2ab7d70513bce4f6bf4e84829065ea9018618c4
@@ -574,20 +574,23 @@ typedef struct _ev3devices_AnalogSensor_obj_t {
STATIC mp_obj_t ev3devices_AnalogSensor_make_new(const mp_obj_type_t *otype, size_t n_args, size_t n_kw, const mp_obj_t *args ) {
PB_PARSE_ARGS_CLASS(n_args, n_kw, args,
PB_ARG_REQUIRED(port),
- PB_ARG_DEFAULT_FALSE(force)
+ PB_ARG_DEFAULT_TRUE(check_type)
);
ev3devices_AnalogSensor_obj_t *self = m_new_obj(ev3devices_AnalogSensor_obj_t);
self->base.type = (mp_obj_type_t*) otype;
mp_int_t port_num = enum_get_value_maybe(port, &pb_enum_type_Port);
- bool force_arg = mp_obj_is_true(force);
+ bool check_type_arg = mp_obj_is_true(check_type);
- if (force_arg) {
- // TODO: Force the port to user-specified analog
+ if (check_type_arg) {
+ // Get the device and assert that it is of the right type
+ pb_assert(ev3device_get_device(&self->iodev, PBIO_IODEV_TYPE_ID_NXT_ANALOG, port_num));
}
-
- // Get the device
+ 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));
+ }
// Initialize NXT sensors to passive state
int32_t voltage;
