From 76e9c2fc605c594c30ec15c4809f6201d60ba753 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Mon, 23 Oct 2023 15:15:06 +0200 Subject: [PATCH] pybricks.pupdevices.ColorSensor: Fix surface=False. This was putting the sensor in the wrong mode. Fixes https://github.com/pybricks/support/issues/1232 --- CHANGELOG.md | 2 ++ pybricks/pupdevices/pb_type_pupdevices_colorsensor.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14db1bd72..e3e28545a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,11 +18,13 @@ ### Fixed - Improved external device detection speed ([support#1140]). - Fixed Powered Up Tilt Sensor not working ([support#1189]). +- Fixed `surface=False` not working in `ColorSensor` ([support#1232]). [pybricks-micropython#104]: https://github.com/pybricks/pybricks-micropython/pull/104 [support#1054]: https://github.com/pybricks/support/issues/1054 [support#1140]: https://github.com/pybricks/support/issues/1140 [support#1189]: https://github.com/pybricks/support/issues/1189 +[support#1232]: https://github.com/pybricks/support/issues/1232 [support#1254]: https://github.com/pybricks/support/issues/1254 ## [3.3.0b8] - 2023-07-07 diff --git a/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c b/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c index ab961936d..74642864f 100644 --- a/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c +++ b/pybricks/pupdevices/pb_type_pupdevices_colorsensor.c @@ -100,7 +100,7 @@ STATIC mp_obj_t get_hsv_surface_false(mp_obj_t self_in) { get_hsv_ambient(self_in, &color->hsv); return MP_OBJ_FROM_PTR(color); } -STATIC PB_DEFINE_CONST_TYPE_DEVICE_METHOD_OBJ(get_hsv_surface_false_obj, PBDRV_LEGODEV_MODE_PUP_COLOR_SENSOR__RGB_I, get_hsv_surface_false); +STATIC PB_DEFINE_CONST_TYPE_DEVICE_METHOD_OBJ(get_hsv_surface_false_obj, PBDRV_LEGODEV_MODE_PUP_COLOR_SENSOR__SHSV, get_hsv_surface_false); // pybricks.pupdevices.ColorSensor.color(surface=True) STATIC mp_obj_t get_color_surface_true(mp_obj_t self_in) { @@ -118,7 +118,7 @@ STATIC mp_obj_t get_color_surface_false(mp_obj_t self_in) { pupdevices_ColorSensor_obj_t *self = MP_OBJ_TO_PTR(self_in); return pb_color_map_get_color(&self->color_map, &hsv); } -STATIC PB_DEFINE_CONST_TYPE_DEVICE_METHOD_OBJ(get_color_surface_false_obj, PBDRV_LEGODEV_MODE_PUP_COLOR_SENSOR__RGB_I, get_color_surface_false); +STATIC PB_DEFINE_CONST_TYPE_DEVICE_METHOD_OBJ(get_color_surface_false_obj, PBDRV_LEGODEV_MODE_PUP_COLOR_SENSOR__SHSV, get_color_surface_false); // pybricks.pupdevices.ColorSensor.hsv STATIC mp_obj_t get_hsv(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {