Skip to content

Commit

Permalink
pybricks.common.LightArray: Fix off method.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Jun 8, 2023
1 parent 5850509 commit 6905609
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
is a tuple of `(name, num_values, data_type)` tuples for each available mode.

### Changed
- Changed internal drivers for LEGO devices on all platforms.
- Changed internal drivers for LEGO devices (motors and sensors) on all platforms.

### Fixed
- Fixed hub will not power off when Bluetooth chip crashes on City and Technic hubs ([support#1095]).
- Fixed `off()` method in `ColorLightMatrix`, `UltrasonicSensor`, `ColorSensor` ([support#1098]).

[support#1095]: https://github.com/pybricks/support/issues/1095
[support#1098]: https://github.com/pybricks/support/issues/1098

## [3.3.0b6] - 2023-06-02

Expand Down
8 changes: 4 additions & 4 deletions pybricks/common/pb_type_lightarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ STATIC mp_obj_t common_LightArray_on(size_t n_args, const mp_obj_t *pos_args, mp
}

// Set the brightness values and wait or await it.
return pb_type_device_set_data(self->sensor, self->light_mode, brightness_values, sizeof(brightness_values));
return pb_type_device_set_data(self->sensor, self->light_mode, brightness_values, self->number_of_lights);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(common_LightArray_on_obj, 1, common_LightArray_on);

// pybricks._common.LightArray.off
STATIC mp_obj_t common_LightArray_off(mp_obj_t self_in) {
const mp_obj_t pos_args[] = {self_in, MP_OBJ_NEW_SMALL_INT(0) };
common_LightArray_on(MP_ARRAY_SIZE(pos_args), pos_args, NULL);
return mp_const_none;
common_LightArray_obj_t *self = MP_OBJ_TO_PTR(self_in);
int8_t brightness_values[4] = { };
return pb_type_device_set_data(self->sensor, self->light_mode, brightness_values, self->number_of_lights);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(common_LightArray_off_obj, common_LightArray_off);

Expand Down
5 changes: 3 additions & 2 deletions pybricks/pupdevices/pb_type_pupdevices_colorlightmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pupdevices_ColorLightMatrix_on_obj, 1, pupdevi

// pybricks.pupdevices.ColorLightMatrix.off
STATIC mp_obj_t pupdevices_ColorLightMatrix_off(mp_obj_t self_in) {
const mp_obj_t pos_args[] = { self_in, MP_OBJ_FROM_PTR(&pb_Color_NONE_obj) };
return pupdevices_ColorLightMatrix_on(MP_ARRAY_SIZE(pos_args), pos_args, NULL);
pupdevices_ColorLightMatrix_obj_t *self = MP_OBJ_TO_PTR(self_in);
int8_t color_ids[9] = { };
return pb_type_device_set_data(&self->device_base, PBDRV_LEGODEV_MODE_PUP_COLOR_LIGHT_MATRIX__PIX_O, color_ids, sizeof(color_ids));
}
MP_DEFINE_CONST_FUN_OBJ_1(pupdevices_ColorLightMatrix_off_obj, pupdevices_ColorLightMatrix_off);

Expand Down

0 comments on commit 6905609

Please sign in to comment.