Skip to content

picogame: two RGB444 fixes - #11428

Merged
dhalbert merged 2 commits into
adafruit:mainfrom
MakerClassCZ:picogame-reset-colmod
Sep 19, 2026
Merged

dhalbert merged 2 commits into
adafruit:mainfrom
MakerClassCZ:picogame-reset-colmod

Conversation

@lynt-smitka

Copy link
Copy Markdown

Two fixes for boards built with CIRCUITPY_PICOGAME_RGB444=1 (upstream: pajenicko_picopad). Both are inside #if CIRCUITPY_PICOGAME_RGB444; no change for other boards.

  1. Restore the panel format at exit. A program that switched the panel to RGB444 left it there, so the REPL afterwards was drawn in the wrong format. picogame_reset() sets it back to RGB565 from cleanup_after_vm(), before reset_displays(). A released display is skipped.

  2. Pack RGB444 on the immediate render path. The pack was only in the port Display backends (Scene.refresh()). picogame.render() sent the strip as RGB565 even when the panel was in RGB444, so HUDs and text drawn with it were garbled. The generic strip path now packs in place with picogame_pack_rgb444() when the target is the switched panel, with the region widened to even x bounds first, as the port backends do.

Tested on a PicoPad (RP2040) and a PyBadge (SAMD51): a picogame.render() HUD band over a Tilemap scene in RGB444 is correct with (2) and garbled without; the REPL is readable after exit with (1).

A program that switched the panel to RGB444 (COLMOD 0x53) and then
exited left it there: the panel keeps its pixel format, and the
CircuitPython console writes RGB565, so the console came up sheared
and colour-fringed - it looked like a broken display, not a setting.

Remember the display picogame_set_pixel_format() switched, and put it
back from cleanup_after_vm() while the bus is still alive (before
reset_displays()). A released display reads as a None bus, the same
check reset_displays() makes, so it is skipped.

Seen on a PyBadge after a game ran in RGB444; affects every board
built with CIRCUITPY_PICOGAME_RGB444.
pg.render() (and everything built on it: HudBar, TextBox, Menu) goes through
picogame_render_region -> picogame_out_strip_send, which always sent the
composited strip as RGB565. On a panel a fast Display had switched to 12-bit
RGB444 the panel reads those bytes as RGB444, so the immediate output shears
and colour-shifts while the scene underneath is fine (HUD band on a PyBadge
and a PicoPad, 2026-09-19).

Pack the strip in place with picogame_pack_rgb444 when the target is the
panel picogame_set_pixel_format switched, and widen the region to even x
bounds first, as the fast Display backends already do. +36 B text on
pybadge, RGB444 boards only; nothing changes for boards without the flag.

Verified with a HudBar + Tilemap check pattern on a PyBadge (SAMD51) and a
PicoPad (RP2040): the HUD band is clean in 12-bit mode on both.

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dhalbert
dhalbert merged commit 090c02b into adafruit:main Sep 19, 2026
691 checks passed
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