[F] Implement shake correctly

This commit is contained in:
Hykilpikonna
2021-01-27 18:27:31 -05:00
parent b0c5a2f458
commit 2313b3cded
3 changed files with 11 additions and 32 deletions
-4
View File
@@ -22,7 +22,6 @@
7C12BC7825BE25C000E5659C /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C12BC7725BE25C000E5659C /* Notification.swift */; };
7C5DAE9C25AF812200E44C52 /* clock.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C5DAE9B25AF812200E44C52 /* clock.png */; };
7C60741E25C11DC000B0A154 /* AlarmLogo1.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C60741D25C11DC000B0A154 /* AlarmLogo1.png */; };
7C83963625AF375B0027A94C /* AlarmActivationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* AlarmActivationLogic.swift */; };
7C83963925AF68980027A94C /* DebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* DebugViewController.swift */; };
7CD385A625BE4649007E9890 /* notif.caf in Resources */ = {isa = PBXBuildFile; fileRef = 7CD385A525BE4649007E9890 /* notif.caf */; };
C7E638E825B88F8B00799512 /* MathExpressions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7E638E725B88F8B00799512 /* MathExpressions.swift */; };
@@ -49,7 +48,6 @@
7C60741D25C11DC000B0A154 /* AlarmLogo1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = AlarmLogo1.png; sourceTree = "<group>"; };
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = "<group>"; };
7C83962F25AF34F10027A94C /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
7C83963525AF375B0027A94C /* AlarmActivationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmActivationLogic.swift; sourceTree = "<group>"; };
7C83963825AF68980027A94C /* DebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugViewController.swift; sourceTree = "<group>"; };
7CD385A525BE4649007E9890 /* notif.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = notif.caf; sourceTree = "<group>"; };
C7E638E725B88F8B00799512 /* MathExpressions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MathExpressions.swift; sourceTree = "<group>"; };
@@ -92,7 +90,6 @@
4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */,
4FD642DF25B4D5F30069171E /* AlarmActivationViewController.swift */,
4FD642D225B48C380069171E /* AlarmActivator.swift */,
7C83963525AF375B0027A94C /* AlarmActivationLogic.swift */,
4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */,
4FF0683E25A5F18700304E6B /* AppDelegate.swift */,
4FF0684725A5F18800304E6B /* Assets.xcassets */,
@@ -217,7 +214,6 @@
4F509BD225AE22D100726227 /* Models.swift in Sources */,
7C12BC7825BE25C000E5659C /* Notification.swift in Sources */,
C7E638E825B88F8B00799512 /* MathExpressions.swift in Sources */,
7C83963625AF375B0027A94C /* AlarmActivationLogic.swift in Sources */,
4FD642E025B4D5F30069171E /* AlarmActivationViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
-28
View File
@@ -1,28 +0,0 @@
//
// NotificationLogic.swift
// ProjectClock
//
// Created by Aaron Saporito on 1/13/21.
//
import Foundation
import CoreMotion
import UserNotifications
import UIKit
var motionManager = CMMotionManager()
var regulate = true
func shakeAction() {
regulate = true
motionManager.accelerometerUpdateInterval = 0.2
motionManager.startAccelerometerUpdates(to: OperationQueue.current!) { data, error in
if data!.acceleration.x > 5 {
print("DO SOMETHING SPECIAL")
regulate = false
}
}
}
@@ -7,6 +7,9 @@
import UIKit
import AVFoundation
import CoreMotion
var motion = CMMotionManager()
/**
View controlling alarm activation and dismissal
@@ -94,6 +97,14 @@ class AlarmActivationViewController: UIViewController
rpsView.show()
case "Shake":
shakeView.show()
motion.accelerometerUpdateInterval = 0.2
motion.startAccelerometerUpdates(to: OperationQueue.current!) { data, error in
if data!.acceleration.x > 5
{
ui { self.endAlarm() }
}
}
default:
print("Invalid alarm type")
}