Skip to content

Commit 315f411

Browse files
committed
feature: Support M5Capsule board
Signed-off-by: lbuque <[email protected]>
1 parent 3b9913a commit 315f411

File tree

11 files changed

+137
-6
lines changed

11 files changed

+137
-6
lines changed

m5stack/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ boards := \
2020
M5STACK_StickC_PLUS:stickcplus \
2121
M5STACK_Fire:fire \
2222
M5STACK_Basic:basic \
23-
M5STACK_Basic_4MB:basic
23+
M5STACK_Basic_4MB:basic \
24+
M5STACK_Capsule:capsule
2425

2526
define find_board
2627
$(if $(filter $(1):%,$(boards)),$(word 2,$(subst :, ,$(filter $(1):%,$(boards)))),none)
@@ -38,7 +39,8 @@ BOARD_TYPE_DEF := \
3839
stickcplus2 \
3940
stickcplus \
4041
fire \
41-
basic
42+
basic \
43+
capsule
4244

4345
# Select the board type to build, default is None
4446
# This value affects which folder in the "./fs/system/" directory is pack into "fs-system.bin"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"deploy": [
3+
"../deploy_s3.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"BLE",
8+
"WiFi"
9+
],
10+
"images": [
11+
"generic_s3.jpg"
12+
],
13+
"mcu": "esp32s3",
14+
"product": "M5Stack S3 Serials",
15+
"thumbnail": "",
16+
"url": "https://www.espressif.com/en/products/modules",
17+
"vendor": "M5Stack"
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include("$(MPY_DIR)/../m5stack/modules/startup/manifest_capsule.py")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set(IDF_TARGET esp32s3)
2+
3+
set(SDKCONFIG_DEFAULTS
4+
./boards/M5STACK_S3_8MB/sdkconfig.board
5+
./boards/sdkconfig.base
6+
./boards/sdkconfig.240mhz
7+
./boards/sdkconfig.disable_iram
8+
./boards/sdkconfig.ble
9+
./boards/sdkconfig.usb
10+
./boards/sdkconfig.flash_8mb
11+
)
12+
13+
# If not enable LVGL, ignore this...
14+
set(LV_CFLAGS -DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=0)
15+
16+
if(NOT MICROPY_FROZEN_MANIFEST)
17+
set(MICROPY_FROZEN_MANIFEST ${CMAKE_SOURCE_DIR}/boards/manifest.py)
18+
endif()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#define MICROPY_HW_BOARD_NAME "M5STACK"
2+
#define MICROPY_HW_MCU_NAME "ESP32S3"
3+
4+
#define MICROPY_PY_MACHINE_DAC (0)
5+
6+
// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
7+
#define MICROPY_HW_ENABLE_UART_REPL (1)
8+
9+
#define MICROPY_HW_I2C0_SCL (9)
10+
#define MICROPY_HW_I2C0_SDA (8)
11+
12+
// If not enable LVGL, ignore this...
13+
#include "./../mpconfiglvgl.h"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_FLASHMODE_DIO=y # QIO mode has some problem when mount fs
2+
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
3+
CONFIG_ESPTOOLPY_FLASHMODE="dio"
4+
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
5+
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
6+
CONFIG_ESPTOOLPY_AFTER_NORESET=y
7+
8+
CONFIG_SPIRAM_MEMTEST=
9+
CONFIG_FREERTOS_UNICORE=y
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include("$(MPY_DIR)/../m5stack/modules/startup/manifest_stamps3.py")

m5stack/libs/hardware/rgb.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ def __new__(cls, **kwargs) -> NeoPixel:
2828
return WS2812(io=cls._io, n=cls._n) # default
2929

3030
# If not provided any io, according to board type, initialize the built-in rgb
31+
board_id = M5.getBoard()
3132
if cls._instance == None:
32-
if M5.BOARD.M5AtomS3 == M5.getBoard():
33+
if M5.BOARD.M5AtomS3 == board_id:
3334
pass
34-
elif M5.getBoard() in (M5.BOARD.M5AtomS3Lite, M5.BOARD.M5AtomS3U):
35+
elif board_id in (M5.BOARD.M5AtomS3Lite, M5.BOARD.M5AtomS3U):
3536
cls._instance = WS2812(io=35, n=1)
3637
return cls._instance
37-
elif M5.BOARD.M5StampS3 == M5.getBoard():
38+
elif board_id in (M5.BOARD.M5StampS3, M5.BOARD.M5Capsule):
3839
cls._instance = WS2812(io=21, n=1)
3940
return cls._instance
4041
else:

m5stack/modules/startup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def startup(boot_opt, timeout: int = 60) -> None:
132132

133133
basic = Basic_Startup()
134134
basic.startup(ssid, pswd, timeout)
135-
elif board_id == M5.BOARD.M5Stack:
135+
elif board_id == M5.BOARD.M5Capsule:
136136
from .capsule import Capsule_Startup
137137

138138
capsule = Capsule_Startup()

m5stack/modules/startup/capsule.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from .stamps3 import StampS3_Startup
2+
import network
3+
import time
4+
import M5
5+
6+
7+
class Capsule_Startup(StampS3_Startup):
8+
"""AtomS3U startup menu"""
9+
10+
def __init__(self) -> None:
11+
super().__init__()
12+
13+
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
14+
self.show_mac()
15+
M5.Speaker.setVolumePercentage(1.0)
16+
17+
if super().connect_network(ssid=ssid, pswd=pswd):
18+
print("Connecting to " + ssid + " ", end="")
19+
status = super().connect_status()
20+
self.rgb.set_brightness(60)
21+
start = time.time()
22+
while True:
23+
t = super().connect_status()
24+
if t != network.STAT_GOT_IP:
25+
status = t
26+
M5.Speaker.tone(5000, 50)
27+
if t is network.STAT_NO_AP_FOUND:
28+
self.show_error(ssid, "NO AP FOUND")
29+
break
30+
elif t is network.STAT_WRONG_PASSWORD:
31+
self.show_error(ssid, "WRONG PASSWORD")
32+
break
33+
elif t is network.STAT_HANDSHAKE_TIMEOUT:
34+
self.show_error(ssid, "HANDSHAKE ERR")
35+
break
36+
elif t is network.STAT_CONNECTING:
37+
print(".", end="")
38+
if t != status and t == network.STAT_GOT_IP:
39+
status = t
40+
print(" ")
41+
print("Local IP: " + super().local_ip())
42+
self.rgb.set_color(0, self.COLOR_GREEN)
43+
self.rgb.set_brightness(100)
44+
break
45+
# connect to network timeout
46+
if (time.time() - start) > timeout:
47+
self.show_error(ssid, "TIMEOUT")
48+
break
49+
time.sleep_ms(300)
50+
if status == network.STAT_GOT_IP:
51+
M5.Speaker.tone(4500, 50)
52+
time.sleep(0.1)
53+
M5.Speaker.tone(4500, 50)
54+
else:
55+
self.rgb.set_color(0, self.COLOR_RED)
56+
self.rgb.set_brightness(100)
57+
self.show_error("Not Found", "Please use M5Burner setup :)")
58+

0 commit comments

Comments
 (0)