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>
- 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>
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>
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>
The code snippet in hwconfig to adjust the drive strength was incorrect:
It was adjusting the wrong pins. This was probably not updated during
some pin shuffling in the breadboard phase.
Fix this by adjusting the correct pins. Experimentation shows that both
setting the slew rate to fast or setting the drive strength to 8 mA
(default: slow and 4 mA) is sufficient to make SD SPI work at 25 MHz on
the Rev1 PCB. For now, the combination 8 mA and slow is chosen (slow
slew rate should result in less high frequency EMI).
Also make the SD clock rate adjustable in hwconfig, and set it to 25 MHz
for Rev1 and 15 MHz for the breadboard setup.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
- Increase the formatting of playlist entries to allow up to 100000
tracks. Also enforce that playlist entries are indexed by integers
using the validate method.
- Add a validate method to validate the data stored in the
btreedb. Optionally dump the contents to stdout. For testing, add a
validate+dump by default when opening the db. This can be removed once
the playlistdb is validated.
Add playlist database based on the micropython 'btree' module.
Supported features are:
* Create playlist
* Load playlist
* Store position in playlist
Different playlist modes will be added in a followup for #24.
Implements #23.
The playlist data is stored in the btree database in a hierarchical
schema. The hierarchy levels are separated by the '/' character.
Currently, the schema is as follows: The top level for a playlist is the
'tag' id encoded as a hexadecimal string. Beneath this, the 'playlist'
key contains the elements in the playlist. The exact keys used for the
playlist entries are not specified, they are enumerated in native sort
order to build the playlist. When writing a playlist using the
playlistdb module, the keys are 000, 001, etc. by default. The
'playlistpos' key is also located under the 'tag' key and stores the key
of the current playlist entry.
For example, a playlist with two entries 'a.mp3' and 'b.mp3' for a tag
with the id '00aa11bb22' would be stored in the following key/value
pairs in the btree db:
- 00aa11bb22/playlist/000: a.mp3
- 00aa11bb22/playlist/001: b.mp3
- 00aa11bb22/playlistpos: 000
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Move hardware-specifics (pin assignments, power management) to
hwconfig_*.py.
The build system will build a firmware image
firmware-filesystem-$variant.uf2 for all variants for which a
hwconfig_$variant.py file exits. Inside the filesystem image, the
selected variants hwconfig_$variant.py file will always be named
hwconfig.py.
At runtime, main.py will attempt to import hwconfig which will load the
configuration for the correct variant.
Currently, the hwconfig_* modules are expected to define the pin mapping
and implement a board_init method.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Make mypy run with proper type stubs for micropython RP2.
Add basic structure for pytest testing.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Add utils.MBRPartition to implement basic partitioned device support.
Try to mount partition 1 of SDCard first, if that fails, try to mount
entire device as FAT file system.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Change PlayerApp to new architecture
- depedencies injected via named tuple
- some initial type checking
- move on button press logic to PlayerApp
TODO: Adapt MP3 player
Copy and clean up test.py to main.py. Add app module (currently on
app.py, maybe make it a directory later) for application classes.
Implement app.TimerManager to allow scheduling of delayed events in the
micropython async framework.
Implement app.TagPlaybackManager which handles playing back MP3 files
based on the NFC tag reader. Currently, simply plays all MP3 files in a
folder, for which the folder name matches the tag id, in order. Resume,
random and other features not yet supported.