diff --git a/pycardium/modules/light_sensor.c b/pycardium/modules/light_sensor.c index f055ef28c5ea7911f86f49f87dfa070514bdc646..9b0d1a08760f77a2aceffc2a1fdb70fe073a0faa 100644 --- a/pycardium/modules/light_sensor.c +++ b/pycardium/modules/light_sensor.c @@ -5,7 +5,11 @@ STATIC mp_obj_t mp_light_sensor_start() { - epic_light_sensor_run(); + int status = epic_light_sensor_run(); + if (status == -EBUSY) + { + mp_raise_msg(&mp_type_RuntimeError, "timer could not be scheduled"); + } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_0(light_sensor_start_obj, mp_light_sensor_start); @@ -25,7 +29,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(light_sensor_get_obj, mp_light_sensor_get_readi STATIC mp_obj_t mp_light_sensor_stop() { - epic_light_sensor_stop(); + int status = epic_light_sensor_stop(); + if (status == -EBUSY) + { + mp_raise_msg(&mp_type_RuntimeError, "timer could not be scheduled"); + } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_0(light_sensor_stop_obj, mp_light_sensor_stop);