Skip to content

Commit 731b2ed

Browse files
committed
pybricks.nxtdevices.TouchSensor: Initialize analog value.
The DCM with analog reads has not yet been implemented on NXT, and the compiler doesn't know that the unused value won't be used on raise. For now make the compiler happy by just initializing it.
1 parent e3f342e commit 731b2ed

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pybricks/nxtdevices/pb_type_nxtdevices_soundsensor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static mp_obj_t nxtdevices_SoundSensor_intensity(size_t n_args, const mp_obj_t *
3838
nxtdevices_SoundSensor_obj_t, self,
3939
PB_ARG_DEFAULT_TRUE(audible_only));
4040

41-
uint32_t analog;
41+
uint32_t analog = 0;
4242
pb_assert(pbio_port_get_analog_value(self->port, LEGO_DEVICE_TYPE_ID_NXT_SOUND_SENSOR, mp_obj_is_true(audible_only_in), &analog));
4343
return mp_obj_new_int(analog_scale(analog, 650, 4860, true));
4444
}

pybricks/nxtdevices/pb_type_nxtdevices_touchsensor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ typedef struct _nxtdevices_TouchSensor_obj_t {
2525
// pybricks.nxtdevices.TouchSensor.pressed
2626
static mp_obj_t nxtdevices_TouchSensor_pressed(mp_obj_t self_in) {
2727
nxtdevices_TouchSensor_obj_t *self = MP_OBJ_TO_PTR(self_in);
28-
uint32_t analog;
28+
uint32_t analog = 0;
2929
pb_assert(pbio_port_get_analog_value(self->port, LEGO_DEVICE_TYPE_ID_NXT_TOUCH_SENSOR, false, &analog));
3030
return mp_obj_new_bool(analog < 3000);
3131
}

0 commit comments

Comments
 (0)