Skip to content

Commit 385eb60

Browse files
committed
feature: Add Fire board
Signed-off-by: lbuque <[email protected]>
1 parent 90920de commit 385eb60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1337
-39
lines changed

m5stack/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BOARD ?= M5STACK_8MB
1111

1212

1313
# Board type list
14-
BOARD_TYPE_DEF := none atoms3 stamps3 cores3 atoms3u core2 stickcplus2 stickcplus
14+
BOARD_TYPE_DEF := none atoms3 stamps3 cores3 atoms3u core2 stickcplus2 stickcplus fire
1515

1616
# Select the board type to build, default is None
1717
# This value affects which folder in the "./fs/system/" directory is pack into "fs-system.bin"
13.1 KB
3.74 KB
3.15 KB
3.17 KB
3.16 KB
3.58 KB
3.54 KB
3.59 KB
3.66 KB
3.53 KB
9.24 KB
3.45 KB
3.39 KB
3.36 KB
3.32 KB
5.61 KB
4.95 KB
5.3 KB
4.88 KB

m5stack/fs/system/fire/applist.png

9.48 KB
2.75 KB
2.76 KB

m5stack/fs/system/fire/bar1.png

7.01 KB

m5stack/fs/system/fire/bar2.png

6.05 KB

m5stack/fs/system/fire/bar3.png

5.94 KB

m5stack/fs/system/fire/bar4.png

6.32 KB

m5stack/fs/system/fire/bar5.png

6.37 KB

m5stack/fs/system/fire/boot_No.png

4.77 KB

m5stack/fs/system/fire/boot_Yes.png

4.85 KB
23.1 KB
22.9 KB
6.31 KB
5.52 KB
5.33 KB
4.9 KB

m5stack/fs/system/fire/logo.png

12.9 KB

m5stack/fs/system/fire/run.png

11.7 KB

m5stack/fs/system/fire/screen100.png

5.3 KB

m5stack/fs/system/fire/screen25.png

5.2 KB

m5stack/fs/system/fire/screen50.png

5.25 KB

m5stack/fs/system/fire/screen75.png

5.18 KB
2.81 KB
2.82 KB
5.73 KB
5.05 KB

m5stack/modules/startup/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def startup(boot_opt, timeout: int = 60) -> None:
6161

6262
pin4 = Pin(4, Pin.OUT)
6363
pin4.value(1)
64-
if board_id == M5.BOARD.M5AtomS3U:
64+
if board_id in (M5.BOARD.M5AtomS3U, M5.BOARD.M5AtomS3Lite, M5.BOARD.M5StampS3):
6565
# M5AtomS3U may fail to enter the AUTODETECT process, which will cause
6666
# m5things to fail to obtain the board id.
6767
nvs = esp32.NVS("M5GFX")
@@ -93,7 +93,7 @@ def startup(boot_opt, timeout: int = 60) -> None:
9393

9494
cores3 = CoreS3_Startup()
9595
cores3.startup(ssid, pswd, timeout)
96-
elif board_id in (M5.BOARD.M5StackCore2, M5.BOARD.M5Tough, M5.BOARD.M5Stack):
96+
elif board_id in (M5.BOARD.M5StackCore2, M5.BOARD.M5Tough):
9797
from .core2 import Core2_Startup
9898

9999
core2 = Core2_Startup()
@@ -113,6 +113,11 @@ def startup(boot_opt, timeout: int = 60) -> None:
113113

114114
stickcplus2 = StickCPlus_Startup()
115115
stickcplus2.startup(ssid, pswd, timeout)
116+
elif board_id == M5.BOARD.M5Stack:
117+
from .fire import Fire_Startup
118+
119+
fire = Fire_Startup()
120+
fire.startup(ssid, pswd, timeout)
116121

117122
# Only connect to network, not show any menu
118123
elif boot_opt is BOOT_OPT_NETWORK:

m5stack/modules/startup/core2.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def umount(self) -> None:
541541

542542
_boot_options = (
543543
(
544-
0,
544+
2,
545545
ImageDesc(
546546
src="/system/core2/Setting/bootNo.png",
547547
x=4 + 60 + 3,
@@ -937,10 +937,7 @@ def mount(self):
937937
self._mac_label.setText(data[0])
938938
self._account_label.setText(str(data[1]))
939939

940-
if self.avatar == "/system/common/img/avatar.jpg":
941-
M5.Lcd.drawJpg(self.avatar, 130, 180, 60, 60)
942-
else:
943-
M5.Lcd.drawJpg(self.avatar, 130, 180, 56, 56, 0, 0, 0.28, 0.28)
940+
M5.Lcd.drawJpg(self.avatar, 130, 180, 56, 56, 0, 0, 0.28, 0.28)
944941

945942
def load_data(self):
946943
mac = binascii.hexlify(machine.unique_id()).upper()
@@ -958,7 +955,6 @@ def load_data(self):
958955
if len(infos[4]) is 0:
959956
self.avatar = "/system/common/img/avatar.jpg"
960957
else:
961-
# FIXME: avatar.jpg path is not right
962958
self.avatar = "/system/common/" + str(infos[4]).split("/")[-1]
963959

964960
try:
@@ -1073,7 +1069,7 @@ def _handle_run_once(self):
10731069

10741070
def _handle_run_always(self):
10751071
nvs = esp32.NVS("uiflow")
1076-
nvs.set_u8("boot_option", 0)
1072+
nvs.set_u8("boot_option", 2)
10771073
nvs.commit()
10781074
machine.reset()
10791075

@@ -1383,7 +1379,7 @@ def _btn_once_event_handler(self, event):
13831379
def _btn_always_event_handler(self, event):
13841380
DEBUG and print("run always")
13851381
nvs = esp32.NVS("uiflow")
1386-
nvs.set_u8("boot_option", 0)
1382+
nvs.set_u8("boot_option", 2)
13871383
nvs.commit()
13881384
with open("apps/" + self._files[self._file_pos], "rb") as f_src, open(
13891385
"main.py", "wb"

m5stack/modules/startup/cores3.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,7 @@ def mount(self):
10311031
self._account_label.setText(str(data[1]))
10321032

10331033
try:
1034-
if self.avatar == "/system/common/img/avatar.jpg":
1035-
M5.Lcd.drawJpg(self.avatar, 130, 180, 60, 60)
1036-
else:
1037-
M5.Lcd.drawJpg(self.avatar, 130, 180, 56, 56, 0, 0, 0.28, 0.28)
1034+
M5.Lcd.drawJpg(self.avatar, 130, 180, 56, 56, 0, 0, 0.28, 0.28)
10381035
except OSError:
10391036
pass
10401037

@@ -1054,7 +1051,6 @@ def load_data(self):
10541051
if len(infos[4]) is 0:
10551052
self.avatar = "/system/common/img/avatar.jpg"
10561053
else:
1057-
# FIXME: avatar.jpg path is not right
10581054
self.avatar = "/system/common/" + str(infos[4]).split("/")[-1]
10591055

10601056
try:
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from startup import Startup
2+
import M5
3+
from .framework import Framework
4+
from .apps.settings import SettingsApp
5+
from .apps.dev import DevApp
6+
from .apps.app_run import RunApp
7+
from .apps.app_list import ListApp
8+
from .apps.ezdata import EzDataApp
9+
import time
10+
11+
BK_IMG = "/system/stack/logo.png"
12+
13+
14+
class Sprite:
15+
def __init__(self, x, y, w, h, bpp, psram, parent=M5.Lcd) -> None:
16+
self._sprite = parent.newCanvas(w, h, bpp, psram)
17+
self._x = x
18+
self._y = y
19+
20+
def refresh(self):
21+
self._sprite.push(self._x, self._y)
22+
23+
24+
class Fire_Startup:
25+
def __init__(self) -> None:
26+
self._wlan = Startup()
27+
28+
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
29+
self._wlan.connect_network(ssid, pswd)
30+
M5.Speaker.setVolume(80)
31+
M5.Speaker.tone(4000, 50)
32+
33+
M5.Lcd.drawImage(BK_IMG)
34+
time.sleep_ms(200)
35+
36+
sprite = M5.Lcd.newCanvas(320, 184, 16, True)
37+
38+
fw = Framework()
39+
settings_app = SettingsApp(sprite, data=self._wlan)
40+
dev_app = DevApp(sprite, data=self._wlan)
41+
run_app = RunApp(None)
42+
list_app = ListApp(sprite)
43+
fw.install_launcher(dev_app)
44+
fw.install(settings_app)
45+
fw.install(dev_app)
46+
fw.install(run_app)
47+
fw.install(list_app)
48+
fw.install(EzDataApp(sprite))
49+
fw.start()

m5stack/modules/startup/fire/app.py

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
try:
2+
import uasyncio as asyncio
3+
except ImportError:
4+
import asyncio
5+
6+
def generator(d):
7+
try:
8+
len(d)
9+
except TypeError:
10+
cache = []
11+
for i in d:
12+
yield i
13+
cache.append(i)
14+
d = cache
15+
while d:
16+
yield from d
17+
18+
class AppSelector():
19+
def __init__(self, apps) -> None:
20+
self._apps = apps
21+
self._id = 0
22+
23+
def next(self):
24+
self._id = (self._id + 1) % len(self._apps)
25+
return self._apps[self._id]
26+
27+
def current(self):
28+
return self._apps[self._id]
29+
30+
class AppBase:
31+
def __init__(self) -> None:
32+
self._task = None
33+
34+
def on_install(self):
35+
pass
36+
37+
def on_launch(self):
38+
pass
39+
40+
def on_view(self):
41+
pass
42+
43+
def on_ready(self):
44+
self._task = asyncio.create_task(self.on_run())
45+
46+
async def on_run(self):
47+
while True:
48+
await asyncio.sleep_ms(500)
49+
50+
def on_hide(self):
51+
self._task.cancel()
52+
53+
def on_exit(self):
54+
pass
55+
56+
def on_uninstall(self):
57+
pass
58+
59+
def install(self):
60+
self.on_install()
61+
62+
def start(self):
63+
self.on_launch()
64+
self.on_view()
65+
self.on_ready()
66+
67+
def pause(self):
68+
self.on_hide()
69+
70+
def resume(self):
71+
self.on_ready()
72+
73+
def stop(self):
74+
self.on_hide()
75+
self.on_exit()
76+
77+
def uninstall(self):
78+
self.on_uninstall()
79+

0 commit comments

Comments
 (0)