picogame: two RGB444 fixes - #11428
Merged
Merged
Conversation
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.
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.
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.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 fromcleanup_after_vm(), beforereset_displays(). A released display is skipped.Pack RGB444 on the immediate render path. The pack was only in the port
Displaybackends (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 withpicogame_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).