Conversation
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" |
There was a problem hiding this comment.
for consistency, this could be plural /patterns like /backgrounds and /apps
There was a problem hiding this comment.
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.
modules/system/patterndisplay/app.py
Outdated
| if path_isfile(path): | ||
| try: | ||
| _patternpath = f"pattern.{self.pattern[1]}.app" | ||
| _patternclass = "__Pattern_export__" |
There was a problem hiding this comment.
for consistency with app_export this could be lowercase
There was a problem hiding this comment.
I've updated this. I'll still need to update my app and test it.
|
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 👍 |
| ], | ||
| ) | ||
| _pclass = getattr(_pmodule, _patternclass) | ||
| self._p = _pclass() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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?
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?
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?
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