Skip to content

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

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

camera: add user option to rotate the camera image 180 degrees#335
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.
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