Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jdiedrick/development
Development to master!
- Loading branch information
Showing
12 changed files
with
902 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
PODS: | ||
- Alamofire (1.2.3) | ||
- MotionKit (0.8.1) | ||
- SwiftyJSON (2.2.0) | ||
|
||
DEPENDENCIES: | ||
- Alamofire | ||
- Alamofire (from `https://github.com/Alamofire/Alamofire.git`) | ||
- MotionKit | ||
- SwiftyJSON (~> 2.2.0) | ||
|
||
EXTERNAL SOURCES: | ||
Alamofire: | ||
:git: https://github.com/Alamofire/Alamofire.git | ||
|
||
CHECKOUT OPTIONS: | ||
Alamofire: | ||
:commit: 97c29c6c48c82344a8f4919b1b6517c7957af3a3 | ||
:git: https://github.com/Alamofire/Alamofire.git | ||
|
||
SPEC CHECKSUMS: | ||
Alamofire: 5550bf0b575ed1a4bf9be572f9463e1015cc169e | ||
MotionKit: a88a7d7b5ed6652793a3744f6ca58227d8804236 | ||
SwiftyJSON: 0b3e6c07af17ff745e77e8e9984097b55c956e5c | ||
|
||
COCOAPODS: 0.37.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// | ||
// TZDriftViewController.swift | ||
// transients | ||
// | ||
// Created by Johann Diedrick on 7/20/15. | ||
// Copyright (c) 2015 Johann Diedrick. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MotionKit | ||
|
||
|
||
class TZDriftViewController: UIViewController{ | ||
|
||
var file_path:NSURL? | ||
|
||
let motionKit = MotionKit() | ||
|
||
let threshold = 0.5 | ||
let interval = 0.1 | ||
let magnitude = 5 | ||
|
||
override func viewDidLoad(){ | ||
view.backgroundColor = UIColor.orangeColor() | ||
|
||
|
||
LocationService.sharedInstance.startUpdatingLocation() | ||
LocationService.sharedInstance.startUpdatingHeading() | ||
|
||
|
||
var motionValues = NSMutableArray() | ||
|
||
|
||
|
||
motionKit.getAccelerometerValues(interval: self.interval) {(x, y, z) -> () in | ||
|
||
// println("X: \(x) Y: \(y) Z \(z)") | ||
var slowedDown = false | ||
|
||
|
||
if(x < -self.threshold){ //we're moving! | ||
|
||
//println("we're moving") | ||
motionValues.addObject(x) | ||
//println(motionValues) | ||
var lastValue = motionValues.lastObject as! Float64 | ||
|
||
if(motionValues.count > 3){ | ||
var penultimateValue = motionValues.objectAtIndex(motionValues.count - 2) as! Float64 | ||
// println("last value: \(lastValue) | penultimateValue: \(penultimateValue)") | ||
if slowedDown == false{ | ||
if (lastValue > penultimateValue){ | ||
|
||
var throwDistance = abs(penultimateValue) - self.threshold | ||
println("we're slowing down: max value above threshold: \(throwDistance)") | ||
|
||
slowedDown = true | ||
motionValues.removeAllObjects() | ||
|
||
self.calculateNewPosition(throwDistance) | ||
} | ||
} | ||
} | ||
} | ||
|
||
//reset slowedDown check | ||
slowedDown = false | ||
|
||
} | ||
} | ||
|
||
func calculateNewPosition(throwDistance : Double){ | ||
var distance = 3.0*throwDistance //first calculate magnitude (distance); might wanna use a map function? | ||
var currentLat = LocationService.sharedInstance.currentLocation!.coordinate.latitude | ||
var currentLng = LocationService.sharedInstance.currentLocation!.coordinate.longitude | ||
var heading = LocationService.sharedInstance.currentHeading!.magneticHeading | ||
var latDisplacement = distance*cos(self.DegreesToRadians(heading)) | ||
var lngDisplacement = distance*sin(self.DegreesToRadians(heading)) | ||
var newLat = currentLat + latDisplacement | ||
var newLng = currentLng + lngDisplacement | ||
|
||
println("Distance: \(distance) | Current Lat: \(currentLat) | Current Lng: \(currentLng) | Heading: \(heading) | latDisp: \(latDisplacement) | lngDisp: \(lngDisplacement) | New Lat: \(newLat) | New Lng: \(newLng) ") | ||
|
||
|
||
} | ||
|
||
|
||
|
||
func DegreesToRadians (value:Double) -> Double { | ||
return value * M_PI / 180.0 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// TZGeoSoundPlayer.swift | ||
// transients | ||
// | ||
// Created by Johann Diedrick on 6/28/15. | ||
// Copyright (c) 2015 Johann Diedrick. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
class TZGeoSoundPlayer : AVAudioPlayer{ | ||
|
||
func startPlayingAudio(){ | ||
if self.playing == false{ | ||
self.play() | ||
} | ||
} | ||
|
||
func stopPlayingAudio(){ | ||
if self.playing == true{ | ||
self.stop() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// TZGeoSoundRecorder.swift | ||
// transients | ||
// | ||
// Created by Johann Diedrick on 6/28/15. | ||
// Copyright (c) 2015 Johann Diedrick. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
class TZGeoSoundRecorder : AVAudioRecorder{ | ||
|
||
func startRecordingAudio(){ | ||
if self.recording == false{ | ||
self.record() | ||
} | ||
} | ||
|
||
func stopRecordingAudio(){ | ||
println("\(self.currentTime)") | ||
if self.recording == true{ | ||
self.stop() | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.