Refactor Animation to simplify

Also add some documentation on how to write animations.
This commit is contained in:
Stefan Bethke 2025-06-16 09:33:22 +02:00
commit 64a3c729be
12 changed files with 302 additions and 223 deletions

View file

@ -48,21 +48,29 @@ Buba is configured completely through environment variables:
## Creating Animation Plugins
Buba instantiates objects of type `BubaAnimation` and runs through them in a loop. Each animation must implement the
`run()` method, which should send data to the display. The animation is run in its own thread, therefor, the animation
`show()` method, which should send data to the display. The animation is run in its own thread, therefore, the animation
should sleep an appropriate time to let users take in the information. See the existing animations
in [buba/animations](./buba/animations) for inspiration.
Note: if you need to fetch and update external information regularly, you should start your own thread when initalizing
your animation.
To implement your own animation, subclass [BubaAnimation](buba/bubaanimation.py).
In the `__init__()` method, you will want to set `self.title`, and configure your data source.
Implement `update()` to fetch any data and fill in `self.rows` (list of rows). Each row in `self.rows` is a list of
values for the columns in the layout.
The default layout has a wide, left-aligned column for text, and a short, right-aligned column for a time period or a
value. You can define your own layout if necessary.
If you do not want to show tabular data, you can override `show()` and implement sending text to the display yourself.
## Character Set
The display uses [Code Page 437](https://en.wikipedia.org/wiki/Code_page_437), with a few exceptions. Due to the limited
resolution of the segments, the display can deviate significantly.
Note that the [Python codecs](https://docs.python.org/3/library/codecs.html) for `CP437` do not map all special characters correctly.
Note that the [Python codecs](https://docs.python.org/3/library/codecs.html) for `CP437` do not map all special
characters correctly.
| Code | CP437 | Geavision Spaltenschrift |
|------|--------------|--------------------------|