Skip to content

Commit b9295f8

Browse files
committed
extmod/modpupdevices/InfraredSensor: resolution
By returning a floating point value on supported platforms, the resolution is much higher, which is useful when using the reflection value in a feedback controller.
1 parent b7b4668 commit b9295f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extmod/modpupdevices.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pupdevices_InfraredSensor_count_obj, pupdevices
573573
STATIC mp_obj_t pupdevices_InfraredSensor_reflection(mp_obj_t self_in) {
574574
pupdevices_InfraredSensor_obj_t *self = MP_OBJ_TO_PTR(self_in);
575575
int32_t raw = pupdevices_InfraredSensor__raw(self->pbdev);
576-
return mp_obj_new_int(raw / 5);
576+
return pb_obj_new_fraction(raw, 5);
577577
}
578578
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pupdevices_InfraredSensor_reflection_obj, pupdevices_InfraredSensor_reflection);
579579

0 commit comments

Comments
 (0)