[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
-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")
}