Working on shaking

This commit is contained in:
Dallon Archibald
2021-01-26 15:28:01 -05:00
parent 2b9e54f485
commit 40e2ba1f7b
3 changed files with 21 additions and 2 deletions
@@ -92,6 +92,9 @@ class AlarmActivationViewController: UIViewController
case "Shake": case "Shake":
shakeView.isHidden = false shakeView.isHidden = false
shakeAction() shakeAction()
if regulate {
endAlarm()
}
default: default:
print("Invalid alarm type") print("Invalid alarm type")
} }
+2 -2
View File
@@ -198,7 +198,7 @@ class RPS {
*/ */
} }
/**
//Reference: https://youtu.be/XDuchXYiWuE //Reference: https://youtu.be/XDuchXYiWuE
class Shake { class Shake {
var motionManager = CMMotionManager() var motionManager = CMMotionManager()
@@ -215,4 +215,4 @@ class Shake {
} }
} }
} }
*/
+16
View File
@@ -10,6 +10,9 @@ import CoreMotion
import UserNotifications import UserNotifications
import UIKit import UIKit
var motionManager = CMMotionManager()
var regulate = true
func walkAction() { func walkAction() {
} }
@@ -19,7 +22,20 @@ func jumpAction() {
} }
func shakeAction() { func shakeAction() {
regulate = true
while regulate {
motionManager.accelerometerUpdateInterval = 0.2
motionManager.startAccelerometerUpdates(to: OperationQueue.current!) { (data,error) in
if let myData = data {
if myData.acceleration.x > 5 {
print("DO SOMETHING SPECIAL")
regulate = false
}
}
}
}
} }
func rpsAction(choice: RPS.Choice) -> Bool? { func rpsAction(choice: RPS.Choice) -> Bool? {