Skip to content

camera: add user option to rotate the camera image 180 degrees - #335

Closed
cateim wants to merge 1 commit into
Blockstream:masterfrom
cateim:camera-rotate-toggle
Closed

cateim wants to merge 1 commit into
Blockstream:masterfrom
cateim:camera-rotate-toggle

Conversation

@cateim

@cateim cateim commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a persisted user setting to rotate the camera preview image 180 degrees, for boards whose camera module can be physically mounted either way up. This supersedes #331, which flipped the build-time default for the Waveshare S3 Touch LCD 2.

Root Cause / Context

  • Two Waveshare S3 Touch LCD 2 units with the same OV5640 module produce opposite preview orientations (see diy: fix upside down camera image on Waveshare Touch LCD 2 #331), so no build-time default suits both.
  • Both modules identify as CAMERA_OV5640 over I2C, so a runtime check on camera_info->model cannot tell the units apart. The difference is physical: the module hangs on an FPC cable and fits either way up.
  • The Camera Orientation menu is visible if HAS_CAMERA && BOARD_TYPE_CUSTOM, so on a named board the symbol has no visible prompt and always falls back to its default. Whichever default wins, the other half of the builders cannot correct it.
  • Preview only: the QR decoder consumes the raw sensor framebuffer (fb->buf), not the rotated copy, so orientation never affects scanning.

Changes

main/storage.h

main/button_events.h

  • Action: add the BTN_SETTINGS_DISPLAY_CAMERA_ROTATE event id.

main/ui/dashboard.c

  • Action: add a 'Rotate Camera' entry to the Display settings menu, on camera boards other than the official Jade units.
  • Note: the label doubles as the state indicator, reading 'Camera Rotated' while the rotation is active. The menu keeps the same number of items.

main/process/dashboard.c

  • Action: toggle the flag and remake the menu screen, following the existing Theme handler pattern.

main/camera.c

  • Action: pick between the two already-compiled copy functions at runtime, composing with any flipped display orientation.
  • Note: no new copy function and no extra flash cost, copy_camera_image_0 and copy_camera_image_180 are both already built in this configuration and the copy function was already a runtime pointer.

Testing

Waveshare S3 Touch LCD 2 with an OV5640 module, firmware 1.0.41-67:

  • Default state is unchanged from before this PR.
  • Toggling rotates the camera preview 180 degrees and the menu label becomes 'Camera Rotated'.
  • The setting survives a full power cycle.
  • Toggling back restores both the preview and the original label.
  • Composes correctly with Flip Orientation.

Official Jade units are excluded from the menu entry, and boards without a camera never compile it.

Motivation

Lets each builder correct the camera orientation once from the device menu, with the choice surviving reboots and firmware updates, instead of flipping a build default that regresses the other half of the units.

cc @bota87

Some DIY boards take a detachable camera module which can end up
physically mounted either way up. Two Waveshare S3 Touch LCD 2 units
with the same OV5640 module have been seen producing opposite image
orientations, so no build-time default suits both and the sensor model
cannot be used to tell them apart at runtime (see discussion in PR 331).

Add a 'Rotate Camera' entry to the display settings menu on camera
boards other than the official Jade units. The setting is persisted as
a bit in the existing gui flags storage field and picks between the two
already-compiled copy functions at runtime in the camera task, composing
with any flipped display orientation. While the rotation is active the
menu label reads 'Camera Rotated', doubling as the state indicator.
@jgriffiths

Copy link
Copy Markdown
Collaborator

Merged to master, thanks!

@jgriffiths jgriffiths closed this Sep 4, 2026
@bota87

bota87 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Tested on my Waveshare S3 Touch LCD 2-C with the OV5640. Default preview is upside down, "Rotate Camera" fixes it and it stays after a reboot. QR scan works too. Thanks @cateim!

@cateim
cateim deleted the camera-rotate-toggle branch September 13, 2026 12:39
cateim added a commit to self-labs/.github that referenced this pull request Oct 2, 2026
Brings the profile from 2026-08-24 up to date: twenty pull requests accepted
across nine repositories owned by eight people, the two merged into
arendst/Tasmota, and a new "Open, and meant to be used" section for Tasmota IR,
Tasmota for KinCony, Custom Branding, cups, ai-usagebar-win and DIY.

Atlas Logistics leaves the production table: it is parked, and the profile
itself promises that what is parked says it is parked. Radar de Promo and the
PMES rosters enter it, and ALFERES gets its real numbers.

The upstream badge reads 20 only after self-labs/self-labs counts
Blockstream/Jade#335 and its stats job runs again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cateim added a commit to self-labs/self-labs that referenced this pull request Oct 3, 2026
Blockstream applied the camera rotation change on their internal branch and
closed the pull request without merging, as they did with the other four, and
commit 9c097297 is in their master. Without an entry in ACEITOS_SEM_MERGE the
search for is:merged never finds it, so the proof bar and the profile badges
read 19 instead of 20.

The comment above the list now says to confirm the commit landed before adding
a PR there, since closed without merge is also what a rejected PR looks like.
stats.json regenerated with an authenticated run: 20 PRs, 1785 commits, 37
repositories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants