diff --git a/internal_filesystem/boot.py b/internal_filesystem/boot.py new file mode 100644 index 00000000..9778ac9e --- /dev/null +++ b/internal_filesystem/boot.py @@ -0,0 +1,10 @@ +# This file is the only one that can't be overridden (without rebuilding) for development, so keep it minimal. + +# Make sure the storage partition's /lib is first in the path, so whatever is placed there overrides frozen libraries +# This allows a "prod[uction]" build to be used for development as well, just by overriding the libraries in /lib +import sys +sys.path.insert(0, '/lib') + +print("Passing execution over to MicroPythonOS's main.py") +import mpos.main + diff --git a/internal_filesystem/lib/mpos/board/boot_fri3d-2024.py b/internal_filesystem/lib/mpos/board/fri3d-2024.py similarity index 99% rename from internal_filesystem/lib/mpos/board/boot_fri3d-2024.py rename to internal_filesystem/lib/mpos/board/fri3d-2024.py index 0aabb62c..243c75c7 100644 --- a/internal_filesystem/lib/mpos/board/boot_fri3d-2024.py +++ b/internal_filesystem/lib/mpos/board/fri3d-2024.py @@ -13,11 +13,9 @@ import gc import lvgl as lv import task_handler -import mpos.info import mpos.ui import mpos.ui.focus_direction -mpos.info.set_hardware_id("fri3d-2024") # Pin configuration SPI_BUS = 2 diff --git a/internal_filesystem/lib/mpos/board/linux.py b/internal_filesystem/lib/mpos/board/linux.py index 92b581bb..3256f53b 100644 --- a/internal_filesystem/lib/mpos/board/linux.py +++ b/internal_filesystem/lib/mpos/board/linux.py @@ -3,18 +3,11 @@ import lcd_bus import lvgl as lv import sdl_display -# Add lib/ to the path for modules, otherwise it will only search in ~/.micropython/lib and /usr/lib/micropython -import sys -sys.path.append('lib/') - import mpos.clipboard import mpos.indev.mpos_sdl_keyboard -import mpos.info import mpos.ui import mpos.ui.focus_direction -mpos.info.set_hardware_id("linux-desktop") - # Same as Waveshare ESP32-S3-Touch-LCD-2 and Fri3d Camp 2026 Badge TFT_HOR_RES=320 TFT_VER_RES=240 diff --git a/internal_filesystem/lib/mpos/board/boot.py b/internal_filesystem/lib/mpos/board/waveshare-esp32-s3-touch-lcd-2.py similarity index 93% rename from internal_filesystem/lib/mpos/board/boot.py rename to internal_filesystem/lib/mpos/board/waveshare-esp32-s3-touch-lcd-2.py index e594c80e..5a5b7eac 100644 --- a/internal_filesystem/lib/mpos/board/boot.py +++ b/internal_filesystem/lib/mpos/board/waveshare-esp32-s3-touch-lcd-2.py @@ -11,9 +11,6 @@ import lvgl as lv import task_handler import mpos.ui -import mpos.info - -mpos.info.set_hardware_id("waveshare-esp32-s3-touch-lcd-2") # Pin configuration SPI_BUS = 2 @@ -92,9 +89,7 @@ mpos.battery_voltage.init_adc(5, 262 / 100000) try: from machine import Pin, I2C i2c = I2C(1, scl=Pin(16), sda=Pin(21)) # Adjust pins and frequency - devices = i2c.scan() - print("Scan of I2C bus on scl=16, sda=21:") - print([hex(addr) for addr in devices]) # finds it on 60 = 0x3C after init + # Warning: don't do an i2c scan because it confuses the camera! camera_addr = 0x3C # for OV5640 reg_addr = 0x3008 reg_high = (reg_addr >> 8) & 0xFF # 0x30 diff --git a/internal_filesystem/lib/mpos/main.py b/internal_filesystem/lib/mpos/main.py index 6ddc3611..a2222e79 100644 --- a/internal_filesystem/lib/mpos/main.py +++ b/internal_filesystem/lib/mpos/main.py @@ -11,9 +11,19 @@ from mpos.content.package_manager import PackageManager # Auto-detect and initialize hardware import sys if sys.platform == "linux" or sys.platform == "darwin": # linux and macOS - import mpos.board.linux + board = "linux" elif sys.platform == "esp32": - print("TODO: detect which esp32 this is and then load the appropriate board") + board = "fri3d-2024" # default fallback + import machine + from machine import Pin, I2C + i2c0 = I2C(0, sda=machine.Pin(48), scl=machine.Pin(47)) + if i2c0.scan() == [21, 107]: # touch screen and IMU + board = "waveshare-esp32-s3-touch-lcd-2" + +print(f"Detected hardware {board}, initializing...") +import mpos.info +mpos.info.set_hardware_id(board) +__import__(f"mpos.board.{board}") # Allow LVGL M:/path/to/file or M:relative/path/to/file to work for image set_src etc import mpos.fs_driver