mirror of
https://github.com/m5stack/M5Stack_MicroPython.git
synced 2026-05-20 10:14:44 -07:00
Fixed bug in utime.sleep & utime.sleep_ms
This commit is contained in:
@@ -22,6 +22,7 @@ build/
|
||||
|
||||
patches/
|
||||
|
||||
partitions_mpy.csv
|
||||
sdkconfig
|
||||
sdkconfig.old
|
||||
_sdkconfig.saved
|
||||
|
||||
@@ -36,24 +36,34 @@
|
||||
#include "py/runtime.h"
|
||||
#include "extmod/utime_mphal.h"
|
||||
|
||||
//----------------------------------------------
|
||||
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
|
||||
//------------------------------------------------------------------
|
||||
STATIC mp_obj_t time_sleep(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
uint32_t t = mp_hal_delay_ms((mp_uint_t)(1000 * mp_obj_get_float(seconds_o)));
|
||||
uint32_t t = mp_hal_delay_ms((mp_uint_t)(1000 * mp_obj_get_float(args[0])));
|
||||
#else
|
||||
uint32_t t = mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o));
|
||||
uint32_t t = mp_hal_delay_ms(1000 * mp_obj_get_int(args[0]));
|
||||
#endif
|
||||
return MP_OBJ_NEW_SMALL_INT(t);
|
||||
if ((n_args > 1) && (mp_obj_is_true(args[1]))) {
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
return mp_obj_new_float((float)t / 1000.0);
|
||||
#else
|
||||
return MP_OBJ_NEW_SMALL_INT(t);
|
||||
#endif
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_utime_sleep_obj, 1, 2, time_sleep);
|
||||
|
||||
//-------------------------------------------
|
||||
STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
|
||||
mp_int_t ms = mp_obj_get_int(arg);
|
||||
//---------------------------------------------------------------------
|
||||
STATIC mp_obj_t time_sleep_ms(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_int_t ms = mp_obj_get_int(args[0]);
|
||||
uint32_t t = mp_hal_delay_ms(ms);
|
||||
return MP_OBJ_NEW_SMALL_INT(t);
|
||||
if ((n_args > 1) && (mp_obj_is_true(args[1]))) {
|
||||
return MP_OBJ_NEW_SMALL_INT(t);
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms);
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_utime_sleep_ms_obj, 1, 2, time_sleep_ms);
|
||||
|
||||
//-------------------------------------------
|
||||
STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_utime_sleep_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_utime_sleep_ms_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_ms_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ_0(mp_utime_ticks_us_obj);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# -------------------------------------------------------
|
||||
# - Partition layout generaded by BUILD.sh script -
|
||||
# -------------------------------------------------------
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# -------------------------------------------------------
|
||||
nvs, data, nvs, 0x9000, 24K,
|
||||
phy_init, data, phy, 0xf000, 4K,
|
||||
MicroPython, app, factory, 0x10000, 1920K,
|
||||
internalfs, data, spiffs, , 1024K,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user