Return None if reference_voltage is 0.0

This commit is contained in:
Kamil Tomaszewski 2019-10-14 08:18:17 +02:00
parent 6b9375804c
commit c67b2c1661

View File

@ -138,7 +138,13 @@ const mp_obj_property_t analogio_analogin_value_obj = {
STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) {
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return mp_obj_new_float(common_hal_analogio_analogin_get_reference_voltage(self));
float reference_voltage = common_hal_analogio_analogin_get_reference_voltage(self);
if (reference_voltage == 0.0f) {
return mp_const_none;
} else {
return mp_obj_new_float(reference_voltage);
}
}
MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_reference_voltage_obj,
analogio_analogin_obj_get_reference_voltage);