Skip to content

Allow hexpansions to add themselves to launcher#321

Open
walkerdanny wants to merge 4 commits into
emfcamp:mainfrom
walkerdanny:hexpansion-management
Open

Allow hexpansions to add themselves to launcher#321
walkerdanny wants to merge 4 commits into
emfcamp:mainfrom
walkerdanny:hexpansion-management

Conversation

@walkerdanny

Copy link
Copy Markdown
Contributor

Description

As per #317 and #184 this is a working (as far as my testing has revealed) way for hexpansion EEPROM apps to add themselves to the launcher.

It adds four new event types to add a hexpansion to launcher, remove a hexpansion from launcher, start a hexpansion app and stop a hexpansion app. Not crazy about the names of these so please suggest better ones if you have ideas, naming things is hard.

This is done on a port number basis, so multiple hexpansions of the same type should each be able to have their own instance of the app. That felt like the right approach.

The hexpansion glyph allocated in #316 is prepended to app names so they appear in the launcher with a hexpansion next to them (eventually)

I get the occasional glitch with this that sorts itself out after a while, but I think this happens when a hexpansion isn't inserted properly or gets inserted and removed quickly, so it's probably not unique behaviour to this branch.

A minimum working hexpansion app for testing is:

import app
from system.eventbus import eventbus
from events.input import Buttons, BUTTON_TYPES
from system.hexpansion.events import HexpansionAppLauncherAddEvent
from app_components import clear_background
from system.scheduler.events import RequestForegroundPushEvent

class TestApp(app.App):
    def __init__(self, config=None):
        self.app = app
        self.button_states = Buttons(self)
        self.hexpansion_config = config
        self.foregrounded = False
        self.add_to_launcher()

    def add_to_launcher(self):
        eventbus.emit(HexpansionAppLauncherAddEvent(self.hexpansion_config.port, "Hexpansion Test App"))

    def update(self, delta):
        if not self.foregrounded:
            print("Requesting foreground push")
            eventbus.emit(RequestForegroundPushEvent(self))
            self.foregrounded = True
        if self.button_states.get(BUTTON_TYPES["CANCEL"]):
            self.button_states.clear()
            self.minimise()

    def background_update(self, delta):
        # Do nothing in the background
        pass

    def draw(self, ctx):
        clear_background(ctx)
        ctx.font_size = 20
        ctx.text_align = ctx.CENTER
        ctx.rgb(255,255,255).move_to(0, 0).text("Test app foregrounded")
        return None

__app_export__ = TestApp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant