File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -70,14 +70,16 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic);
70
70
//|
71
71
STATIC mp_obj_t time_sleep (mp_obj_t seconds_o ) {
72
72
#if MICROPY_PY_BUILTINS_FLOAT
73
- float seconds = mp_obj_get_float (seconds_o );
73
+ mp_float_t seconds = mp_obj_get_float (seconds_o );
74
+ mp_float_t msecs = 1000.0f * seconds + 0.5f ;
74
75
#else
75
- int seconds = mp_obj_get_int (seconds_o );
76
+ mp_int_t seconds = mp_obj_get_int (seconds_o );
77
+ mp_int_t msecs = 1000 * seconds ;
76
78
#endif
77
79
if (seconds < 0 ) {
78
80
mp_raise_ValueError (translate ("sleep length must be non-negative" ));
79
81
}
80
- common_hal_time_delay_ms (1000 * seconds );
82
+ common_hal_time_delay_ms (msecs );
81
83
return mp_const_none ;
82
84
}
83
85
MP_DEFINE_CONST_FUN_OBJ_1 (time_sleep_obj , time_sleep );
You can’t perform that action at this time.
0 commit comments