[Snek] [PATCH] Fix onfor() ignoring fractional parts of a second
Misha Gusarov
dottedmag at dottedmag.net
Mon Oct 12 09:03:45 PDT 2020
Signed-off-by: Misha Gusarov <dottedmag at dottedmag.net>
---
ports/ev3/motors.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ports/ev3/motors.c b/ports/ev3/motors.c
index 01e9105..92c929e 100644
--- a/ports/ev3/motors.c
+++ b/ports/ev3/motors.c
@@ -411,7 +411,7 @@ motor_onfor(int fd, snek_poly_t duration)
float fduration = snek_poly_get_float(duration);
- if (sysfs_write_int(fd, "time_sp", ((int) fduration * DURATION_SCALE)) == -1) {
+ if (sysfs_write_int(fd, "time_sp", (int) (fduration * DURATION_SCALE)) == -1) {
snek_error("unable to set run duration: %s", strerror(errno));
return SNEK_NULL;
}
--
2.28.0
More information about the Snek
mailing list