From 1970ca2ae14bcf1baff4811d7adf73e4239459ec Mon Sep 17 00:00:00 2001 From: R Date: Thu, 17 Jul 2025 20:27:16 +0100 Subject: [PATCH] pybricks/ev3devices: Enable remaining device support This compiles, and IR distance measurement appears to be working correctly. Ultrasonic sensors and gyro have not been manually tested but are expected to work as they share the common UART protocol handling. --- pybricks/ev3devices.h | 9 ++------- pybricks/ev3devices/pb_module_ev3devices.c | 2 -- pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c | 4 ++-- pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c | 4 ++-- .../ev3devices/pb_type_ev3devices_ultrasonicsensor.c | 4 ++-- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pybricks/ev3devices.h b/pybricks/ev3devices.h index 324951349..5cc6ce76a 100644 --- a/pybricks/ev3devices.h +++ b/pybricks/ev3devices.h @@ -12,15 +12,10 @@ extern const mp_obj_type_t pb_type_ev3devices_TouchSensor; extern const mp_obj_type_t pb_type_ev3devices_ColorSensor; - -#endif // PYBRICKS_PY_EV3DEVICES - -#if PYBRICKS_PY_EV3DEVDEVICES - extern const mp_obj_type_t pb_type_ev3devices_InfraredSensor; -extern const mp_obj_type_t pb_type_ev3devices_GyroSensor; extern const mp_obj_type_t pb_type_ev3devices_UltrasonicSensor; +extern const mp_obj_type_t pb_type_ev3devices_GyroSensor; -#endif // PYBRICKS_PY_EV3DEVDEVICES +#endif // PYBRICKS_PY_EV3DEVICES #endif // PYBRICKS_INCLUDED_PYBRICKS_EV3DEVICES_H diff --git a/pybricks/ev3devices/pb_module_ev3devices.c b/pybricks/ev3devices/pb_module_ev3devices.c index e6a36160d..5c6a8348e 100644 --- a/pybricks/ev3devices/pb_module_ev3devices.c +++ b/pybricks/ev3devices/pb_module_ev3devices.c @@ -15,11 +15,9 @@ static const mp_rom_map_elem_t ev3devices_globals_table[] = { #endif { MP_ROM_QSTR(MP_QSTR_TouchSensor), MP_ROM_PTR(&pb_type_ev3devices_TouchSensor) }, { MP_ROM_QSTR(MP_QSTR_ColorSensor), MP_ROM_PTR(&pb_type_ev3devices_ColorSensor) }, - #if PYBRICKS_PY_EV3DEVDEVICES { MP_ROM_QSTR(MP_QSTR_InfraredSensor), MP_ROM_PTR(&pb_type_ev3devices_InfraredSensor) }, { MP_ROM_QSTR(MP_QSTR_UltrasonicSensor), MP_ROM_PTR(&pb_type_ev3devices_UltrasonicSensor)}, { MP_ROM_QSTR(MP_QSTR_GyroSensor), MP_ROM_PTR(&pb_type_ev3devices_GyroSensor) }, - #endif }; static MP_DEFINE_CONST_DICT(pb_module_ev3devices_globals, ev3devices_globals_table); diff --git a/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c b/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c index 73f336d8f..1ab7e2353 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_gyrosensor.c @@ -3,7 +3,7 @@ #include "py/mpconfig.h" -#if PYBRICKS_PY_EV3DEVDEVICES +#if PYBRICKS_PY_EV3DEVICES #include #include @@ -103,4 +103,4 @@ MP_DEFINE_CONST_OBJ_TYPE(pb_type_ev3devices_GyroSensor, make_new, ev3devices_GyroSensor_make_new, locals_dict, &ev3devices_GyroSensor_locals_dict); -#endif // PYBRICKS_PY_EV3DEVDEVICES +#endif // PYBRICKS_PY_EV3DEVICES diff --git a/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c b/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c index a40866ca8..20ee09af7 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_infraredsensor.c @@ -3,7 +3,7 @@ #include "py/mpconfig.h" -#if PYBRICKS_PY_EV3DEVDEVICES +#if PYBRICKS_PY_EV3DEVICES #include #include @@ -181,4 +181,4 @@ MP_DEFINE_CONST_OBJ_TYPE(pb_type_ev3devices_InfraredSensor, make_new, ev3devices_InfraredSensor_make_new, locals_dict, &ev3devices_InfraredSensor_locals_dict); -#endif // PYBRICKS_PY_EV3DEVDEVICES +#endif // PYBRICKS_PY_EV3DEVICES diff --git a/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c b/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c index 46d0b8861..a48bdf6d3 100644 --- a/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c +++ b/pybricks/ev3devices/pb_type_ev3devices_ultrasonicsensor.c @@ -3,7 +3,7 @@ #include "py/mpconfig.h" -#if PYBRICKS_PY_EV3DEVDEVICES +#if PYBRICKS_PY_EV3DEVICES #include #include @@ -63,4 +63,4 @@ MP_DEFINE_CONST_OBJ_TYPE(pb_type_ev3devices_UltrasonicSensor, make_new, ev3devices_UltrasonicSensor_make_new, locals_dict, &ev3devices_UltrasonicSensor_locals_dict); -#endif // PYBRICKS_PY_EV3DEVDEVICES +#endif // PYBRICKS_PY_EV3DEVICES