Skip to content

Commit 6abafca

Browse files
committed
esp8266/modutime: Support float argument to time.sleep().
1 parent a4c8ef9 commit 6abafca

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

esp8266/modutime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
102102
/// \function sleep(seconds)
103103
/// Sleep for the given number of seconds.
104104
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
105+
#if MICROPY_PY_BUILTINS_FLOAT
106+
mp_hal_delay_ms(1000 * mp_obj_get_float(seconds_o));
107+
#else
105108
mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o));
109+
#endif
106110
return mp_const_none;
107111
}
108112
MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep);

0 commit comments

Comments
 (0)