commit deec6ffd34c1594087772fa31f7d805835e972a6
parent 67a8ebd039e191d14185bb10fb24222bd2b2a2ca
Author: Jean Schurger <jean@schurger.org>
Date: Fri, 13 Nov 2026 14:53:36 -0500
0.6: development mode (CSV log of measurements and events, raw values on screen)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYGSNhtY1AmBH7DQGNs
Diffstat:
9 files changed, 149 insertions(+), 8 deletions(-)
diff --git a/OpenMerou/App/AppModel.swift b/OpenMerou/App/AppModel.swift
@@ -20,7 +20,20 @@ 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 }
+ DevLog.shared.set(enabled: settings.developer)
+ engine.onState = { [weak self] state in
+ guard let self else { return }
+ if state.message != camera.message || state.shots != camera.shots, let message = state.message {
+ DevLog.shared.event("caméra : \(message)")
+ }
+ if state.zoomIndex != camera.zoomIndex, state.capabilities.zoomLabels.indices.contains(state.zoomIndex) {
+ DevLog.shared.event("objectif \(state.capabilities.zoomLabels[state.zoomIndex])")
+ }
+ if (state.recordingSince == nil) != (camera.recordingSince == nil) {
+ DevLog.shared.event(state.recordingSince == nil ? "vidéo : arrêt" : "vidéo : début")
+ }
+ camera = state
+ }
engine.start(settings)
housing.cameraButton = { [weak self] event in self?.button(event) }
sleepTask = Task { [weak self] in
@@ -65,6 +78,8 @@ final class AppModel {
}
if settings != before {
if settings.orientation != before.orientation { applyOrientation() }
+ DevLog.shared.set(enabled: settings.developer)
+ DevLog.shared.event("réglages : \(settings)")
settings.save()
engine.apply(settings)
}
@@ -72,7 +87,9 @@ final class AppModel {
}
guard !event.isLong else { return }
switch event.button {
- case .shutter: settings.mode == .photo ? engine.capturePhoto() : engine.toggleRecording()
+ case .shutter:
+ if settings.mode == .photo { DevLog.shared.event("photo demandée") }
+ settings.mode == .photo ? engine.capturePhoto() : engine.toggleRecording()
case .up: engine.cycleLens(1)
case .down: engine.cycleLens(-1)
case .right: if camera.recordingSince == nil { menu.open() }
diff --git a/OpenMerou/App/DevLog.swift b/OpenMerou/App/DevLog.swift
@@ -0,0 +1,75 @@
+// Mode développement : journal CSV des mesures et des événements, pour les essais dans l'eau.
+// Un fichier par session dans Documents/journaux (visible dans l'app Fichiers et partageable).
+import Foundation
+
+@MainActor
+final class DevLog {
+ static let shared = DevLog()
+ private(set) var enabled = false
+ private var handle: FileHandle?
+ private(set) var url: URL?
+ private var start = Date()
+ private let stamp = ISO8601DateFormatter()
+
+ static var directory: URL {
+ FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("journaux")
+ }
+
+ static var files: [URL] {
+ ((try? FileManager.default.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil)) ?? [])
+ .filter { $0.pathExtension == "csv" }.sorted { $0.lastPathComponent > $1.lastPathComponent }
+ }
+
+ func set(enabled: Bool) {
+ guard enabled != self.enabled else { return }
+ self.enabled = enabled
+ if enabled {
+ try? FileManager.default.createDirectory(at: Self.directory, withIntermediateDirectories: true)
+ let name = DateFormatter()
+ name.dateFormat = "yyyyMMdd-HHmmss"
+ let file = Self.directory.appendingPathComponent("merou-\(name.string(from: .now)).csv")
+ FileManager.default.createFile(atPath: file.path, contents: nil)
+ handle = try? FileHandle(forWritingTo: file)
+ url = file
+ start = .now
+ write("heure,secondes,type,pression_int_pa,pression_ext_brut_pa,temperature_c,batterie,pompe,v1628,etape,remontee_corrigee_pa,thermique_iphone,texte")
+ event("journal ouvert")
+ } else {
+ event("journal fermé")
+ try? handle?.close()
+ handle = nil
+ }
+ }
+
+ private func write(_ line: String) {
+ handle?.write(Data((line + "\n").utf8))
+ }
+
+ private func prefix(_ type: String) -> String {
+ "\(stamp.string(from: .now)),\(String(format: "%.2f", Date().timeIntervalSince(start))),\(type)"
+ }
+
+ func event(_ text: String) {
+ guard enabled else { return }
+ write(prefix("evenement") + ",,,,,,,,,,\"" + text.replacingOccurrences(of: "\"", with: "'") + "\"")
+ }
+
+ func sensors(_ r: HousingReadings, _ vacuum: VacuumSequence) {
+ guard enabled else { return }
+ func f(_ v: Double?, _ format: String = "%.0f") -> String { v.map { String(format: format, $0) } ?? "" }
+ let pump: String = switch r.pumpState {
+ case .running: "1"
+ case .stopped: "2"
+ case .other(let b): "\(b)"
+ case nil: ""
+ }
+ let rise: Double? = switch vacuum.step {
+ case .testing(let b), .sealed(let b): vacuum.correctedRise(since: b)
+ default: nil
+ }
+ let step = String(describing: vacuum.step).prefix { $0 != "(" }
+ let thermal = ProcessInfo.processInfo.thermalState.rawValue
+ write(prefix("mesure") + ",\(f(r.internalPressurePa)),\(f(r.externalPressurePa)),\(f(r.temperatureC, "%.2f")),"
+ + "\(r.batteryPercent.map(String.init) ?? ""),\(pump),\(r.alarmRaw.map(String.init) ?? ""),\(step),\(f(rise)),\(thermal),")
+ }
+}
diff --git a/OpenMerou/Camera/CameraSettings.swift b/OpenMerou/Camera/CameraSettings.swift
@@ -42,8 +42,10 @@ struct CameraSettings: Codable, Equatable, Sendable {
/// Secondes sans bouton avant la veille de l'écran ; 0 = jamais.
var sleepAfter = 120
var orientation = ScreenOrientation.landscape
+ /// Mode développement : journal CSV et affichages supplémentaires.
+ var developer = false
- static let key = "cameraSettings2"
+ static let key = "cameraSettings3"
static func load() -> CameraSettings {
guard let data = UserDefaults.standard.data(forKey: key),
let value = try? JSONDecoder().decode(CameraSettings.self, from: data) else { return CameraSettings() }
@@ -65,7 +67,7 @@ struct CameraCapabilities: Equatable, Sendable {
}
enum CameraSetting: Sendable, CaseIterable {
- case photoFormat, exposure, stabilization, videoQuality, sleep, orientation
+ case photoFormat, exposure, stabilization, videoQuality, sleep, orientation, developer
var title: String {
switch self {
@@ -75,12 +77,13 @@ enum CameraSetting: Sendable, CaseIterable {
case .videoQuality: "Qualité vidéo"
case .sleep: "Veille de l'écran"
case .orientation: "Orientation"
+ case .developer: "Développement"
}
}
}
enum SettingValue: Equatable, Sendable {
- case photoFormat(PhotoFormat), exposure(Double), stabilization(Stabilization), videoQuality(VideoQuality), sleep(Int), orientation(ScreenOrientation)
+ case photoFormat(PhotoFormat), exposure(Double), stabilization(Stabilization), videoQuality(VideoQuality), sleep(Int), orientation(ScreenOrientation), developer(Bool)
var label: String {
switch self {
@@ -97,6 +100,7 @@ enum SettingValue: Equatable, Sendable {
case .orientation(.landscape): "Paysage"
case .orientation(.landscapeFlipped): "Paysage inversé"
case .orientation(.portrait): "Portrait"
+ case .developer(let on): on ? "Activé" : "Désactivé"
}
}
}
@@ -113,6 +117,7 @@ extension CameraSettings {
case .videoQuality: caps.qualities.map { .videoQuality($0) }
case .sleep: Self.sleepSteps.map { .sleep($0) }
case .orientation: ScreenOrientation.allCases.map { .orientation($0) }
+ case .developer: [.developer(false), .developer(true)]
}
}
@@ -124,6 +129,7 @@ extension CameraSettings {
case .videoQuality: .videoQuality(videoQuality)
case .sleep: .sleep(sleepAfter)
case .orientation: .orientation(orientation)
+ case .developer: .developer(developer)
}
}
@@ -135,6 +141,7 @@ extension CameraSettings {
case .videoQuality(let v): videoQuality = v
case .sleep(let v): sleepAfter = v
case .orientation(let v): orientation = v
+ case .developer(let v): developer = v
}
}
}
diff --git a/OpenMerou/Housing/HousingClient.swift b/OpenMerou/Housing/HousingClient.swift
@@ -120,6 +120,7 @@ final class HousingClient: NSObject {
private func note(_ text: String) {
log.insert(LogLine(date: .now, text: text), at: 0)
+ DevLog.shared.event(text)
if log.count > 200 { log.removeLast(log.count - 200) }
}
@@ -251,6 +252,7 @@ extension HousingClient: CBPeripheralDelegate {
if uuid == HousingUUID.internalPressure || uuid == HousingUUID.temperature {
run(vacuum.sensors(pressurePa: readings.internalPressurePa, temperatureC: readings.temperatureC, now: .now))
}
+ if uuid == HousingUUID.internalPressure { DevLog.shared.sensors(readings, vacuum) }
if vacuum.step != before { note("Séquence : \(vacuum.step)") }
if uuid == HousingUUID.internalPressure, pumpRequested,
let p = readings.internalPressurePa, p < Self.vacuumTargetPa {
diff --git a/OpenMerou/Info.plist b/OpenMerou/Info.plist
@@ -22,6 +22,10 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
+ <key>LSSupportsOpeningDocumentsInPlace</key>
+ <true/>
+ <key>UIFileSharingEnabled</key>
+ <true/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
diff --git a/OpenMerou/UI/CameraScreen.swift b/OpenMerou/UI/CameraScreen.swift
@@ -39,6 +39,7 @@ struct CameraScreen: View {
VStack {
topBar
+ if model.settings.developer { devOverlay }
Spacer()
if let message = model.camera.message, !model.menu.isOpen {
Text(message).font(.footnote).padding(8).background(.black.opacity(0.5), in: Capsule())
@@ -108,6 +109,32 @@ struct CameraScreen: View {
.shadow(radius: 3)
}
+ /// Mode développement : valeurs brutes, pour les essais dans l'eau.
+ private var devOverlay: some View {
+ let r = housing.readings, v = housing.vacuum
+ let rise: Double? = switch v.step {
+ case .testing(let b), .sealed(let b): v.correctedRise(since: b)
+ default: nil
+ }
+ func n(_ value: Double?, _ format: String) -> String { value.map { String(format: format, $0) } ?? "—" }
+ let lines = [
+ "P int \(n(r.internalPressurePa, "%.0f")) Pa remontée \(n(rise, "%+.0f")) Pa",
+ "P ext? \(n(r.externalPressurePa, "%.0f")) Pa T \(n(r.temperatureC, "%.2f")) °C",
+ "pompe \(r.pumpState.map { "\($0)" } ?? "—") 1628 \(r.alarmRaw.map { String(format: "%02X", $0) } ?? "—") batt \(r.batteryPercent.map(String.init) ?? "—") %",
+ "étape \(String(describing: v.step).prefix { $0 != "(" }) iPhone thermique \(ProcessInfo.processInfo.thermalState.rawValue)",
+ "journal \(DevLog.shared.url?.lastPathComponent ?? "—")",
+ ]
+ return HStack {
+ VStack(alignment: .leading, spacing: 2) {
+ ForEach(lines, id: \.self) { Text($0) }
+ }
+ .font(.system(size: 11, design: .monospaced))
+ .padding(6)
+ .background(.black.opacity(0.55), in: RoundedRectangle(cornerRadius: 8))
+ Spacer()
+ }
+ }
+
private var sealChip: some View {
let (text, color): (String, Color) = switch housing.vacuum.step {
case .sealed: ("Étanche", .green)
diff --git a/OpenMerou/UI/HousingView.swift b/OpenMerou/UI/HousingView.swift
@@ -56,6 +56,15 @@ struct HousingView: View {
}
}
+ let files = DevLog.files
+ if !files.isEmpty {
+ Section("Journaux du mode développement") {
+ ForEach(files, id: \.self) { file in
+ ShareLink(item: file) { Text(file.lastPathComponent).font(.footnote) }
+ }
+ }
+ }
+
Section("Journal") {
ForEach(housing.log) { line in
HStack(alignment: .firstTextBaseline) {
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.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."],
+ "0.6 : mode développement (Menu → Réglages → Développement) : valeurs brutes à l'écran et journal CSV des mesures et des événements, à récupérer par le bouton ⓘ ou dans l'app Fichiers. À faire dans l'eau : activer le mode, plonger le boîtier, noter la profondeur réelle."],
"en-CA" => ["Free, open-source app for compatible dive housings: buttons, vacuum pump, sensors, camera.",
- "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."],
+ "0.6: developer mode (Menu → Settings → Development): raw values on screen and a CSV log of measurements and events, shared from the ⓘ button or the Files app. In water: turn it on, submerge the housing, note the real depth."],
}
_, 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.5"
+ MARKETING_VERSION: "0.6"
CURRENT_PROJECT_VERSION: "1"
SWIFT_VERSION: "6.0"
targets: