Skip to content

Commit

Permalink
Updates testing on real hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewWilkes committed May 24, 2024
1 parent 5fd2a32 commit 8305cd3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 2 additions & 3 deletions modules/app_components/dialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import string

import display
from events.input import BUTTON_TYPES, ButtonDownEvent
Expand Down Expand Up @@ -70,7 +69,7 @@ def _handle_buttondown(self, event: ButtonDownEvent):


class TextDialog:
alphabet = string.ascii_letters
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

def __init__(self, message, app, masked=False, on_complete=None, on_cancel=None):
self.open = True
Expand All @@ -94,7 +93,7 @@ async def run(self, render_update):

# Tightly loop, waiting for a result, then return it
while self._result is None:
await asyncio.sleep(0.05)
await render_update()
self.app.overlays.pop()
await render_update()
return self._result
Expand Down
13 changes: 11 additions & 2 deletions modules/firmware_apps/text_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import app
from app_components import TextDialog, clear_background
from events.input import BUTTON_TYPES, ButtonDownEvent
from system.eventbus import eventbus


class TextDemo(app.App):
Expand All @@ -16,14 +18,21 @@ async def run(self, render_update):
if await dialog.run(render_update):
self.name = dialog.text

eventbus.on(ButtonDownEvent, self._handle_buttondown, self)

self.overlays = []
await render_update()
while True:
await render_update()

def _handle_buttondown(self, event: ButtonDownEvent):
if BUTTON_TYPES["CANCEL"] in event.button:
self.minimise()

def draw(self, ctx):
clear_background(ctx)

ctx.save()
ctx.text_align = "center"
ctx.text_align = ctx.CENTER
ctx.gray(1).move_to(0, 0).text("Hello " + self.name)
ctx.restore()

Expand Down
2 changes: 2 additions & 0 deletions modules/system/launcher/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ def list_core_apps(self):
# ("Name Badge", "hello", "Hello"),
("Logo", "firmware_apps.intro_app", "IntroApp"),
("Menu demo", "firmware_apps.menu_demo", "MenuDemo"),
("Kbd demo", "firmware_apps.text_demo", "TextDemo"),
# ("Update Firmware", "otaupdate", "OtaUpdate"),
# ("Wi-Fi Connect", "wifi_client", "WifiClient"),
# ("Sponsors", "sponsors", "Sponsors"),
# ("Battery", "battery", "Battery"),
# ("Accelerometer", "accel_app", "Accel"),
# ("Magnetometer", "magnet_app", "Magnetometer"),
("Update", "system.ota.ota", "OtaUpdate"),
("Power Off", "firmware_apps.poweroff", "PowerOff"),
# ("Settings", "settings_app", "SettingsApp"),
]
core_apps = []
Expand Down

0 comments on commit 8305cd3

Please sign in to comment.