Skip to content

Rearcam 2.0. Refactor rear camera settings and add module documentation - #44

Open
PabloMartin97 wants to merge 12 commits into
BoostedMoose:devfrom
PabloMartin97:rearcam-2.0
Open

Rearcam 2.0. Refactor rear camera settings and add module documentation#44
PabloMartin97 wants to merge 12 commits into
BoostedMoose:devfrom
PabloMartin97:rearcam-2.0

Conversation

@PabloMartin97

Copy link
Copy Markdown
Contributor
  1. Refactor rear camera settings and replace legacy migration with a clean versioned schema.
  2. Add comprehensive CarPlay and rear camera module documentation.

PabloMartin97 and others added 12 commits August 15, 2026 23:57
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.
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.

2 participants