Skip to content

Commit

Permalink
pybricks.pupdevices.ColorSensor: Fix surface=False.
Browse files Browse the repository at this point in the history
This was putting the sensor in the wrong mode.

Fixes pybricks/support#1232
  • Loading branch information
laurensvalk committed Oct 23, 2023
1 parent 5e83281 commit 76e9c2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pybricks/pupdevices/pb_type_pupdevices_colorsensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 76e9c2f

Please sign in to comment.