Skip to content

FunHouse board package works on stock MicroPython; board_peripherals import order on seven boards; MADCTL rotation on RGB panels - #112

Merged
bdbarnett merged 4 commits into
mainfrom
funhouse-board-fixes
Sep 26, 2026
Merged

bdbarnett merged 4 commits into
mainfrom
funhouse-board-fixes

Conversation

@bdbarnett

@bdbarnett bdbarnett commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

import board_config raised NameError: name 'AudioCapability' isn't defined on seven boards: funhouse, pyportal, pyportal_titano, pybadge, pygamer, odroid_go and hallowing_m4. Each one's board_peripherals.py used AudioCapability a line before importing it (from ec3d498). The import now comes first. tests/test_board_peripherals_static.py walks every board's module-level code in order and fails on a name used before it is bound. It flags exactly these seven on main, passes here, and carries a planted-fault case.

The FunHouse needed more than that before it would come up on stock MicroPython 1.29 (ESP32_GENERIC_S2):

  • The barometer is a DPS310 (product ID 0x10 at 0x77), not a BMP280. The BMP280 driver read chip ID 0x00 and pressure 0. The new drivers/env/dps310.py reports hPa and °C.
  • The board has no touchscreen, and nothing answers at 0x24, so the TT21100 is gone.
  • GPIO21 is the TFT backlight. The display now drives it. The DotStars used to claim it as SoftSPI MISO; they now use hardware SPI 2 with no MISO, starting at brightness 0.1.
  • There are new light (GPIO18 ADC) and motion (PIR, GPIO16) roles.
  • The package now ships drivers/bus/spibus.py, because stock firmware has no C spibus. On our own images the frozen or built-in one still loads first.

Proven on the FunHouse (MicroPython v1.29.0, pydevices 0.6.3 from the MIP index plus these files over serial):

display 240 240 16
pixels 5 brightness 0.1 all [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)]
DPS310 P hPa 1006.50  T C 24.95   AHT20 T 24.18 RH 51.1
light [3072, 3776, 4224] pir 1
PERIPHERALS ['audio_out', 'humidity', 'light', 'motion', 'pixels', 'pressure', 'temperature', 'wlan']

The other six boards get only the import move. None of them was on hand.

The package.json version is untouched.

Rotation on RGB panels (second commit)

On the FunHouse the screen came up upside down, and rotation couldn't turn it. BusDisplay.init() built MADCTL as self.rotation_table[index] | _BGR if self.bgr else _RGB, which parses as (table | _BGR) if bgr else _RGB. So every bgr=False panel has always sent MADCTL 0, whatever its rotation. The line is now parenthesised, and tests/test_busdisplay_madctl.py pins it down: it fails on the old line and passes on the new one.

Twelve board configs are bgr=False, all ST7789 on the default tables, all rotation=0, mirrored=False:

  • The ten that aren't the FunHouse move to mirrored=True. That table's rotation 0 is MADCTL 0, the same byte they have always sent, so they come up exactly as before, and setting rotation now works on them. None of them was on hand to look at.
  • The FunHouse (MicroPython and cp/) gets mirrored=True, rotation=180, which is MADCTL 0xC0, and keeps rowstart=80. The panel is mounted upside down against the controller. With MY set, the glass is still rows 80-319, as in CircuitPython's board definition, which keeps MY set and offsets that axis by 80. A first try with rowstart 0 showed the picture shifted up by about 80 rows. Read back on the board: MADCTL 0xc0 rot 180.

The cp/ FunHouse config also loses its TT21100, since the MicroPython I2C scan found nothing at 0x24 (only 0x38 and 0x77). The cp/ change is untested on CircuitPython.

…ds' import order fixed

- board_peripherals on seven PWM-buzzer boards (funhouse, pyportal,
  pyportal_titano, pybadge, pygamer, odroid_go, hallowing_m4) used
  AudioCapability a line before importing it, so import board_config
  raised NameError. New static test walks every board's module-level
  code and fails on a name used before it is bound.
- FunHouse: the barometer is a DPS310 (product id 0x10 at 0x77), not a
  BMP280; new drivers/env/dps310.py (hPa, C, continuous 4 Hz, 8x).
- FunHouse has no touchscreen: TT21100 removed (nothing answers 0x24).
- GPIO21 is the TFT backlight: the display now drives it, and the
  DotStars move to hardware SPI with no MISO instead of claiming it.
  DotStars start at brightness 0.1.
- New light (GPIO18 ADC) and motion (PIR, GPIO16) roles.
- The package ships drivers/bus/spibus.py, since stock MicroPython has
  no C spibus; a built-in spibus still wins where one is frozen.
…omes up the right way up

The MADCTL line parsed as (table | BGR) if bgr else RGB, so every
bgr=False panel sent MADCTL 0 and ignored rotation. With it
parenthesised, the ten other bgr=False boards (all ST7789, all
rotation 0) move to mirrored=True, whose rotation 0 is MADCTL 0: the
same byte they have always sent, and rotation now works on them.

FunHouse (MicroPython and cp/): the panel is mounted upside down
against the controller, so MX|MY (0xC0), the mirrored table's 180;
flipping rows puts the visible 240 of 320 at rows 0-239, so rowstart
80 becomes 0. Measured on the board: MADCTL 0xc0, rowstart 0.
@bdbarnett bdbarnett changed the title FunHouse board package works on stock MicroPython; seven boards' board_peripherals import order FunHouse board package works on stock MicroPython; board_peripherals import order on seven boards; MADCTL rotation on RGB panels Sep 26, 2026
@bdbarnett
bdbarnett merged commit f146ca9 into main Sep 26, 2026
3 checks passed
@bdbarnett
bdbarnett deleted the funhouse-board-fixes branch September 26, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant