首页 > 编程知识 正文

M5Stack学习笔记4 StickC上手

时间:2023-05-03 14:25:11 阅读:276395 作者:4159

虽然简单,但是69的价格(如果同时购买表带和支架等,是79),还是有些性价比的。

本节我们来看看StickC有些啥不一样。

基本上,屏幕小了,按键少了,电池更迷你了。只有一个红色LED,没有了speaker,但是多了红外发射。如果你同时购买了表带,你可以把StickC佩戴在手腕上。

机身上有3个按键,上图中的Power Switch,在机身的正面右侧靠下,开机时,短按是Reset,长按6s是关机,关机时,长按2s 貌似短按是开机。 机身正面刻有M5字样的是Button A,右侧靠上是Button B。

我刚拿到的StickC,开机后好像是个测试程序,可以检测Mic,LED,按键,以及6轴传感器。估计是Arduino写的程序,没有UIFlow相关功能。 

用M5Burner擦除并重新烧写UIFlow-v1.2.3后重启。

启动后会显示WI-FI SSID M5-……,以及192.168.4.1,需要用其他设备连接SSID为M5-开头的热点,并访问http://192.168.4.1 并设置StickC访问其他wifi的密码,设置完毕后,重启即可自动连接wif并进入cloud编程模式,显示APIKEY和一个地球符号。

参考:

https://docs.m5stack.com/#/en/quick_start/m5stickc/m5stickc_quick_start_with_uiflow

上面的链接说明了如何烧写UIFlow和用UIFlow的Web-IDE编程,下面我来说说怎么用UIFlow的桌面IDE,和连接REPL。

首先说明Button A和Button B的作用。

重启后,出现UIFlow Cloud信息时迅速按下Button A,就可以进入菜单,Button B可以切换菜单选择,主菜单选择有3个,Program(编程模式),APP.List(程序列表,但是貌似不会有什么列表,它只会运行系统内唯一一个程序,即main.py),Setup(设定,里面可以切换Cloud模式或者USB模式,也可以设定Wi-Fi)。Button A为确定按键。

如果需要使用桌面版的UIFlow IDE,需要先切换到USB Mode。

然后启动UIFlow-Desktop-IDE,并选择类似/dev/tty.usbserial-A15AE98545的串口,或者你确定的连接StickC的串口。即可开始UIFlow编程。

需要注意的是,同M5Stack Fire不同的是,StickC并不支持多APP,而是只保留最后下载的APP。 在flash中的文件名为main.py。

而如果要连接REPL,是同M5Stack Fire类似的。

$ screen /dev/tty.usbserial-A15AE98545 115200……(没有显示,按几次 Ctrl-C)……Traceback (most recent call last): File "flow_usb.py", line 34, in <module> File "m5flow/m5ucloud.py", line 53, in run File "m5flow/m5stack.py", line 105, in waitKeyboardInterrupt:FreeRTOS running on BOTH CORES, MicroPython task started on App Core (1). Reset reason: Power on reset uPY stack: 14336 bytes uPY heap: 86016/26672/59344 bytesMicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32Type "help()" for more information.>>> help()Welcome to LoBo MicroPython for the ESP32For online documentation please visit the Wiki pages:https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wikiBased on official MicroPython, this port brings many new features: - support for two cores and 4MB SPIRAM (psRAM) - improved 'network' module - greatly improved thread support - support for 3 different internal file systems on top of ESP32 VFS - ESP32 native support for SD Card - built-in FTP & Telnet servers - support for OTA updates - many new and improved hardware access modules implemented in C and many more...Control commands: CTRL-A -- on a blank line, enter raw REPL mode CTRL-B -- on a blank line, enter normal REPL mode CTRL-C -- interrupt a running program CTRL-D -- on a blank line, do a soft reset of the board CTRL-E -- on a blank line, enter paste modeFor further help on a specific object, type help(obj)For a list of available modules, type help('modules')>>>

连接上串口后即可进入REPL,如果看不到MicroPython命令行提示符,可以尝试按下Ctrl-C。

使用mpfshell也是类似。

$ mpfshell -o tty.usbserial-A15AE98545Connected to esp32_LoBo** Micropython File Shell v0.9.1, sw@kaltpost.de **-- Running on Python 3.6 using PySerial 3.4 --mpfs [/flash]> lsRemote files in '/flash': <dir> .. <dir> .vscode <dir> blocks <dir> image_app <dir> img <dir> lib <dir> res <dir> sys_lib boot.py config.py debug.py flow.py flow_usb.py main.py modeconfig.jsonmpfs [/flash]> cat main.pyfrom m5stack import *from m5ui import *clear_bg(0x111111)M5LED.on()mpfs [/flash]>

可以看到,main.py就是我写的一个测试StickC上LED灯的程序,而/flash文件夹中,也没有了apps文件夹。

极速赛车稳赚4码proved hardware access modules implemented in C and many more...Control commands: CTRL-A -- on a blank line, enter raw REPL mode CTRL-B -- on a blank line, enter normal REPL mode CTRL-C -- interrupt a running program CTRL-D -- on a blank line, do a soft reset of the board CTRL-E -- on a blank line, enter paste modeFor further help on a specific object, type help(obj)For a list of available modules, type help('modules')>>>

连接上串口后即可进入REPL,如果看不到MicroPython命令行提示符,可以尝试按下Ctrl-C。

使用mpfshell也是类似。

$ mpfshell -o tty.usbserial-A15AE98545Connected to esp32_LoBo** Micropython File Shell v0.9.1, sw@kaltpost.de **-- Running on Python 3.6 using PySerial 3.4 --mpfs [/flash]> lsRemote files in '/flash': <dir> .. <dir> .vscode <dir> blocks <dir> image_app <dir> img <dir> lib <dir> res <dir> sys_lib boot.py config.py debug.py flow.py flow_usb.py main.py modeconfig.jsonmpfs [/flash]> cat main.pyfrom m5stack import *from m5ui import *clear_bg(0x111111)M5LED.on()mpfs [/flash]>

可以看到,main.py就是我写的一个测试StickC上LED灯的程序,而/flash文件夹中,也没有了apps文件夹。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。