Rearcam 2.0. Refactor rear camera settings and add module documentation - #44
Open
PabloMartin97 wants to merge 12 commits into
Open
Rearcam 2.0. Refactor rear camera settings and add module documentation#44PabloMartin97 wants to merge 12 commits into
PabloMartin97 wants to merge 12 commits into
Conversation
PabloMartin97
commented
Aug 23, 2026
Contributor
- Refactor rear camera settings and replace legacy migration with a clean versioned schema.
- Add comprehensive CarPlay and rear camera module documentation.
Backend: add recursive _merge_missing to migrate new defaults without overwriting user values and log added keys. Frontend (Rearcam): verify saved deviceId is currently available before applying exact constraint to avoid failures when hardware changes. Frontend (Settings): separate debounce/save refs for app vs CAN settings, persist pending saves on unmount, disambiguate duplicate camera labels, and show saved-but-missing camera option. Socket namespaces: map frontend `cam` to backend `/rearcam`. package-lock.json updated (auto-generated).
Thread-safety and socket cleanup: switch CameraGPIO lock to threading.RLock to allow reentrant access and avoid deadlocks; expose CameraGPIO via server import. Minor fix to APPThread Chrome args punctuation. Frontend: remove direct socket.io usage from Content.tsx and centralize reverse-state handling in frontend/src/socket/Socket.tsx — add 'reverse' listener, emit 'systemTask' for reverse, and clean up handlers. These changes consolidate reverse camera logic and improve GPIO thread-safety.
Update the reverse camera toggle label to clarify it only controls navigation visibility and migrate existing user settings to the new wording while preserving the saved value. Also harden the Rearcam camera-open flow against stale async requests so outdated streams are stopped when settings change or the component unmounts.
Enhance Rearcam video startup and diagnostics: - Add a 10s VIDEO_START_TIMEOUT_MS. - Implement getCameraErrorMessage for clearer messages. Handle play failures as PlaybackError, attach an 'ended' listener to video tracks to detect disconnects, stop streams on failure, and surface detailed error/denied messages to the UI. These changes improve robustness and user feedback when opening/playing the camera stream.
Backend: remove the conditional lgpio import, LGPIO_AVAILABLE flag and _require_lgpio guard; simplify CameraGPIO to directly open/claim/write/close gpiochip and let lgpio calls raise on error. Frontend: remove openingRef and its bookkeeping; start video.play() and waitForVideoData concurrently for cleaner playback startup and simplify error/finally handling; devicechange handler now retries unless permission is denied.
This removes the label-based reverse camera selection flow and the related config field from backend settings. The rear camera logic now only supports auto and deviceId selection, matching the current device selection behavior. It also adds a standalone V-Link preview entry point for local UI previews using the app config and theme setup.
Redesign rear camera settings to use preset video resolutions and standards instead of arbitrary width/height/FPS values. Add three guideline modes (Standard static PNG and Custom configurable SVG).
…ovement. Rear-camera settings now use a clean, versioned schema. Legacy rear-camera settings are reset once during upgrade to remove obsolete fields. Other application settings remain unchanged, and standard parking guidelines are enabled by default.
Add three documentation files: - carplay.md: comprehensive CarPlay module docs. - rearcam.md: full Rear Camera module docs. - Local Frontend Preview.md: how to run a frontend-only preview with Vite and its limitations.
Introduce a one-time migration notice for rear-camera settings. Also logs incompatible rearcam old configuration. Frontend Rearcam shows a red warning banner on first visit if the migration is not supported. Documentation updated to describe behavior. Unit tests updated to assert the flag is set/cleared during migration scenarios.
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.