Commit fd379db2 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

unix/modtime: Implement sleep_ms(), sleep_us().

parent 096d1e45
......@@ -97,10 +97,24 @@ STATIC mp_obj_t mod_time_sleep(mp_obj_t arg) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_obj, mod_time_sleep);
STATIC mp_obj_t mod_time_sleep_ms(mp_obj_t arg) {
usleep(mp_obj_get_int(arg) * 1000);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_ms_obj, mod_time_sleep_ms);
STATIC mp_obj_t mod_time_sleep_us(mp_obj_t arg) {
usleep(mp_obj_get_int(arg));
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_us_obj, mod_time_sleep_us);
STATIC const mp_map_elem_t mp_module_time_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_utime) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_clock), (mp_obj_t)&mod_time_clock_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep), (mp_obj_t)&mod_time_sleep_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep_ms), (mp_obj_t)&mod_time_sleep_ms_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep_us), (mp_obj_t)&mod_time_sleep_us_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mod_time_time_obj },
};
......
......@@ -60,6 +60,8 @@ Q(utime)
Q(time)
Q(clock)
Q(sleep)
Q(sleep_ms)
Q(sleep_us)
Q(socket)
Q(sockaddr_in)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment