mirror of
https://github.com/m5stack/M5Stack_MicroPython.git
synced 2026-05-20 10:14:44 -07:00
some modif
This commit is contained in:
@@ -68,7 +68,7 @@ typedef struct _mp_machine_i2c_obj_t {
|
||||
|
||||
const mp_obj_type_t machine_hw_i2c_type;
|
||||
|
||||
static int i2c_used[I2C_MODE_MAX] = { 21, 22 };
|
||||
static int i2c_used[I2C_MODE_MAX] = { -1, -1 };
|
||||
static QueueHandle_t slave_mutex = NULL;
|
||||
static TaskHandle_t i2c_slave_task_handle[I2C_MODE_MAX] = { NULL, NULL };
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ soft_reset:
|
||||
int res = mount_vfs(VFS_NATIVE_TYPE_SPIFLASH, VFS_NATIVE_INTERNAL_MP);
|
||||
if (res == 0) {
|
||||
// run boot-up script 'boot.py'
|
||||
pyexec_frozen_module("_boot.py");
|
||||
pyexec_file("boot.py");
|
||||
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
|
||||
// Check if 'main.py' exists and run it
|
||||
|
||||
@@ -330,7 +330,7 @@ STATIC mp_obj_t display_tft_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
|
||||
// }
|
||||
|
||||
_fg = intToColor(iTFT_WHITE);
|
||||
// bcklOn(&self->dconfig);
|
||||
bcklOn(&self->dconfig);
|
||||
led_pwm_init();
|
||||
|
||||
return mp_const_none;
|
||||
@@ -965,10 +965,6 @@ STATIC mp_obj_t display_tft_println(size_t n_args, const mp_obj_t *pos_args, mp_
|
||||
display_tft_print(n_args, pos_args, kw_args);
|
||||
TFT_print("\r\n", TFT_X, TFT_Y);
|
||||
|
||||
// mp_obj_t tuple[2];
|
||||
// tuple[0] = mp_obj_new_int(TFT_X);
|
||||
// tuple[1] = mp_obj_new_int(TFT_Y);
|
||||
// return mp_obj_new_tuple(2, tuple);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_println_obj, 1, display_tft_println);
|
||||
@@ -1313,39 +1309,39 @@ STATIC mp_obj_t display_tft_getWinSize(size_t n_args, const mp_obj_t *pos_args,
|
||||
return mp_obj_new_tuple(2, tuple);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_getWinSize_obj, 0, display_tft_getWinSize);
|
||||
|
||||
#if 0
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// STATIC mp_obj_t display_tft_setCalib(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t display_tft_setCalib(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
||||
// const mp_arg_t allowed_args[] = {
|
||||
// { MP_QSTR_calx, MP_ARG_INT, { .u_int = 0 } },
|
||||
// { MP_QSTR_caly, MP_ARG_INT, { .u_int = 0 } },
|
||||
// };
|
||||
// display_tft_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
// if (setupDevice(self)) return mp_const_none;
|
||||
const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_calx, MP_ARG_INT, { .u_int = 0 } },
|
||||
{ MP_QSTR_caly, MP_ARG_INT, { .u_int = 0 } },
|
||||
};
|
||||
display_tft_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
if (setupDevice(self)) return mp_const_none;
|
||||
|
||||
// mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
// mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
// if (self->tp_type == TOUCH_TYPE_NONE) {
|
||||
// return mp_const_none;
|
||||
// }
|
||||
if (self->tp_type == TOUCH_TYPE_NONE) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
// if (args[0].u_int == 0) {
|
||||
// if (self->tp_type == TOUCH_TYPE_XPT2046) self->tp_calx = TP_CALX_XPT2046;
|
||||
// else self->tp_calx = TP_CALX_STMPE610;
|
||||
// }
|
||||
// else self->tp_calx = args[0].u_int;
|
||||
|
||||
// if (args[0].u_int == 0) {
|
||||
// if (self->tp_type == TOUCH_TYPE_XPT2046) self->tp_caly = TP_CALY_XPT2046;
|
||||
// else self->tp_caly = TP_CALY_STMPE610;
|
||||
// }
|
||||
// else self->tp_caly = args[1].u_int;
|
||||
// return mp_const_none;
|
||||
// }
|
||||
// STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setCalib_obj, 0, display_tft_setCalib);
|
||||
if (args[0].u_int == 0) {
|
||||
if (self->tp_type == TOUCH_TYPE_XPT2046) self->tp_calx = TP_CALX_XPT2046;
|
||||
else self->tp_calx = TP_CALX_STMPE610;
|
||||
}
|
||||
else self->tp_calx = args[0].u_int;
|
||||
|
||||
if (args[0].u_int == 0) {
|
||||
if (self->tp_type == TOUCH_TYPE_XPT2046) self->tp_caly = TP_CALY_XPT2046;
|
||||
else self->tp_caly = TP_CALY_STMPE610;
|
||||
}
|
||||
else self->tp_caly = args[1].u_int;
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(display_tft_setCalib_obj, 0, display_tft_setCalib);
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
STATIC mp_obj_t display_tft_setColor(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ def _boot():
|
||||
from m5stack import lcd, buttonA
|
||||
import utils
|
||||
if buttonA.isPressed():
|
||||
lcd.println('On: SAFE Mode, ignore run main.py', color=lcd.RED)
|
||||
if utils.exists('main.py'):
|
||||
if utils.exists('_main.py'):
|
||||
os.remove('_main.py')
|
||||
else:
|
||||
os.rename('main.py', '_main.py')
|
||||
lcd.println('On: SAFE Mode, ignore run main.py', color=lcd.ORANGE)
|
||||
os.rename('main.py', '_main.py')
|
||||
else:
|
||||
if not utils.exists('main.py'):
|
||||
if utils.exists('_main.py'):
|
||||
os.rename('_main.py', 'main.py')
|
||||
else:
|
||||
if utils.exists('main.py'):
|
||||
if utils.exists('_main.py'):
|
||||
os.remove('_main.py')
|
||||
else:
|
||||
if utils.exists('_main.py'):
|
||||
os.rename('_main.py', 'main.py')
|
||||
|
||||
|
||||
_boot()
|
||||
gc.collect()
|
||||
@@ -9,14 +9,11 @@ import sys
|
||||
sys.path[1] = '/flash/lib'
|
||||
|
||||
# ---------- M5Cloud ------------
|
||||
M5Cloud_Enable = True
|
||||
|
||||
if M5Cloud_Enable:
|
||||
if True:
|
||||
from m5stack import lcd, buttonA, buttonB
|
||||
if buttonB.isPressed():
|
||||
lcd.println('On: OFF-LINE Mode', color=lcd.ORANGE)
|
||||
elif not buttonA.isPressed():
|
||||
lcd.println('On: M5Cloud Mode', color=0xCCCCCC)
|
||||
else:
|
||||
import wifisetup
|
||||
import m5cloud
|
||||
""")
|
||||
@@ -25,8 +22,12 @@ if M5Cloud_Enable:
|
||||
f.write("""\
|
||||
from m5stack import lcd
|
||||
|
||||
#lcd.clear()
|
||||
#lcd.print("Hello world!")
|
||||
'''
|
||||
lcd.clear()
|
||||
lcd.setCursor(0, 0)
|
||||
lcd.setColor(lcd.WHITE)
|
||||
lcd.print("Hello world!")
|
||||
'''
|
||||
""")
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART --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
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import sys
|
||||
|
||||
OFFSET_BOOTLOADER = 0x1000
|
||||
OFFSET_PARTITIONS = 0x8000
|
||||
OFFSET_PHY_INIT_DATA = 0xf000
|
||||
OFFSET_APPLICATION = 0x10000
|
||||
|
||||
files_in = [
|
||||
('bootloader', OFFSET_BOOTLOADER, 'bootloader/bootloader.bin'),
|
||||
('partitions', OFFSET_PARTITIONS, 'partitions_mpy.bin'),
|
||||
('phy_init_data', OFFSET_PHY_INIT_DATA, 'phy_init_data.bin'),
|
||||
('application', OFFSET_APPLICATION, 'MicroPython.bin'),
|
||||
]
|
||||
# file_out = sys.argv[1]
|
||||
file_out = 'firmware.bin'
|
||||
|
||||
cur_offset = OFFSET_BOOTLOADER
|
||||
with open(file_out, 'wb') as fout:
|
||||
for name, offset, file_in in files_in:
|
||||
assert offset >= cur_offset
|
||||
fout.write(b'\xff' * (offset - cur_offset))
|
||||
cur_offset = offset
|
||||
with open(file_in, 'rb') as fin:
|
||||
data = fin.read()
|
||||
fout.write(data)
|
||||
cur_offset += len(data)
|
||||
print('%-12s% 8d' % (name, len(data)))
|
||||
print('%-12s% 8d' % ('total', cur_offset))
|
||||
Binary file not shown.
@@ -5,5 +5,5 @@
|
||||
# -------------------------------------------------------
|
||||
nvs, data, nvs, 0x9000, 24K,
|
||||
phy_init, data, phy, 0xf000, 4K,
|
||||
MicroPython, app, factory, 0x10000, 1344K,
|
||||
internalfs, data, spiffs, , 1024K,
|
||||
MicroPython, app, factory, 0x10000, 1600K,
|
||||
internalfs, data, spiffs, , 2432K,
|
||||
|
||||
|
@@ -15,11 +15,11 @@ CONFIG_MAKE_WARN_UNDEFINED_VARIABLES=y
|
||||
#
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_NONE=
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_ERROR=
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG=
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE=
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL=3
|
||||
CONFIG_LOG_BOOTLOADER_LEVEL=2
|
||||
CONFIG_BOOTLOADER_VDDSDIO_BOOST=y
|
||||
|
||||
#
|
||||
@@ -31,7 +31,7 @@ CONFIG_FLASH_ENCRYPTION_ENABLED=
|
||||
#
|
||||
# Serial flasher config
|
||||
#
|
||||
CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB0"
|
||||
CONFIG_ESPTOOLPY_PORT="/dev/tty.SLAB_USBtoUART"
|
||||
CONFIG_ESPTOOLPY_BAUD_115200B=
|
||||
CONFIG_ESPTOOLPY_BAUD_230400B=
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
@@ -76,7 +76,7 @@ CONFIG_MONITOR_BAUD=115200
|
||||
#
|
||||
# MicroPython
|
||||
#
|
||||
CONFIG_MICROPY_HW_BOARD_NAME="ESP32 board"
|
||||
CONFIG_MICROPY_HW_BOARD_NAME="M5Stack"
|
||||
CONFIG_MICROPY_HW_MCU_NAME="ESP32"
|
||||
CONFIG_MICROPY_TIMEZONE="GMT0BST"
|
||||
CONFIG_MICROPY_USE_OTA=
|
||||
@@ -119,15 +119,18 @@ CONFIG_MICROPY_FTPSERVER_BUFFER_SIZE=1024
|
||||
# Modules
|
||||
#
|
||||
CONFIG_MICROPY_PY_FRAMEBUF=y
|
||||
CONFIG_MICROPY_PY_USE_BTREE=
|
||||
CONFIG_MICROPY_USE_WEBSOCKETS=
|
||||
CONFIG_MICROPY_PY_USE_BTREE=y
|
||||
CONFIG_MICROPY_USE_WEBSOCKETS=y
|
||||
CONFIG_MICROPY_USE_DISPLAY=y
|
||||
CONFIG_MICROPY_USE_EVE=
|
||||
CONFIG_MICROPY_USE_GSM=
|
||||
CONFIG_MICROPY_USE_GSM=y
|
||||
CONFIG_MICROPY_USE_ETHERNET=
|
||||
CONFIG_MICROPY_USE_MDNS=y
|
||||
CONFIG_MICROPY_USE_CURL=
|
||||
CONFIG_MICROPY_USE_SSH=
|
||||
CONFIG_MICROPY_USE_CURL=y
|
||||
CONFIG_MICROPY_USE_CURL_TLS=y
|
||||
CONFIG_MICROPY_USE_CURLFTP=
|
||||
CONFIG_MICROPY_USE_MAIL=y
|
||||
CONFIG_MICROPY_USE_SSH=y
|
||||
CONFIG_MICROPY_USE_MQTT=y
|
||||
|
||||
#
|
||||
@@ -135,8 +138,8 @@ CONFIG_MICROPY_USE_MQTT=y
|
||||
#
|
||||
CONFIG_MQTT_PROTOCOL_311=y
|
||||
CONFIG_MQTT_PRIORITY=5
|
||||
CONFIG_MQTT_BUFFER_SIZE_BYTE=256
|
||||
CONFIG_MQTT_MAX_PAYLOAD_SIZE=2048
|
||||
CONFIG_MQTT_BUFFER_SIZE_BYTE=2048
|
||||
CONFIG_MQTT_MAX_PAYLOAD_SIZE=4094
|
||||
CONFIG_MQTT_LOG_LEVEL=1
|
||||
CONFIG_MQTT_LOG_LEVEL0=
|
||||
CONFIG_MQTT_LOG_LEVEL1=y
|
||||
@@ -154,10 +157,14 @@ CONFIG_MICROPY_SDMMC_SHOW_INFO=y
|
||||
#
|
||||
# SD Card configuration
|
||||
#
|
||||
CONFIG_SDCARD_MODE=3
|
||||
CONFIG_SDCARD_MODE1=
|
||||
CONFIG_SDCARD_MODE=1
|
||||
CONFIG_SDCARD_MODE1=y
|
||||
CONFIG_SDCARD_MODE2=
|
||||
CONFIG_SDCARD_MODE3=y
|
||||
CONFIG_SDCARD_MODE3=
|
||||
CONFIG_SDCARD_CLK=18
|
||||
CONFIG_SDCARD_MOSI=23
|
||||
CONFIG_SDCARD_MISO=19
|
||||
CONFIG_SDCARD_CS=4
|
||||
|
||||
#
|
||||
# Partition Table
|
||||
@@ -176,8 +183,8 @@ CONFIG_PARTITION_TABLE_MD5=y
|
||||
#
|
||||
# Compiler options
|
||||
#
|
||||
CONFIG_OPTIMIZATION_LEVEL_DEBUG=y
|
||||
CONFIG_OPTIMIZATION_LEVEL_RELEASE=
|
||||
CONFIG_OPTIMIZATION_LEVEL_DEBUG=
|
||||
CONFIG_OPTIMIZATION_LEVEL_RELEASE=y
|
||||
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
|
||||
CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=
|
||||
CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED=
|
||||
@@ -233,7 +240,7 @@ CONFIG_TWO_UNIVERSAL_MAC_ADDRESS=
|
||||
CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y
|
||||
CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4
|
||||
CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32
|
||||
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048
|
||||
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304
|
||||
CONFIG_MAIN_TASK_STACK_SIZE=3584
|
||||
CONFIG_IPC_TASK_STACK_SIZE=1024
|
||||
CONFIG_TIMER_TASK_STACK_SIZE=3584
|
||||
@@ -251,8 +258,8 @@ CONFIG_CONSOLE_UART_NUM=0
|
||||
CONFIG_CONSOLE_UART_BAUDRATE=115200
|
||||
CONFIG_ULP_COPROC_ENABLED=
|
||||
CONFIG_ULP_COPROC_RESERVE_MEM=0
|
||||
CONFIG_ESP32_PANIC_PRINT_HALT=y
|
||||
CONFIG_ESP32_PANIC_PRINT_REBOOT=
|
||||
CONFIG_ESP32_PANIC_PRINT_HALT=
|
||||
CONFIG_ESP32_PANIC_PRINT_REBOOT=y
|
||||
CONFIG_ESP32_PANIC_SILENT_REBOOT=
|
||||
CONFIG_ESP32_PANIC_GDBSTUB=
|
||||
CONFIG_ESP32_DEBUG_OCDAWARE=y
|
||||
@@ -417,11 +424,11 @@ CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
#
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=
|
||||
CONFIG_LOG_DEFAULT_LEVEL_ERROR=
|
||||
CONFIG_LOG_DEFAULT_LEVEL_WARN=
|
||||
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_INFO=
|
||||
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=
|
||||
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=
|
||||
CONFIG_LOG_DEFAULT_LEVEL=4
|
||||
CONFIG_LOG_DEFAULT_LEVEL=2
|
||||
CONFIG_LOG_COLORS=y
|
||||
|
||||
#
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART --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
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import sys
|
||||
|
||||
OFFSET_BOOTLOADER = 0x1000
|
||||
OFFSET_PARTITIONS = 0x8000
|
||||
OFFSET_PHY_INIT_DATA = 0xf000
|
||||
OFFSET_APPLICATION = 0x10000
|
||||
|
||||
files_in = [
|
||||
('bootloader', OFFSET_BOOTLOADER, 'bootloader/bootloader.bin'),
|
||||
('partitions', OFFSET_PARTITIONS, 'partitions_mpy.bin'),
|
||||
('phy_init_data', OFFSET_PHY_INIT_DATA, 'phy_init_data.bin'),
|
||||
('application', OFFSET_APPLICATION, 'MicroPython.bin'),
|
||||
]
|
||||
# file_out = sys.argv[1]
|
||||
file_out = 'firmware.bin'
|
||||
|
||||
cur_offset = OFFSET_BOOTLOADER
|
||||
with open(file_out, 'wb') as fout:
|
||||
for name, offset, file_in in files_in:
|
||||
assert offset >= cur_offset
|
||||
fout.write(b'\xff' * (offset - cur_offset))
|
||||
cur_offset = offset
|
||||
with open(file_in, 'rb') as fin:
|
||||
data = fin.read()
|
||||
fout.write(data)
|
||||
cur_offset += len(data)
|
||||
print('%-12s% 8d' % (name, len(data)))
|
||||
print('%-12s% 8d' % ('total', cur_offset))
|
||||
Binary file not shown.
@@ -5,5 +5,5 @@
|
||||
# -------------------------------------------------------
|
||||
nvs, data, nvs, 0x9000, 24K,
|
||||
phy_init, data, phy, 0xf000, 4K,
|
||||
MicroPython, app, factory, 0x10000, 1472K,
|
||||
internalfs, data, spiffs, , 1024K,
|
||||
MicroPython, app, factory, 0x10000, 1728K,
|
||||
internalfs, data, spiffs, , 2304K,
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user