Skip to content

feat: add Last.fm app - #10

Closed
bombsimon wants to merge 1 commit into
MatrixBOX-dev:mainfrom
bombsimon:feat/last-fm
Closed

feat: add Last.fm app#10
bombsimon wants to merge 1 commit into
MatrixBOX-dev:mainfrom
bombsimon:feat/last-fm

Conversation

@bombsimon

@bombsimon bombsimon commented Jun 16, 2026

Copy link
Copy Markdown
Member

I know this is a completely new concept, feel free to reject it without any reason!

I think it's important that you understand the approach and feel that it's a good one and that you can maintain it, even though I of course plan to keep maintaining this as well. If the approach feels too complex I see two options:

  • Keep it as is but in a separate repository, users will have to manually side-load it if they want it
  • Drop everything around mpy-cross, build.py and just put the app as-is in apps/

Last.fm app

This adds an app to poll Last.fm for what's currently playing. See app README for more information.

The app can be configured to set colors, shadow, alignment, one or multiple rows etc.

Additional changes

This PR also contains a new concept which will allow you to write code with clear comments and clear structure but at the same time use less space on the device. The PR introduces an src directory where human readable and formatted code can be put.

The code in src/lastfm is formatted with ruff for Python and prettier for HTML. However the idea is to "build" this app with tools/build.py using mpy-cross for Python and HTML minifier for the HTML.

Another thing that I haven't seen in other apps worth mentioning is that this app auto-exits on inactivity. The reason is because to get a snappy feeling of quick updates the app polls every 5s which isn't really needed when nothing is playing. This is configurable.

I personally think this gives more flexibility around quality and maintainability but it also allow us to implement other tools in the build process such as HTML templating to ensure all apps uses the same styling and layout.

Some measurements from this app:

┌────────────────────┬────────┬───────┬─────────────┐
│        file        │  src/  │ apps/ │    saved    │
├────────────────────┼────────┼───────┼─────────────┤
│ code.py → code.mpy │  9,839 │ 4,198 │ 5,641 (57%) │
├────────────────────┼────────┼───────┼─────────────┤
│ lastfm.html        │  6,142 │ 4,658 │ 1,484 (24%) │
├────────────────────┼────────┼───────┼─────────────┤
│ init.py            │     81 │    81 │           0 │
├────────────────────┼────────┼───────┼─────────────┤
│ v0.1               │      2 │     2 │           0 │
├────────────────────┼────────┼───────┼─────────────┤
│ total              │ 16,064 │ 8,939 │ 7,125 (44%) │
└────────────────────┴────────┴───────┴─────────────┘

Worth noting the .mpy figure is flash footprint. The bigger on-device win is usually RAM and import time: shipping code.mpy means the device skips compiling the .py at launch, no parser/compiler allocation, no source held in memory.

If you don't think this is a good idea I can try to slim down the app and code and move it direclty under apps. If you do think this is a good idea I can look into porting all apps to this structure. Or we can just keep it for some apps like this one.

Pictures

image image image image image

@matrixbox

Copy link
Copy Markdown
Collaborator
  1. Auto-exit sounds great, it could probably be implemented in other apps as well
  2. We were using .mpy-files for a while but thought it would be more transparent with uncompiled code. Your idea to include an optional /src subdirectory is interesting, though. So far, the uncompiled apps don't take up that much space but if apps were to increase in number it could be worthwhile.
  3. Let's start by putting the Last.fm app in the apps directory as code? If that's OK with you!

@bombsimon

Copy link
Copy Markdown
Member Author

Thanks for the feedback!

Let's start by putting the Last.fm app in the apps directory as code? If that's OK with you!

Sounds very reasonable to start with and it's easy enough to add and remove apps if storage becomes an issue! I still have close to 200kb free space so a bit pre-mature optimization on my end (although I partly just wanted to discuss the topic).

I'll update the PR and remove the split and drop the build tool as soon as I get some time over!

- Fix scrolling/resetting
- Fix margins
- Fix refresh loop
- Drop comments
- Update settings UI
@bombsimon

Copy link
Copy Markdown
Member Author

@matrixbox Hey! Looks like you added the Last.fm app but not by merging this PR.

I had some outstanding tasks that I was planning to fix so instead I updated this PR to contain them. I rebased on main now so you should be able to just merge this. See commit message for changes.

PS. I always enable edits from maintainers on my PRs so feel free to (force) push any changes to my branches and merge them if you want to!

@bombsimon

bombsimon commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Actually, I think the history will be cleaner and easier to follow in a new PR so I'll create a new one!

Created #14

@bombsimon bombsimon closed this Jun 19, 2026
@matrixbox

Copy link
Copy Markdown
Collaborator

Done! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants