- 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>
Spurious failures were observed with a SanDisk Ultra 32GB card that no
longer occur with the increased timeouts.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
The check-format and clang-format targets were not adjusted when the
code was reorganized in commit 7f8282315e ("Restructure sources"). Fix
it to find the C sources that are now in the modules directory.
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>
- Old SDSC cards could have a native blocksize != 512 bytes, but they
should support the SET_BLOCKLEN command to set the blocksize to 512.
Use that so we can just assume 512 everywhere else.
- SDSC cards used byte addresses, not sector numbers, for the argument
of READ_BLOCK and WRITE_BLOCK. Check the card type and multiply the
sector number with 512 if necessary.
Tested with a noname chinese 128 MiB-ish card.
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>
Migrated all patches from the previous version.
A change in the Findpicotool.cmake script in the pico-sdk led to a
downgrade of picotool, which incorporated mbedtls into the build, which
itself is not buildable with cmake versions < 3.5.
The commit which made this isolated change was reverted. Future versions
of micropython will use pico-sdk 2.2.0 or newer, where this problem is
fixed, and picotool is pinned to a release version.
In theory, the FIFO interrupt could occur after getting the
fifo_read_value and reenabling interrupts, but before __wfi is called,
causing a deadlock. Fix this by calling __wfi with interrupts still
disabled. It will return immediately if an interrupt is pending.
Add two __nop to ensure that the CPU has enough instructions between
enabling interrupts and disabling them again at the top of the loop.
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>
Add write support to rp2_sd driver.
Cleanup standalone-mp3 test tool and add write test mode.
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.
Upgrade and cherry-picks were necessary due to a compilation issue
introduced with gcc 15.1 regarding unterminated string literals. For more
details see https://github.com/micropython/micropython/pull/17269.
Still hot and untested...
The python and C modules that are supposed to be built into the firmware
image (i.e. those that are in manifest.py or in USER_C_MODULES) have
been moved to the software/modules directory.
The software/src directory should now only contain python scripts and
other files that should be installed to the Picos flash filesystem. The
idea is that these should be those scripts that implement the
application behaviour, as these are the ones that a user who does not
want to build the whole firmware themself wants to modify.
Rename the exising audiocore C module to _audiocore and create a new
Micropython wrapper module audiocore. This makes it easier to implement
async methods.
Add interrupt support to _audiocore that notifies core0 whenever data
has been consumed from the MP3 bitstream buffer.
Use this interrupt and an asyncio.ThreadSafeFlag to implement
audiocore.async_put which will play back the provided buffer, allowing
other async tasks to run while waiting for space in the bitstream
buffer.