M5StackでmicroPython
UiFlowのファームウエアをM5Burnerで書き込む
UiFlowはUSBモードにする
microPythonのバージョン確認
code:console
>> import os
>> os.uname().release
'1.12.0'
>>
シリアルコンソールで使う場合はAPPモード
code:console
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:5280
ho 0 tail 12 room 4
load:0x40078000,len:12908
load:0x40080400,len:3512
entry 0x4008063c
_ __ _
_ _(_)/ _| | _____ __
| | | | | |_| |/ _ \ \ /\ / /
| |_| | | _| | (_) \ V V /
\__,_|_|_| |_|\___/ \_/\_/
APIKEY: 7F7D5B01
MicroPython 29fcb53ce-dirty on 2021-08-13; M5Stack with ESP32
Type "help()" for more information.
>>
モジュール
UiFlow v1.8.2のMicroPython 29fcb53ce-dirty on 2021-08-13で確認
code:console
>> help('modules')
IoTcloud/AWS libs/ethernet/wiznet5k_dns smartconfig units/_fan
IoTcloud/Ali libs/ethernet/wiznet5k_mqtt sys units/_finger
IoTcloud/Azure libs/ethernet/wiznet5k_ntp uarray units/_flash_light
IoTcloud/Tencent libs/ethernet/wiznet5k_socket ubinascii units/_gesture
IoTcloud/__init__ libs/ethernet/wiznet5k_wsgiserver ubluetooth units/_gps
IoTcloud/blynk libs/imu ucollections units/_grove2grove
MediaTrans/Mqtt_Printer libs/ir/ir_rx/__init__ ucryptolib units/_hall
MediaTrans/TimerCam libs/ir/ir_rx/nec uctypes units/_heart
MediaTrans/__init__ libs/ir/ir_rx/print_error uerrno units/_imu6886
MicroWebSrv/__init__ libs/ir/ir_tx/__init__ uhashlib units/_ir
MicroWebSrv/microWebSocket libs/ir/ir_tx/nec uhashlib units/_joystick
MicroWebSrv/microWebSrv libs/lorabus uheapq units/_joystick_led
MicroWebSrv/microWebTemplate libs/m5_espnow uiflow units/_key
ThirdParty/toio/__init__ libs/m5mqtt uio units/_kmeter
ThirdParty/toio/ble_const libs/mcp2515/__init__ ujson units/_laserrx
ThirdParty/toio/toio_message libs/mcp2515/can_frame umqtt/__init__ units/_lasertx
__main__ libs/mcp2515/mcp2515_param umqtt/robust units/_lcd
_boot libs/mcp2515/mcp2515_spi umqtt/simple units/_light
_flow libs/microcoapy/__init__ unit units/_limit
_onewire libs/microcoapy/coap_macros unitcam units/_makey
_thread libs/microcoapy/coap_option units/VFunction/__init__ units/_microphone_AD
_uasyncio libs/microcoapy/coap_packet units/VFunction/_apriltag_code units/_microphone_I2S
_webrepl libs/microcoapy/coap_reader units/VFunction/_bar_code units/_mqtt_eth
apa106 libs/microcoapy/coap_writer units/VFunction/_color_track units/_ncir
base/DTU_CAT1 libs/microcoapy/microcoapy units/VFunction/_dm_code units/_ncir2
base/DTU_LoRaWAN libs/micropyGPS units/VFunction/_face_detect units/_oled
base/DTU_NB libs/mlx90640 units/VFunction/_jpeg_transfer units/_op
base/GPS libs/modbus/__init__ units/VFunction/_line_tracker units/_pahub
base/HDriver libs/modbus/master/__init__ units/VFunction/_motion units/_pbhub
base/Motion libs/modbus/master/uModBusConst units/VFunction/_qr_code units/_pir
base/PoE libs/modbus/master/uModBusFunctions units/VFunction/_tag_reader units/_relay
base/QRCode libs/modbus/master/uModBusSerial units/VFunction/_target_track units/_relay2
base/Speaker libs/modbus/master/uModBusTCP units/VFunction/_v2_code_detector units/_relay4
base/Stepmotor libs/modbus/slave/__init__ units/VFunction/_v2_color_tracker units/_rfid
base/TF_Card libs/modbus/slave/exceptions units/VFunction/_v2_face_detector units/_rgb
base/__init__ libs/modbus/slave/functions units/VFunction/_v2_face_recognition units/_rgb_multi
base64 libs/modbus/slave/redundancy_check units/VFunction/_v2_lane_line_tracker units/_rotary_encoder
ble/ble_advertising libs/modbus/slave/route units/VFunction/_v2_motion_tracker units/_scales
btree libs/modbus/slave/rtu units/VFunction/_v2_object_recognition units/_servo
builtins libs/modbus/slave/utils units/VFunction/_v2_online_classifier units/_sonic_io
cmath libs/mpu6050 units/VFunction/_v2_shape_detector units/_ssr
collections/__init__ libs/mstate units/VFunction/_v2_target_tracker units/_tcp_eth
collections/defaultdict libs/numbers units/_ID units/_thermal
collections/deque libs/nvs units/_IR_NEC units/_thermal_cam2
comx/LoRaWAN libs/paj7620u2 units/_ISORS485 units/_tof
comx/__init__ libs/pca9685 units/_LoRaWAN units/_tracker
comx/cat1 libs/pid units/_NBIoT units/_tube_pressure
deviceCfg libs/qmp6988 units/_RS485 units/_tvoc
display libs/servo units/_RTC8563 units/_uhf_rfid
esp libs/sh1107 units/_accel units/_ultrasonic
esp32 libs/sh200q units/_acsocket units/_unitcam
espnow libs/sht30 units/_adc units/_uwb
flashbdev libs/simcom/__init__ units/_ameter units/_v_function
flow/__init__ libs/simcom/common units/_angle units/_vibrator
flow/adaptation libs/simcom/gps units/_angle8 units/_vmeter
flow/ezdata libs/simcom/gsm units/_atom_motion units/_watering
flow/ezdata_queue libs/simcom/lte units/_bps units/_weight
flow/flowDeinit libs/simcom/nb units/_bps_qmp units/_zigbee
flow/m5cloud libs/speak units/_button uos
flow/m5ucloud libs/timeSchedule units/_buzzer urandom
flow/protocol libs/time_ex units/_cardKB ure
framebuf libs/urequests units/_catm urllib/parse
gc libs/vl53l0x units/_catm_gnss urllib/urequest
hardware/__init__ m5stack units/_co2_scd40 uselect
hardware/button m5uart units/_color usocket
hardware/microphone m5ui units/_dac ussl
hmac machine units/_dds ustruct
i2c_bus math units/_digi_clock utils
inisetup max30100 units/_dlight utime
libs/__init__ menu/__init__ units/_dual_button utimeq
libs/bmm150 menu/cloud units/_earth uwebsocket
libs/bmp280 menu/wifi units/_encoder8 uzlib
libs/config micropython units/_encoder_led warnings
libs/dht12 modules/_catm_iot units/_env wav/chunk
libs/easyIO modules/_nb_iot units/_env2 wav/wav_player
libs/echo neopixel units/_env3 wav/wave
libs/emoji network units/_ext_io wifiCfg
libs/ethernet/__init__ ntptime units/_ext_io2 wifiWebCfg
libs/ethernet/wiznet5k ntptime units/_fader
libs/ethernet/wiznet5k_dhcp simpleOTA units/_fader8
Plus any modules on the filesystem
>>
m5stackモジュール(BASIC)
code:console
>> import m5stack
>> dir(m5stack)
'__class__', '__name__', 'const', '__file__', 'display', 'machine', 'node_id', 'btnA', 'btnB', 'btnC', 'lcd', 'binascii', 'button', 'rgb', 'btn', 'time_ex', 'timEx', 'timeSchedule', 'timerSch', 'Rgb_multi', 'Speaker', 'speaker', 'IP5306', 'power', '_remote_init', 'remoteInit' ボタン
code:console
>> from m5stack import btnA, btnB, btnC
スレットを止めずに中の処理を止めたい
code:thread
from m5stack import *
import _thread as t
import time
thread_running = True
task_running = True
def task():
while thread_running:
if task_running:
print("Hello from Task")
time.sleep_ms(1000)
else:
time.sleep_ms(100)
def buttonA_wasPressed():
task_running = not task_running
btnA.wasPressed(buttonA_wasPressed)
t.start_new_thread(task, ())
BLE