- Reset the app idle timer when interacting with the webapp, so that the
device does not turn off while the web ui is used.
- Handle denying put/post while playback is active centrally in the
before_request handler, so that it does not need to be copy/pasted
into every request handler.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
- Reset the app idle timer when interacting with the webapp, so that the
device does not turn off while the web ui is used.
- Handle denying put/post while playback is active centrally in the
before_request handler, so that it does not need to be copy/pasted
into every request handler.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Implement nicer configuration UI:
- Show human-readable names for config settings
- Show error message received from server if storing settings fails
- Show appropriate input elements for enum choice and numerical inputs
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Merge defaults into config at load time to ensure that all config
options show up in the configuration dialog, even if they were added
after the local configuration was last changed.
Also use the merge method to merge the local config with the new config
in set_config, ensuring the config contains all keys even if the
submitted config leaves some out.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Probably due to memory/stack overrun, some more involved web API
requests cause the system to hang if performed during playback. For now,
block these requests during playback.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
If a timer is scheduled with the timer manager while it is already
scheduled, the new exipry time should override the prev. expiry time
instead of adding a second instance of the same timer function.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
- Remove Pin to button mapping from hwconfig, replace with a simple list
of Pins to which buttons are attached
- Add BUTTON_MAP to config.json which maps indices in the HW button list
to button names
- Update utils.Buttons to use the button map to connect the correct pins
to the matching key codes
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Add all python code run on the device to the manifest.py to freeze
it. This has two benefits:
- It precompiles the bytecode, so it is smaller and faster
- All code (C and python) is now in the firmware image, leaving the
littlefs filesystem on the flash free for user settings.
This requires changing the way the hardware variants are handled. There
is now only one _filesystem_ image, but instead there are different
_firmware_ images for each variant.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Allow the PlayerApp to turn off the device if it is idle for longer then
the timeout. The timeout is currently hardcoded to 1 minute, this will be
made configurable in the future.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Move the LED control to the utils.LedManager class. For the first
implementation, support two LED patterns 'idle' and 'playing'.
Extend the PlayerApp to set the LED pattern based on playback state.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
If the tagmode setting is 'tagremains' (the default): Play as long as the
tag is on the reader, with a 5 second timeout (i.e. playback stops when
tag is gone for more than 5 seconds).
If the tagmode setting is 'tagstartstop': Playback starts when a tag is
seen. Presenting a different tag causes the playback to stop and
playback for the new tag to start. Re-presenting the same tag used to
start with a no-tag-time of 5 seconds or more in between stops playback.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Split the tag handling in PlayerApp into two parts: The low level
handling of changed/removed tags from the Nfc reader, including the
timeout processing is moved into the nested TagStateMachine class. The
main PlayerApp has two new (internal) callbacks "onNewTag" and
"onTagRemoved" which are called when a new tag is presented or a tag was
actually removed. This will hopefully make the implementation of #28
"Configurable Tag Handling" cleaner.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
As we don't have an API to upload files and create playlists yet, we
used the convention "tag uid as directory name" to allow testing
playback. With the introduction of the database in #39 "Add playlist db"
a builddb() function to initialize the database from the tag directories
was added, but it is not automatically called. To make the developer
experience more ergonomical, add a check for that automatically runs
builddb() when no database exists.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
To simplify the playlist handling, enforce that the indices are always
formatted to the same length (5, which allows for 100000 entries, that
should be enough).
Then make the position stored in the Playlist object be a simple integer
instead of a database key. This simplifies the code, and will make
implementing shuffle much easier.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Add documentation of playlist database schema in DEVELOP.md.
Add settings for persist and shuffle to BTreeDB. Implement the different
persist modes. Shuffle will be implemented in a followup commit.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>