echo-lalia / MicroHydra

MicroHydra is a simple, 'OS-like', MicroPython based app switcher designed for ESP32 based devices.
GNU General Public License v3.0
136 stars 14 forks source link

Major API Overhaul is required for MicroHydra to enable multiplatform support. #65

Closed echo-lalia closed 4 weeks ago

echo-lalia commented 1 month ago

In MicroHydra 1.0, the API for controlling the hardware is highly specific to the Cardputer. This means that, to create apps that work on multiple devices, you would need to completely rewrite large parts of the code for every single device.

In order for MicroHydra to support multiple platforms (such as the Cardputer II and the original Cardputer) simultaneously, the API for all of the built-in modules must be redesigned such that apps no longer need to specify exact Pins or other device-specific parameters in order to control things like the display, speaker, keyboard, etc.

For example, this:

# init object for accessing display
tft = st7789fbuf.ST7789(
    machine.SPI(
        1,baudrate=40000000,sck=machine.Pin(36),mosi=machine.Pin(35),miso=None),
    _DISPLAY_HEIGHT,
    _DISPLAY_WIDTH,
    reset=machine.Pin(33, machine.Pin.OUT),
    cs=machine.Pin(37, machine.Pin.OUT),
    dc=machine.Pin(34, machine.Pin.OUT),
    backlight=machine.Pin(38, machine.Pin.OUT),
    rotation=1,
    color_order=st7789fbuf.BGR
    )

Will not work on anything except the Cardputer.

MicroHydra can use device-specific modules to simplify this process, and make the display initialization code in each app would look like this:

tft = Display()
echo-lalia commented 1 month ago

FYI, this change is already being implemented in the experimental-multiplatform branch.

Currently, I am using a few different techniques in an attempt to simplify multiplatform development, including:

And more to come, hopefully :)