Skip to content

Commit

Permalink
pybricks.pupdevices.ColorSensor: remove power hack
Browse files Browse the repository at this point in the history
Sensors that require power are now automatically powered when plugged in, so we no longer need this hack at the module level.

This also lets us remove the hardcoded delay so scripts with this sensor start more quickly.
  • Loading branch information
laurensvalk committed Dec 23, 2020
1 parent 9c9dfa2 commit fccd9b5
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions pybricks/pupdevices/pb_type_pupdevices_colorsensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ STATIC mp_obj_t pupdevices_ColorSensor_make_new(const mp_obj_type_t *type, size_
// Get iodevices
self->pbdev = pb_device_get_device(port, PBIO_IODEV_TYPE_ID_SPIKE_COLOR_SENSOR);

// This sensor requires power, which iodevice does not do automatically yet
pb_device_set_power_supply(self->pbdev, 100);

// Create an instance of the LightArray class
self->lights = common_LightArray_obj_make_new(self->pbdev, PBIO_IODEV_MODE_PUP_COLOR_SENSOR__LIGHT, 3);

Expand All @@ -86,9 +83,6 @@ STATIC mp_obj_t pupdevices_ColorSensor_make_new(const mp_obj_type_t *type, size_
// Save default settings
pb_color_map_save_default(&self->color_map);

// This sensor needs some time to get values right after turning power on
mp_hal_delay_ms(1000);

return MP_OBJ_FROM_PTR(self);
}

Expand Down

0 comments on commit fccd9b5

Please sign in to comment.