open-merou

Open Mérou, a free iOS app for the Oceanic+ underwater iPhone housing
git clone https://git.schurger.org/open-merou.git
Log | Files | Refs | README | LICENSE

commit 67a8ebd039e191d14185bb10fb24222bd2b2a2ca
parent fea430125a3f8b6e901ab9c22c5235395c1c114c
Author: Jean Schurger <jean@schurger.org>
Date:   Fri, 13 Nov 2026 14:47:10 -0500

0.5: screen and captures in a fixed orientation (landscape by default, adjustable)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYGSNhtY1AmBH7DQGNs

Diffstat:
MOpenMerou/App/AppModel.swift | 23+++++++++++++++++++++++
MOpenMerou/App/OpenMerouApp.swift | 1+
MOpenMerou/Camera/CameraEngine.swift | 28+++++++++++-----------------
MOpenMerou/Camera/CameraSettings.swift | 28+++++++++++++++++++++++++---
Mfastlane/Fastfile | 4++--
Mproject.yml | 2+-
6 files changed, 63 insertions(+), 23 deletions(-)

diff --git a/OpenMerou/App/AppModel.swift b/OpenMerou/App/AppModel.swift @@ -19,6 +19,7 @@ final class AppModel { func start() { UIApplication.shared.isIdleTimerDisabled = true // l'écran ne se verrouille jamais tout seul + applyOrientation() engine.onState = { [weak self] state in self?.camera = state } engine.start(settings) housing.cameraButton = { [weak self] event in self?.button(event) } @@ -63,6 +64,7 @@ final class AppModel { case .none, .close, .changed: break } if settings != before { + if settings.orientation != before.orientation { applyOrientation() } settings.save() engine.apply(settings) } @@ -78,8 +80,29 @@ final class AppModel { } } + private func applyOrientation() { + let mask: UIInterfaceOrientationMask = switch settings.orientation { + case .landscape: .landscapeRight + case .landscapeFlipped: .landscapeLeft + case .portrait: .portrait + } + AppDelegate.orientations = mask + for case let scene as UIWindowScene in UIApplication.shared.connectedScenes { + scene.requestGeometryUpdate(.iOS(interfaceOrientations: mask)) + scene.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations() + } + } + func background() { engine.stopForBackground() if sleeping { wake() } } } + +final class AppDelegate: NSObject, UIApplicationDelegate { + @MainActor static var orientations: UIInterfaceOrientationMask = .landscapeRight + + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + Self.orientations + } +} diff --git a/OpenMerou/App/OpenMerouApp.swift b/OpenMerou/App/OpenMerouApp.swift @@ -2,6 +2,7 @@ import SwiftUI @main struct OpenMerouApp: App { + @UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate @State private var model = AppModel() var body: some Scene { diff --git a/OpenMerou/Camera/CameraEngine.swift b/OpenMerou/Camera/CameraEngine.swift @@ -29,8 +29,6 @@ final class CameraEngine: NSObject, @unchecked Sendable { private var settings = CameraSettings() private var state = CameraState() private var photoDelegates: [Int64: PhotoDelegate] = [:] - private var rotation: AVCaptureDevice.RotationCoordinator? - private var rotationObservation: NSKeyValueObservation? override init() { previewLayer = AVCaptureVideoPreviewLayer(session: session) @@ -99,13 +97,6 @@ final class CameraEngine: NSObject, @unchecked Sendable { state.capabilities.minBias = Double(device.minExposureTargetBias) state.capabilities.maxBias = Double(device.maxExposureTargetBias) - let coordinator = AVCaptureDevice.RotationCoordinator(device: device, previewLayer: previewLayer) - rotation = coordinator - let layer = previewLayer - rotationObservation = coordinator.observe(\.videoRotationAngleForHorizonLevelPreview, options: [.initial, .new]) { coordinator, _ in - let angle = coordinator.videoRotationAngleForHorizonLevelPreview - DispatchQueue.main.async { layer.connection?.videoRotationAngle = angle } - } applyMode() } @@ -166,9 +157,18 @@ final class CameraEngine: NSObject, @unchecked Sendable { applyLight() } + private func rotate(_ connection: AVCaptureConnection?) { + let angle = settings.orientation.videoAngle + if let connection, connection.isVideoRotationAngleSupported(angle) { connection.videoRotationAngle = angle } + } + /// Réglages qui ne demandent pas de reconfigurer la session. private func applyLight() { guard let device else { return } + let layer = previewLayer, angle = settings.orientation.videoAngle + DispatchQueue.main.async { + if let connection = layer.connection, connection.isVideoRotationAngleSupported(angle) { connection.videoRotationAngle = angle } + } if (try? device.lockForConfiguration()) != nil { let bias = Float(settings.exposureBias) device.setExposureTargetBias(min(max(bias, device.minExposureTargetBias), device.maxExposureTargetBias)) @@ -219,10 +219,7 @@ final class CameraEngine: NSObject, @unchecked Sendable { ?? AVCapturePhotoSettings(format: heif) photoSettings.maxPhotoDimensions = photoOutput.maxPhotoDimensions photoSettings.photoQualityPrioritization = .quality - if let angle = rotation?.videoRotationAngleForHorizonLevelCapture, - let connection = photoOutput.connection(with: .video), connection.isVideoRotationAngleSupported(angle) { - connection.videoRotationAngle = angle - } + rotate(photoOutput.connection(with: .video)) let delegate = PhotoDelegate { [weak self] id, result in self?.queue.async { self?.photoDelegates[id] = nil @@ -244,10 +241,7 @@ final class CameraEngine: NSObject, @unchecked Sendable { movieOutput.stopRecording() return } - if let angle = rotation?.videoRotationAngleForHorizonLevelCapture, - let connection = movieOutput.connection(with: .video), connection.isVideoRotationAngleSupported(angle) { - connection.videoRotationAngle = angle - } + rotate(movieOutput.connection(with: .video)) if let connection = movieOutput.connection(with: .video), movieOutput.availableVideoCodecTypes.contains(.hevc) { movieOutput.setOutputSettings([AVVideoCodecKey: AVVideoCodecType.hevc], for: connection) } diff --git a/OpenMerou/Camera/CameraSettings.swift b/OpenMerou/Camera/CameraSettings.swift @@ -3,6 +3,20 @@ import Foundation enum CaptureMode: String, Codable, Sendable { case photo, video } enum PhotoFormat: String, Codable, Sendable, CaseIterable { case heif, rawHeif } +/// Orientation fixe : sous l'eau, l'iPhone pointe souvent vers le bas et ne peut pas se fier à la gravité. +enum ScreenOrientation: String, Codable, Sendable, CaseIterable { + case landscape, landscapeFlipped, portrait + + /// Angle de rotation de l'image pour l'appareil photo arrière. + var videoAngle: Double { + switch self { + case .landscape: 0 + case .landscapeFlipped: 180 + case .portrait: 90 + } + } +} + enum Stabilization: String, Codable, Sendable, CaseIterable { case off, standard, cinematic, extended } struct VideoQuality: Codable, Equatable, Hashable, Sendable { @@ -27,8 +41,9 @@ struct CameraSettings: Codable, Equatable, Sendable { var videoQuality = VideoQuality(height: 2160, fps: 30) /// Secondes sans bouton avant la veille de l'écran ; 0 = jamais. var sleepAfter = 120 + var orientation = ScreenOrientation.landscape - static let key = "cameraSettings" + static let key = "cameraSettings2" static func load() -> CameraSettings { guard let data = UserDefaults.standard.data(forKey: key), let value = try? JSONDecoder().decode(CameraSettings.self, from: data) else { return CameraSettings() } @@ -50,7 +65,7 @@ struct CameraCapabilities: Equatable, Sendable { } enum CameraSetting: Sendable, CaseIterable { - case photoFormat, exposure, stabilization, videoQuality, sleep + case photoFormat, exposure, stabilization, videoQuality, sleep, orientation var title: String { switch self { @@ -59,12 +74,13 @@ enum CameraSetting: Sendable, CaseIterable { case .stabilization: "Stabilisation vidéo" case .videoQuality: "Qualité vidéo" case .sleep: "Veille de l'écran" + case .orientation: "Orientation" } } } enum SettingValue: Equatable, Sendable { - case photoFormat(PhotoFormat), exposure(Double), stabilization(Stabilization), videoQuality(VideoQuality), sleep(Int) + case photoFormat(PhotoFormat), exposure(Double), stabilization(Stabilization), videoQuality(VideoQuality), sleep(Int), orientation(ScreenOrientation) var label: String { switch self { @@ -78,6 +94,9 @@ enum SettingValue: Equatable, Sendable { case .videoQuality(let q): q.label case .sleep(0): "Jamais" case .sleep(let s): s < 60 ? "\(s) s" : "\(s / 60) min" + case .orientation(.landscape): "Paysage" + case .orientation(.landscapeFlipped): "Paysage inversé" + case .orientation(.portrait): "Portrait" } } } @@ -93,6 +112,7 @@ extension CameraSettings { case .stabilization: caps.stabilizations.map { .stabilization($0) } case .videoQuality: caps.qualities.map { .videoQuality($0) } case .sleep: Self.sleepSteps.map { .sleep($0) } + case .orientation: ScreenOrientation.allCases.map { .orientation($0) } } } @@ -103,6 +123,7 @@ extension CameraSettings { case .stabilization: .stabilization(stabilization) case .videoQuality: .videoQuality(videoQuality) case .sleep: .sleep(sleepAfter) + case .orientation: .orientation(orientation) } } @@ -113,6 +134,7 @@ extension CameraSettings { case .stabilization(let v): stabilization = v case .videoQuality(let v): videoQuality = v case .sleep(let v): sleepAfter = v + case .orientation(let v): orientation = v } } } diff --git a/fastlane/Fastfile b/fastlane/Fastfile @@ -122,9 +122,9 @@ platform :ios do end texts = { "fr-CA" => ["App libre et gratuite pour boîtier de plongée compatible : boutons, pompe à vide, capteurs, caméra.", - "0.4 : caméra. Déclencheur = photo ou vidéo, haut et bas = objectif, droite = menu (Photo, Vidéo, Veille, Réglages), gauche = retour. Réglages : format (ProRAW), exposition, stabilisation, qualité vidéo, veille. Bouton « Essai à sec » à l'écran pour essayer sans mise sous vide. À vérifier : les objectifs proposés, la résolution des photos, chaque qualité vidéo, la veille."], + "0.5 : caméra, écran fixe en paysage (Réglages → Orientation : paysage, paysage inversé, portrait). Déclencheur = photo ou vidéo, haut et bas = objectif, droite = menu (Photo, Vidéo, Veille, Réglages), gauche = retour. Réglages : format (ProRAW), exposition, stabilisation, qualité vidéo, veille. Bouton « Essai à sec » à l'écran pour essayer sans mise sous vide. À vérifier : les objectifs proposés, la résolution des photos, chaque qualité vidéo, la veille."], "en-CA" => ["Free, open-source app for compatible dive housings: buttons, vacuum pump, sensors, camera.", - "0.4: camera. Shutter = photo or video, up and down = lens, right = menu (Photo, Video, Sleep, Settings), left = back. Settings: format (ProRAW), exposure, stabilization, video quality, sleep. On-screen Dry run button to try without the vacuum sequence. Please check the lenses offered, photo resolution, each video quality, and sleep."], + "0.5: camera, screen locked to landscape (Settings → Orientation: landscape, flipped landscape, portrait). Shutter = photo or video, up and down = lens, right = menu (Photo, Video, Sleep, Settings), left = back. Settings: format (ProRAW), exposure, stabilization, video quality, sleep. On-screen Dry run button to try without the vacuum sequence. Please check the lenses offered, photo resolution, each video quality, and sleep."], } _, locs = asc(:get, "/v1/apps/#{app.id}/betaAppLocalizations") texts.each do |locale, (description, _)| diff --git a/project.yml b/project.yml @@ -9,7 +9,7 @@ settings: base: DEVELOPMENT_TEAM: CM5RQKJH56 CODE_SIGN_STYLE: Automatic - MARKETING_VERSION: "0.4" + MARKETING_VERSION: "0.5" CURRENT_PROJECT_VERSION: "1" SWIFT_VERSION: "6.0" targets: