Skip to content

Commit 86d167c

Browse files
committed
feature: Support Basic(4MB flash) board
Signed-off-by: lbuque <[email protected]>
1 parent ea6d1a3 commit 86d167c

File tree

16 files changed

+412
-90
lines changed

16 files changed

+412
-90
lines changed

m5stack/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ boards := \
1919
M5STACK_StickC_PLUS2:stickcplus2 \
2020
M5STACK_StickC_PLUS:stickcplus \
2121
M5STACK_Fire:fire \
22-
M5STACK_Basic:basic
22+
M5STACK_Basic:basic \
23+
M5STACK_Basic_4MB:basic
2324

2425
define find_board
2526
$(if $(filter $(1):%,$(boards)),$(word 2,$(subst :, ,$(filter $(1):%,$(boards)))),none)
@@ -49,6 +50,13 @@ else
4950
$(error Board type $(BOARD_TYPE) does not exist in list [$(BOARD_TYPE_DEF)])
5051
endif
5152

53+
TINY_BOARD_TYPE_DEF = M5STACK_StickC_PLUS M5STACK_Basic_4MB
54+
ifneq ($(filter $(BOARD),$(TINY_BOARD_TYPE_DEF)),)
55+
TINY_FLAG ?= 1
56+
else
57+
TINY_FLAG ?= 0
58+
endif
59+
5260
# esp32c3's bootloader is different with esp32
5361
ifeq (C3, $(findstring C3,${BOARD}))
5462
CHIP ?= esp32c3
@@ -157,7 +165,7 @@ nvs:
157165
@$(PYTHON) ./../tools/nvs_partition_gen.py generate partition_nvs.csv $(BUILD)/nvs.bin 0x6000
158166

159167
# Build the system and user filesystem firmware.
160-
ifeq ($(BOARD_TYPE),stickcplus)
168+
ifeq ($(TINY_FLAG),1)
161169
fs: build
162170
@if [ ! -d $(BUILD)/base-files ]; then \
163171
mkdir -p $(BUILD)/base-files; \
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_basic.py")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(SDKCONFIG_DEFAULTS
2+
./boards/sdkconfig.base
3+
./boards/sdkconfig.flash_4mb
4+
./boards/sdkconfig.ble
5+
./boards/sdkconfig.240mhz
6+
./boards/sdkconfig.disable_iram
7+
./boards/M5STACK_Basic/sdkconfig.board
8+
)
9+
10+
# If not enable LVGL, ignore this...
11+
set(LV_CFLAGS -DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=0)
12+
13+
if(NOT MICROPY_FROZEN_MANIFEST)
14+
set(MICROPY_FROZEN_MANIFEST ${CMAKE_SOURCE_DIR}/boards/manifest.py)
15+
endif()
16+
17+
set(TINY_FLAG 1)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#define MICROPY_HW_BOARD_NAME "M5STACK"
2+
#define MICROPY_HW_MCU_NAME "ESP32"
3+
4+
// If not enable LVGL, ignore this...
5+
#include "./../mpconfiglvgl.h"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SSL
2+
CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=n
3+
CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC=y
4+
5+
# Flash
6+
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
7+
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
8+
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y

m5stack/boards/M5STACK_StickC_PLUS/mpconfigboard.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ set(LV_CFLAGS -DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=0)
1313
if(NOT MICROPY_FROZEN_MANIFEST)
1414
set(MICROPY_FROZEN_MANIFEST ${CMAKE_SOURCE_DIR}/boards/manifest.py)
1515
endif()
16+
17+
set(TINY_FLAG 1)

m5stack/cmodules/m5unified/m5unified.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ target_include_directories(usermod_M5UNIFIED INTERFACE
2020
${CMAKE_CURRENT_LIST_DIR}
2121
)
2222

23-
if (BOARD_TYPE STREQUAL "stickcplus")
23+
if (TINY_FLAG)
2424
target_compile_definitions(usermod_M5UNIFIED INTERFACE TINY_FONT=1)
2525
endif()
2626

m5stack/modules/startup/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self) -> None:
1818
self.wlan.active(True)
1919

2020
def connect_network(self, ssid: str, pswd: str) -> bool:
21-
if (len(ssid) > 0) or (len(pswd) > 0):
21+
if len(ssid) > 0:
2222
self.wlan.connect(ssid, pswd)
2323
return True
2424
else:
@@ -132,6 +132,11 @@ 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:
136+
from .capsule import Capsule_Startup
137+
138+
capsule = Capsule_Startup()
139+
capsule.startup(ssid, pswd, timeout)
135140

136141
# Only connect to network, not show any menu
137142
elif boot_opt is BOOT_OPT_NETWORK:

m5stack/modules/startup/basic/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def next(self):
2929
def current(self):
3030
return self._apps[self._id]
3131

32+
def prev(self):
33+
self._id = (self._id - 1) % len(self._apps)
34+
return self._apps[self._id]
35+
3236

3337
class AppBase:
3438
def __init__(self) -> None:

m5stack/modules/startup/basic/apps/app_list.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,31 @@ def __init__(self, x, y, w, h, color, fill_c, parent=M5.Lcd) -> None:
2626
self._parent = parent
2727
self.set_pos(self._x, self._y)
2828

29+
def set_x(self, x):
30+
self._x = x
31+
self._parent.fillRect(self._x, self._y, self._w, self._h, self._fill_c)
32+
self._parent.drawRect(self._x, self._y, self._w, self._h, self._color)
33+
34+
def get_y(self):
35+
return self._y
36+
37+
def set_y(self, y):
38+
self._y = y
39+
self._parent.fillRect(self._x, self._y, self._w, self._h, self._fill_c)
40+
self._parent.drawRect(self._x, self._y, self._w, self._h, self._color)
41+
2942
def set_pos(self, x, y):
3043
self._x = x
3144
self._y = y
3245
self._parent.fillRect(self._x, self._y, self._w, self._h, self._fill_c)
3346
self._parent.drawRect(self._x, self._y, self._w, self._h, self._color)
3447

48+
def set_color(self, color, fill_c):
49+
self._color = color
50+
self._fill_c = fill_c
51+
self._parent.fillRect(self._x, self._y, self._w, self._h, self._fill_c)
52+
self._parent.drawRect(self._x, self._y, self._w, self._h, self._color)
53+
3554

3655
class FileList:
3756
def __init__(self, dir, suffix=".py") -> None:
@@ -170,7 +189,8 @@ def on_exit(self):
170189
M5.Lcd.drawImage(APPLIST_UNSELECTED_IMG, 5 + 62 * 3, 0)
171190
del self._bg_img, self._left_img, self._right_img
172191
del self._label0, self._label1, self._label2, self._label3, self._labels
173-
del self._files
192+
del self._rect0
193+
del self._files, self._max_file_num, self._cursor_pos, self._file_pos
174194

175195
async def _btna_event_handler(self, fw):
176196
pass

0 commit comments

Comments
 (0)