Merged
Conversation
1501931 to
e6aa184
Compare
Add a mode to return the framebuffer to the user without being cleared. Allows for a slightly better framerate when the whole screen is overdrawn.
Add builtins for X2, X4 and OFF so we can: image.antialias = X2
9df9098 to
23b6d91
Compare
Closed
Deprecate passing True/False into display.update() to pick pixel doubled vs full resolution. Move this to display.fullres(True / False)
a778ad1 to
5bc7c5b
Compare
This violated the cardinal rule: don't write to FAT from the board. Highly probable source of our corrupt-from-just-resetting issue. Remove any attempt to recover the FAT during boot and instead emit an error. This leaves us with room to inspect or attempt to recover the filesystem rather than the board simply resetting it.
Allow the user to attach Thonny or a serial terminal and try to diagnose, recover or reformat the filesystem. Note: _boot_fat.py occurs before USB is enabled.
c9d22ea to
b645e17
Compare
badge.default_pen(pen) -> badge.default_pen = pen badge.default_clear(pen) -> badge.default_clear = pen w, h = badge.resolution() -> w, h = badge.resolution badge.set_caselights(c1[, c2, c3, c4]) -> badge.caselights(c1[, c2, c3, c4]) c1, c2, c3, c4 = badge.get_caselights() -> c1, c2, c3, c4 = badge.caselights()
8d7973e to
cd2ab9e
Compare
Originally "initial_refresh", first_update was used internally to indicate when a badge should do a full display refresh: set when launching an app or starting from a cold boot.
520a12d to
af36b98
Compare
launch now accepts only a filename, since it is not doing the double duty that run did to make apps tenable in Thonny. run now takes only an update function and either loops indefinitely, or runs for a given duration in ticks. launch expects an app to block or call run, otherwise it will exit back to the menu. The update function is no longer implicitly called by the system, and must be called in the app (using run(update)) if you decide to use one at all. If run is given a duration it will provide a progress value, in all cases the run function has its own internal ticks timed from the start of the run. These are available inside a running function as builtins: "loop.ticks" and "loop.progress".
Since __import__ would never return in blocking apps, app would never get set. Retrieve on_exit from sys.modules instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
with-filesystembuild since there are breaking changes which require the apps to be updated. Back up your filesystem first!Latest experimental build here: https://github.com/pimoroni/tufty2350/actions/runs/22391690121/artifacts/5651200980
Release Notes (Draft)
Building upon the shipping firmware we've made many changes to the shape and
function of the Badgeware API. A lot of these changes are breaking, and you
will have to update your code for this release.
Bugfixes
FAT Filesystem Corruption
Users were encountering problems with the FAT "/system" partition spontaneously
erasing itself. This usually presents as the badge becoming unresponsive, with
Badger in particular showing the same screen (since it's never updated again.)
After much deliberation I realised we're setting the filesystem label every
time the board boots. This means there's a write to the FAT filesystem which
could potentially go wrong†. This is now removed, with the label set in the
filesystem image instead. This should ensure a more robust filesystem.
† - by wrong, I mean that a flash write starts with a block erase and if your
board resets between the erase and the new data being written then you have
a 4k empty block where there should have been 1/4th of file allocation table.
Other Bugfixes
Changes
Running Apps
Our
updateloop setup for apps worked very well for games, and terribly foreverything else. We've heard your troubles with this approach, and had some
of our own.
launchhas now been split intolaunch, which accepts a file path and loadsan app, and
runwhich runs anupdatefunction, or any other function, ineither a continuous loop or one with a duration.
All apps now own their main loops, so you can simply
while Trueyour way toapp nirvana (at least on Blinky and Tufty, Badger is a whole different animal.)
To update your existing
updatebased apps, you just need to add:To the bottom of your
__init__.py. If you've already got a Thonny fixup:Then delete it and swap it to the above.
runwill run a function for you, handling the clear, update and poll callsneeded to keep Badgeware ticking. You don't have to use it, though, and can
call the new
badge.update()function to update, clear and poll, or callscreen.update(),badge.clear()andbadge.poll()separately. Up to you!A typical main loop might look like this:
You can now also access the buttons like they were ordinary MicroPython Pin
objects (because they are) so
BUTTON_A.value()will give you the currentraw status of a button (0 when pressed) regardless of polling.
Badger
Since a display update is so costly on Badger, it works a little different
from the other boards. You can still
run()yourupdatefunction, but youmust call
badge.update()to update the display when you want to.You may also call
wait_for_button_or_alarm(timeout=5000)which will sit ina loop calling
badge.poll()and waiting for a button press or an alarminterrupt. After the timeout time (in ticks/milliseconds) your badge will go
into deep sleep to conserve battery. This timeout can be as long as you feel
is necessary for your app, or
Noneto never automatically sleep.Note: Badger will not sleep while connected to power!
To update an existing app, you would do:
Badger also gets a new
NON_BLOCKINGmode flag, letting you update the displayasynchronously. We've deployed this in the Menu, making it feel more responsive.
General
/system/main.pyis missing/systemfails to mountDrawing
color.blackandcolor.whiteare now set to pure black/white on Badger and Blinkypen()has been removed, usescreen.pen = vAdvanced Drawing
vspan_texis nowblit_vspanand we have a newblit_hspancounterpart.raycastalgorithm, and a single-rayddaBuiltin Functions
free()is now a builtin (call to show the memory delta)run()is now a builtin, and can take a filename, eg:run("/system/apps/menu")Badge (formerly known as io)
iois nowbadgeand some straggler functions have been moved to badge:io.tickstobadge.ticksio.ticks_deltatobadge.ticks_deltabadgeware.get_battery_level()is nowbadge.battery_level()badgeware.is_charging()is nowbadge.is_charging()badge.model(new) returns "tufty", "blinky" or "badger" depending on the board.badge.uidreturns the board UID (hex) as an ASCII string.set_caselights()is nowbadge.caselights(), and caselights are gamma corrected.badge.first_update(Badger only)mode()is nowbadge.mode()mode()now supportsVSYNC† (Tufty only)badgeware.get_disk_usage()moved tobadge.disk_free()and now returns total, used and free in bytesbadge.default_clearandbadge.default_pento control the update better† - Avoiding
VSYNCwill normally give you a better framerate where your app logic takes over ~8ms, since you wont be missing entireVSYNCperiods and having to wait up to 16.6ms. UsingVSYNCwill fix screen tearing at the cost of raw framerate. Currentlydisplay.update()on Tufty blocks for around 7.7ms leaving you only 8ms for logic/drawing. To enableVSYNCwhen changing mode usebadge.mode(HIRES | VSYNC)orbadge.mode(LORES | VSYNC)Images
SpriteSheetandAnimatedSpriteare now builtin, you need notimage.load(open("image.jpg", "rb").read())my_image = image.load(filename, max_width, max_height)RTC
rtcnow has its own module.Text
Both vector and pixel fonts now support UTF-8 codepoints, a fairly critical omission
from our shipping firmware- you can now use the degrees symbol and much, much more.
Advanced text layout functions have been moved to
text, a builtin providing:text.scroll()which has been modified heavily fromscroll_text()text.tokenise()text.draw()which should now return the correct boundsTwo new ROM fonts have been added:
badgewarebadgewaremaxThe font
yolkhas been updated with better language support.Technical Stuff
MICROPY_OBJ_REPRtoMICROPY_OBJ_REPR_C, which is slightly faster at the cost of RAM