esp8266/modutime: Support float argument to time.sleep().

This commit is contained in:
Paul Sokolovsky 2016-02-03 15:24:11 +02:00
parent a4c8ef9d16
commit 6abafca1aa
1 changed files with 4 additions and 0 deletions

View File

@ -102,7 +102,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
/// \function sleep(seconds)
/// Sleep for the given number of seconds.
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
#if MICROPY_PY_BUILTINS_FLOAT
mp_hal_delay_ms(1000 * mp_obj_get_float(seconds_o));
#else
mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o));
#endif
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep);