Skip to content

Commit

Permalink
Add automatic provisioning of the frontboard, from mpy files in github
Browse files Browse the repository at this point in the history
TODO: This currently still builds the files into the firmware, the github action needs changing to mpy-cross these independently
  • Loading branch information
MatthewWilkes committed May 30, 2024
1 parent f22c91a commit b9f2917
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ jobs:
micropython/ports/esp32/build-tildagon/partition_table/partition-table.bin
micropython/ports/esp32/build-tildagon/ota_data_initial.bin
micropython/ports/esp32/build-tildagon/tildagon.txt
micropython/ports/esp32/build-tildagon/frozen_mpy/frontboards/TwentyFour/app.mpy
micropython/ports/esp32/build-tildagon/frozen_mpy/frontboards/TwentyFour/tokens.mpy
- name: Create latest release for tags
uses: "marvinpinto/action-automatic-releases@latest"
if: github.event_name == 'push'
Expand Down
6 changes: 6 additions & 0 deletions modules/app_components/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ def clear_background(ctx):

def set_color(ctx, color):
ctx.rgb(*ui_colors.get(color, colors.get(color, color)))


try:
from frontboard.tokens import * # noqa: F403
except ImportError:
pass
22 changes: 22 additions & 0 deletions modules/frontboards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
from app import App
from system.hexpansion.util import read_hexpansion_header, get_hexpansion_block_devices
import vfs


class FrontBoard(App):
year: int


def mount_frontboard(i2c, readonly=True):
header = read_hexpansion_header(i2c, eeprom_addr=0x57)
if header is None:
return False

try:
eep, partition = get_hexpansion_block_devices(i2c, header, addr=0x57)
except Exception:
return False

mountpoint = "/frontboard"

try:
vfs.mount(partition, mountpoint, readonly=readonly)
except OSError:
return False

return True
43 changes: 0 additions & 43 deletions modules/frontboards/twentyfour.py

This file was deleted.

Binary file removed modules/lib/requests/__init__.mpy
Binary file not shown.
Binary file removed modules/lib/urequests.mpy
Binary file not shown.
44 changes: 37 additions & 7 deletions modules/main.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
# main.py -- put your code here!
from esp32 import Partition
import machine
import os

from system.scheduler import scheduler
from system.hexpansion.app import HexpansionManagerApp
from system.patterndisplay.app import PatternDisplay
from system.notification.app import NotificationService
from system.launcher.app import Launcher
from system.power.handler import PowerEventHandler
import display
import frontboards
import tildagonos

from frontboards.twentyfour import TwentyTwentyFour

tildagonos.tildagonos.init_gpio()
display.gfx_init()


# Start front-board interface
scheduler.start_app(TwentyTwentyFour())

fb_i2c = machine.I2C(0)
frontboard = 0x57 in fb_i2c.scan()
if frontboard:
# We have a frontboard, try to mount it
mounted = frontboards.mount_frontboard(fb_i2c)
print(f"Frontboard mounted {mounted}")
if not mounted or "app.mpy" not in os.listdir("/frontboard"):
# Provision the board if not mountable
import provision_fb

provision_fb.populate_fb()


# Do main imports after mounting the frontboard so they can
# import the year's design tokens
from system.scheduler import scheduler # noqa: E402
from system.hexpansion.app import HexpansionManagerApp # noqa: E402
from system.patterndisplay.app import PatternDisplay # noqa: E402
from system.notification.app import NotificationService # noqa: E402
from system.launcher.app import Launcher # noqa: E402


# Start expansion interface
scheduler.start_app(HexpansionManagerApp())
Expand All @@ -28,6 +51,13 @@

PowerEventHandler.RegisterDefaultCallbacks(PowerEventHandler)

if frontboard:
# Import the interface and start the app
import frontboard.app

scheduler.start_app(frontboard.app.__app_export__())


Partition.mark_app_valid_cancel_rollback()

scheduler.run_forever()

0 comments on commit b9f2917

Please sign in to comment.