From ce76d6382af322d1d44361f1f17cd959b7e12c17 Mon Sep 17 00:00:00 2001 From: miklosimate <megykereku@gmail.com> Date: Wed, 27 Mar 2024 15:22:16 +0100 Subject: [PATCH] please go up to the repo --- SenzorDataCollectorApp.xcodeproj/project.pbxproj | 2 ++ SenzorDataCollectorApp/Info.plist | 2 ++ SenzorDataCollectorApp/Sensors.swift | 10 +--------- SenzorDataCollectorApp/StartingView.swift | 13 +++++++------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/SenzorDataCollectorApp.xcodeproj/project.pbxproj b/SenzorDataCollectorApp.xcodeproj/project.pbxproj index 3d9f514..19fcfcb 100644 --- a/SenzorDataCollectorApp.xcodeproj/project.pbxproj +++ b/SenzorDataCollectorApp.xcodeproj/project.pbxproj @@ -489,6 +489,7 @@ INFOPLIST_KEY_NSFileProviderPresenceUsageDescription = "The app needs it to save files"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "The needs ot use senzor data"; + INFOPLIST_KEY_NSMotionUsageDescription = "THe app need is"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -526,6 +527,7 @@ INFOPLIST_KEY_NSFileProviderPresenceUsageDescription = "The app needs it to save files"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "The needs ot use senzor data"; + INFOPLIST_KEY_NSMotionUsageDescription = "THe app need is"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/SenzorDataCollectorApp/Info.plist b/SenzorDataCollectorApp/Info.plist index fd40622..dd703ee 100644 --- a/SenzorDataCollectorApp/Info.plist +++ b/SenzorDataCollectorApp/Info.plist @@ -2,6 +2,8 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> + <key>NSMotionUsageDescription</key> + <string>App mesasures sensors</string> <key>BGTaskSchedulerPermittedIdentifiers</key> <array> <string>hu.itk.ppke.backgroundTask</string> diff --git a/SenzorDataCollectorApp/Sensors.swift b/SenzorDataCollectorApp/Sensors.swift index 03eafa3..5cf4ec7 100644 --- a/SenzorDataCollectorApp/Sensors.swift +++ b/SenzorDataCollectorApp/Sensors.swift @@ -74,20 +74,15 @@ class SensorCollector: ObservableObject { gyroStartRecording(motionManager: motionManager) magStartRecording(motionManager: motionManager) altStartRecording(altimeter: altimeter) - } func stopAllRecording(motionManager: CMMotionManager, altimeter: CMAltimeter){ - print("Sensors stopped all recording") motionManager.stopAccelerometerUpdates() motionManager.stopGyroUpdates() motionManager.stopMagnetometerUpdates() altimeter.stopRelativeAltitudeUpdates() - - - //many missing :/ - + print("Sensors stopped all recording") for index in 0..<activeSensorsList.count { activeSensorsList[index].isSensorActive = false } @@ -130,9 +125,6 @@ class SensorCollector: ObservableObject { func accStartRecording(motionManager: CMMotionManager){ //if there is an acc.meter available: if(motionManager.isAccelerometerAvailable){ - - //changing the status of the sensor active in the list of sensors - //set accelerometer update frequency - to the maximum that the device is capable motionManager.accelerometerUpdateInterval = motionManager.deviceMotionUpdateInterval //start accelerometer update: diff --git a/SenzorDataCollectorApp/StartingView.swift b/SenzorDataCollectorApp/StartingView.swift index f8783c8..6b0ab95 100644 --- a/SenzorDataCollectorApp/StartingView.swift +++ b/SenzorDataCollectorApp/StartingView.swift @@ -72,8 +72,9 @@ struct StartingView: View { }.padding().disabled(manager.state != "Ready").opacity(debug ? 0 : 1) Button("STOP Iterations") { - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) + }.padding().opacity(debug ? 0 : 1) Text("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= 0 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised")") @@ -230,11 +231,11 @@ struct StartingView: View { // } // } //----------------------------- NOTIFICAION HANDELING --------------------------------- - .alert("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= 0 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised") Measurement", isPresented: $customTimer.isFinished) { + .alert("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= -1 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised") Measurement", isPresented: $customTimer.isFinished) { Button(manager.timerIntervalValues.count == 0 ? "End" : "Next" ,role: .cancel){ - - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) saveAllToJson() setNextMeasurement() @@ -244,16 +245,16 @@ struct StartingView: View { } } Button("Stop", role: .destructive){ - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) saveAllToJson() } } //------------------ DEMO NOTIFICATION - MEASUREMENT STARTING ---------------------- .alert("Demo Alert - press start if you are ready to start!", isPresented: $demostart){ Button("Start",role: .cancel){ - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) setNextMeasurement() if customTimer.totalSeconds != 0 { sensor.startAllRecording(motionManager: motionManager, altimeter: altimeter) -- GitLab