Working on shaking
This commit is contained in:
@@ -92,6 +92,9 @@ class AlarmActivationViewController: UIViewController
|
||||
case "Shake":
|
||||
shakeView.isHidden = false
|
||||
shakeAction()
|
||||
if regulate {
|
||||
endAlarm()
|
||||
}
|
||||
default:
|
||||
print("Invalid alarm type")
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class RPS {
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
//Reference: https://youtu.be/XDuchXYiWuE
|
||||
class Shake {
|
||||
var motionManager = CMMotionManager()
|
||||
@@ -215,4 +215,4 @@ class Shake {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,9 @@ import CoreMotion
|
||||
import UserNotifications
|
||||
import UIKit
|
||||
|
||||
var motionManager = CMMotionManager()
|
||||
var regulate = true
|
||||
|
||||
func walkAction() {
|
||||
|
||||
}
|
||||
@@ -19,7 +22,20 @@ func jumpAction() {
|
||||
}
|
||||
|
||||
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? {
|
||||
|
||||
Reference in New Issue
Block a user