Skip to content

Commit 4aebc7b

Browse files
Works on waveshare-esp32-s3-touch-lcd-2
1 parent be5de1d commit 4aebc7b

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

internal_filesystem/boot.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file is the only one that can't be overridden (without rebuilding) for development, so keep it minimal.
2+
3+
# Make sure the storage partition's /lib is first in the path, so whatever is placed there overrides frozen libraries
4+
# This allows a "prod[uction]" build to be used for development as well, just by overriding the libraries in /lib
5+
import sys
6+
sys.path.insert(0, '/lib')
7+
8+
print("Passing execution over to MicroPythonOS's main.py")
9+
import mpos.main
10+

internal_filesystem/lib/mpos/board/boot_fri3d-2024.py renamed to internal_filesystem/lib/mpos/board/fri3d-2024.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
import lvgl as lv
1414
import task_handler
1515

16-
import mpos.info
1716
import mpos.ui
1817
import mpos.ui.focus_direction
1918

20-
mpos.info.set_hardware_id("fri3d-2024")
2119

2220
# Pin configuration
2321
SPI_BUS = 2

internal_filesystem/lib/mpos/board/linux.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
import lvgl as lv
44
import sdl_display
55

6-
# Add lib/ to the path for modules, otherwise it will only search in ~/.micropython/lib and /usr/lib/micropython
7-
import sys
8-
sys.path.append('lib/')
9-
106
import mpos.clipboard
117
import mpos.indev.mpos_sdl_keyboard
12-
import mpos.info
138
import mpos.ui
149
import mpos.ui.focus_direction
1510

16-
mpos.info.set_hardware_id("linux-desktop")
17-
1811
# Same as Waveshare ESP32-S3-Touch-LCD-2 and Fri3d Camp 2026 Badge
1912
TFT_HOR_RES=320
2013
TFT_VER_RES=240

internal_filesystem/lib/mpos/board/boot.py renamed to internal_filesystem/lib/mpos/board/waveshare-esp32-s3-touch-lcd-2.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
import task_handler
1212

1313
import mpos.ui
14-
import mpos.info
15-
16-
mpos.info.set_hardware_id("waveshare-esp32-s3-touch-lcd-2")
1714

1815
# Pin configuration
1916
SPI_BUS = 2
@@ -92,9 +89,7 @@
9289
try:
9390
from machine import Pin, I2C
9491
i2c = I2C(1, scl=Pin(16), sda=Pin(21)) # Adjust pins and frequency
95-
devices = i2c.scan()
96-
print("Scan of I2C bus on scl=16, sda=21:")
97-
print([hex(addr) for addr in devices]) # finds it on 60 = 0x3C after init
92+
# Warning: don't do an i2c scan because it confuses the camera!
9893
camera_addr = 0x3C # for OV5640
9994
reg_addr = 0x3008
10095
reg_high = (reg_addr >> 8) & 0xFF # 0x30

internal_filesystem/lib/mpos/main.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@
1111
# Auto-detect and initialize hardware
1212
import sys
1313
if sys.platform == "linux" or sys.platform == "darwin": # linux and macOS
14-
import mpos.board.linux
14+
board = "linux"
1515
elif sys.platform == "esp32":
16-
print("TODO: detect which esp32 this is and then load the appropriate board")
16+
board = "fri3d-2024" # default fallback
17+
import machine
18+
from machine import Pin, I2C
19+
i2c0 = I2C(0, sda=machine.Pin(48), scl=machine.Pin(47))
20+
if i2c0.scan() == [21, 107]: # touch screen and IMU
21+
board = "waveshare-esp32-s3-touch-lcd-2"
22+
23+
print(f"Detected hardware {board}, initializing...")
24+
import mpos.info
25+
mpos.info.set_hardware_id(board)
26+
__import__(f"mpos.board.{board}")
1727

1828
# Allow LVGL M:/path/to/file or M:relative/path/to/file to work for image set_src etc
1929
import mpos.fs_driver

0 commit comments

Comments
 (0)