[F] Implement shake correctly
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user