Skip to content

custom LED patterns#235

Open
ChrisDick wants to merge 7 commits intomainfrom
custom-patterns
Open

custom LED patterns#235
ChrisDick wants to merge 7 commits intomainfrom
custom-patterns

Conversation

@ChrisDick
Copy link
Contributor

Feature to allow user LED pattern apps. also add API for normal apps to set the LED pattern without changing the settings

Description

Please include a summary of the change and what is does. Please also include relevant motivation and context.
see #228 and #234

Feature to allow user LED pattern apps. also add API for normal apps to set the LED pattern without changing the settings
from system.scheduler.events import RequestForegroundPushEvent

BG_DIR = "/backgrounds"
PAT_DIR = "/pattern"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency, this could be plural /patterns like /backgrounds and /apps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the patterns directory already exists in the modules directory. This means that the import path is patterns.xyz and changing the user directory to patterns causes a conflict with this. Since that's already out in the wild and in use, I had to use the singular. I'm open to alternative name suggestions.

if path_isfile(path):
try:
_patternpath = f"pattern.{self.pattern[1]}.app"
_patternclass = "__Pattern_export__"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency with app_export this could be lowercase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this. I'll still need to update my app and test it.

@benclifford
Copy link
Contributor

I just tried this out because I was hitting the problems with too many of my own apps wanting to be in charge of the LEDs. It merges cleanly into main right now. It was pretty straightforward to port one of my apps to be a pattern, and I like both the UI and the amount of App code I could delete.

👍

],
)
_pclass = getattr(_pmodule, _patternclass)
self._p = _pclass()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this raises an error due to my terrible user-provided pattern implementation having a bug in its __init__, then when I power up my tildagon, I get a blank screen/dead tildagon that needs external intervention (to stop this pattern loading at startup) - it crashes main.py.

For example my pattern that expects wifi to be up:

Traceback (most recent call last):
  File "main.py", line 24, in <module>
  File "system/patterndisplay/app.py", line 27, in __init__
  File "system/patterndisplay/app.py", line 56, in load_pattern
  File "pattern/wiflame/app.py", line 18, in __init__
OSError: Wifi Internal Error

I'm happy to do some work here -- it's definitely going to bug me again while I play with patterns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've stopped this from crashing the badge, now if the app has a bug, the LEDs will just be off. It'll print out on the usb what is causing the crash.

benclifford added a commit to benclifford/tildagon-badge-2024-software that referenced this pull request Jan 24, 2026
print backtrace on pattern crash, for debugging

assert that a pattern should be a BasePattern, to give more of a clue than missing fields later. (this one probably
isn't for merge, in so much as it doesn't fit the style of the rest of the firmware being untyped?)

catch boot time pattern construction errors. this isn't very principled, but it should help me survive a pattern crash?
benclifford added a commit to benclifford/tildagon-badge-2024-software that referenced this pull request Jan 26, 2026
print backtrace on pattern crash, for debugging

assert that a pattern should be a BasePattern, to give more of a clue than missing fields later. (this one probably
isn't for merge, in so much as it doesn't fit the style of the rest of the firmware being untyped?)

catch boot time pattern construction errors. this isn't very principled, but it should help me survive a pattern crash?
benclifford added a commit to benclifford/tildagon-badge-2024-software that referenced this pull request Jan 26, 2026
print backtrace on pattern crash, for debugging

assert that a pattern should be a BasePattern, to give more of a clue than missing fields later. (this one probably
isn't for merge, in so much as it doesn't fit the style of the rest of the firmware being untyped?)

catch boot time pattern construction errors. this isn't very principled, but it should help me survive a pattern crash?
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.

2 participants