From c67b2c16619c456935dd93675b478668aeac0352 Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Mon, 14 Oct 2019 08:18:17 +0200 Subject: [PATCH] Return None if reference_voltage is 0.0 --- shared-bindings/analogio/AnalogIn.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index a8bbbf59af..de48ba082d 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -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);