Add initial support for M5Stack-Fire board#32
Add initial support for M5Stack-Fire board#32ThomasFarstrike merged 5 commits intoMicroPythonOS:mainfrom
Conversation
M5Stack-Fire board detection should be:
i2c0 = I2C(0, sda=Pin(21), scl=Pin(22))
if {0x68} <= set(i2c0.scan()): # IMU (MPU6886)
return "m5stack-fire"
But there are some pin incompatibilities between ESP32 and ESP32-S3 boards that don't allow I2C scan.
M5Stack-Fire uses an ILI9342 instead of an ILI9341. Therefore, lvgl_micropython should include "_ili9341_init_type3.py".
Avoid new "_ili9341_init_type3.py" file dependency in lvgl_micropython by following suggestion: lvgl-micropython/lvgl_micropython#527
|
Very cool!
Why not? :-D I think we can merge this fairly soon, I mean, ok, we need to modify the build script so that it has "esp32" and "esp32s3" as targets, but other than that...? |
|
As you guessed, this is exactly the reason: the pull request changes the build script from esp32s3 to esp32. As you suggest, modifying the build script to support both esp32 and esp32s3 is the better solution. Best regards. |
|
I can confirm, that it works in general. |
|
Awesome! I wouldn't mind merging this! We will have to start carrying 2 builds (esp32 and esp32s3) which means more release artifacts, double the OTA update images, double the webinstaller images,... but this was bound to happen :-D Let's push out the 0.8.0 release as a "stable" checkpoint and then integrate this one for the next release. |
|
Build fails because the move command uses esp32s3 image name instead of esp32 image name: /Users/runner/.espressif/python_env/idf5.4_py3.14_env/bin/python -m esptool --chip esp32 -p (PORT) -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 40m --erase-all 0x0 /Users/runner/work/MicroPythonOS/MicroPythonOS/lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC-SPIRAM-16.bin ~/work/MicroPythonOS/MicroPythonOS |
| if (btn_a.value() == 0) and (btn_c.value() == 0): | ||
| current_key = lv.KEY.ESC | ||
|
|
||
| # Key repeat logic |
There was a problem hiding this comment.
In #35 i implement a other auto-key-repeat solution. Maybe it fits also for the FIRE ?
REPEAT_INITIAL_DELAY_MS = 300 # Delay before first repeat
REPEAT_RATE_MS = 100 # Interval between repeats
next_repeat = None # Used for auto-repeat key handling
def input_callback(indev, data):
global next_repeat
current_key = None
if crossbar_pressed := crossbar.poll():
current_key = crossbar_pressed
elif button_menu.value() == 0:
current_key = lv.KEY.ESC
# ... handle other buttons here ...
else:
# No crossbar/buttons pressed
if data.key: # A key was previously pressed and now released
# print(f"Key {data.key=} released")
data.key = 0
data.state = lv.INDEV_STATE.RELEASED
next_repeat = None
return
# A key is currently pressed
current_time = time.ticks_ms()
repeat = current_time > next_repeat if next_repeat else False # Auto repeat?
if repeat or current_key != data.key:
print(f"Key {current_key} pressed {repeat=}")
data.key = current_key
data.state = lv.INDEV_STATE.PRESSED
if current_key == lv.KEY.ESC: # Handle ESC for back navigation
mpos.ui.back_screen()
elif current_key == lv.KEY.RIGHT:
mpos.ui.focus_direction.move_focus_direction(90)
# ... handle other buttons here ...
if not repeat:
# Initial press: Delay before first repeat
next_repeat = current_time + REPEAT_INITIAL_DELAY_MS
else:
# Faster auto repeat after initial press
next_repeat = current_time + REPEAT_RATE_MS
| TFT_HOR_RES=320 | ||
| TFT_VER_RES=240 | ||
|
|
||
| spi_bus = machine.SPI.Bus( |
There was a problem hiding this comment.
Seems this doesn't work in a soft reset. So why not doing this:
try:
spi_bus = machine.SPI.Bus(host=SPI_BUS, mosi=LCD_MOSI, sck=LCD_SCLK)
except Exception as e:
print(f"Error initializing SPI bus: {e}")
print("Attempting hard reset in 3sec...")
time.sleep(3)
machine.reset()
There was a problem hiding this comment.
Probably fine, I mean it's a workaround, not a fix, or something that seems trivial, but it's better than nothing, I guess...
I never understood why those soft resets even happen... any idea? I think I disabled them at some point in mpremote.py because of... issues...
I've added esp32 and esp32s3 as separate targets, should be good now, if not, I'll fix it. |
|
It's merged, and I had to move around drivers around to make a unified build, but I don't have the hardware to test and make sure I properly adjusted the imports etc. Would you mind trying the latest esp32 build from https://github.com/MicroPythonOS/MicroPythonOS/actions/ ? Thanks a lot for your help! |
|
After testing the latest esp32 build (MicroPythonOS_esp32_0.8.1.bin), I can confirm that it works as expected in the M5Stack-Fire. Best regards. |
Only display and buttons support for M5Stack-Fire.
DON'T merge directly to the main branch. Create his own branch.
demo.mp4