Skip to content

2D view of Astro Pi SenseHAT - #1719

Open
G3zz wants to merge 26 commits into
mainfrom
feature/2d-astro-pi-model
Open

G3zz wants to merge 26 commits into
mainfrom
feature/2d-astro-pi-model

Conversation

@G3zz

@G3zz G3zz commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds an alternative zoomed-in 2D view of the SenseHAT LED matrix to the AstroPiModel component. This feature was requested by the Youth Programmes team as we have observed through doing Mission Zero workshops that it is difficult to use the current 3D view of the Astro Pi on smaller or less powerful devices.

Users can now zoom in from the 3D view to a 2D view of the LED matrix, rendered using coloured divs: see the image below.

Screenshot 2026-11-05 at 16 58 10

Notes

  • I have included two icons from https://fonts.google.com/icons, which are Apache 2.0 licensed. The COPYRIGHT file has been updated accordingly.
  • Some array rotation is necessary to implement the 2D matrix. I've put the rotation code into a new utility file, namely src/utils/senseHatUtils.js

G3zz added 4 commits October 8, 2026 17:54
Basic div-based 2D render of the SenseHAT LED matrix.
Pixel state needs lifting to AstroPiModel so that it
can be shared between both 2D and 3D renderers.
Correctly use the pre-computed indexes passed
into `sense_hat_emit` to rotate the 2D grid.
@G3zz
G3zz temporarily deployed to previews/1719/merge October 30, 2026 14:14 — with GitHub Actions Inactive
Split out 2D and 3D scenarios
@G3zz
G3zz temporarily deployed to previews/1719/merge October 30, 2026 15:20 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge October 30, 2026 15:32 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge October 30, 2026 16:41 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge October 30, 2026 17:45 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge November 5, 2026 16:42 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge November 5, 2026 16:47 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge November 5, 2026 17:10 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge November 5, 2026 17:20 — with GitHub Actions Inactive
@G3zz
G3zz temporarily deployed to previews/1719/merge November 5, 2026 17:27 — with GitHub Actions Inactive
@G3zz G3zz changed the title Feature/2d astro pi model 2D view of Astro Pi SenseHAT Nov 5, 2026
@G3zz
G3zz marked this pull request as ready for review November 5, 2026 17:31
@macroscopeapp

macroscopeapp Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — Adds an optional 2D Sense HAT display while keeping 3D as the default. Effects are confined to the browser simulator, and the supplied orientation concern has a corresponding fix and regression coverage in the change.

Needs human approval because:

  • approvability is in preview mode for this repository — Macroscope would have approved this PR outside preview mode

Notes:

  • This comment was updated automatically after the outstanding correctness findings were resolved. Macroscope did not re-review the code.

You can add or adjust custom eligibility rules. Learn more.

Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
@G3zz
G3zz temporarily deployed to previews/1719/merge November 5, 2026 17:42 — with GitHub Actions Inactive
…ter rotated set_pixels. The 3D view leaves Sk.sense_hat.pixels in set_pixels order, so the 2D view needs the rotation index mapping to rebuild framebuffer order. It now gets that mapping… (#1732)

## Summary

Fixes the LED matrix losing its orientation when you switch from the 3D
view to the 2D view after a rotated `set_pixels` call.

The 3D view (FlightCase) leaves `Sk.sense_hat.pixels` in `set_pixels`
order, not framebuffer order. When the 2D view mounted, it read that
buffer as if it were already in framebuffer order. Any image drawn with
a non-zero rotation then showed up wrongly oriented in 2D.

## Changes

- **FlightCase**: saves the index mapping from the last `setpixels` in a
new field, `Sk.sense_hat.pixel_indexes`.
- **Simulator2d**:
- On its first snapshot, if `pixel_indexes` is set, it uses that mapping
with `rotate` to put the pixels back into framebuffer order. It then
writes the result back to `Sk.sense_hat.pixels` and clears
`pixel_indexes`.
- Its own `setpixels` handler also clears `pixel_indexes`, so an old
mapping can't be applied to pixels the 2D view set itself.

## Tests

- 3D→2D regression test: draws an asymmetric image with a rotation-90
`set_pixels`, then checks both the resulting buffer and the rendered LED
colours in 2D.
- FlightCase test: checks that `setpixels` saves the mapping in
`Sk.sense_hat.pixel_indexes`.

I haven't run these tests yet. Please run the suite before merging.

<!-- Macroscope (Fix It For Me) template starts here -->
> [!NOTE]
> ### Macroscope: _Fix It For Me_
> - This PR originated from [this
comment](https://github.com/RaspberryPiFoundation/editor-ui/pull/1719/files#r4484016063)
in #1719.
> - Since auto-merge is off, Macroscope will wait for checks to pass,
investigate / repair any failures, and then leave this PR for you to
merge when ready.
> - You can also @mention Macroscope in this PR to request further
changes.
>
> #### Activity
> Currently: <!-- Macroscope (Fix It For Me) current status starts here
-->Ready for review<!-- Macroscope (Fix It For Me) current status ends
here -->
>
> <details>
> <summary>Previously</summary>
>
> <!-- Macroscope (Fix It For Me) previous status starts here -->
> - Waiting on checks
> - Pushed fa47578
> - Action failed: CI-CD
> - Waiting on checks
> - Pushed 10ea54e
> <!-- Macroscope (Fix It For Me) previous status ends here -->
>
> </details>

----
<!-- Macroscope (Fix It For Me) template ends here -->
<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible
markers, and the markers themselves will not be visible in the GitHub
rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's
description, Macroscope will append its summary at the bottom of the
description. -->
<!-- Macroscope's pull request summary ends here -->

---------

Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
previews/1719/merge — 5615ec30 Deployed Nov 5, 2026 by G3zz via deploy-branch / build-deploy #7064
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.

1 participant