camera: add user option to rotate the camera image 180 degrees - #335
Open
cateim wants to merge 1 commit into
Open
camera: add user option to rotate the camera image 180 degrees#335cateim wants to merge 1 commit into
cateim wants to merge 1 commit into
Conversation
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.
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.
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
CAMERA_OV5640over I2C, so a runtime check oncamera_info->modelcannot tell the units apart. The difference is physical: the module hangs on an FPC cable and fits either way up.Camera Orientationmenu isvisible 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.fb->buf), not the rotated copy, so orientation never affects scanning.Changes
main/storage.hGUI_FLAGS_CAMERA_ROTATEDas a bit in the existingGUI_FLAGS_FIELDbyte, as requested in diy: fix upside down camera image on Waveshare Touch LCD 2 #331.main/button_events.hBTN_SETTINGS_DISPLAY_CAMERA_ROTATEevent id.main/ui/dashboard.cmain/process/dashboard.cmain/camera.ccopy_camera_image_0andcopy_camera_image_180are 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: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