Created
May 3, 2015 23:11
-
-
Save anonymous/748f0c95eb5fe4bafbb6 to your computer and use it in GitHub Desktop.
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
import Foundation | |
class MetawearConfig:NSObject, MBLRestorable { | |
var pulseWidthEvent:MBLEvent! | |
func encodeWithCoder(aCoder: NSCoder) { | |
aCoder.encodeObject(self.pulseWidthEvent, forKey: "pulseWidthEvent") | |
} | |
required init(coder: NSCoder) { | |
super.init() | |
self.pulseWidthEvent = coder.decodeObjectForKey("pulseWidthEvent") as? MBLEvent | |
} | |
override init () { | |
super.init() | |
} | |
func runOnDeviceBoot(device: MBLMetaWear) { | |
// Log some Accelerometer data | |
device.accelerometer.fullScaleRange = MBLAccelerometerRange.Range2G | |
device.accelerometer.filterCutoffFreq = 0 | |
device.accelerometer.highPassFilter = true; | |
var periodicEvent = device.accelerometer.rmsDataReadyEvent.periodicSampleOfEvent(1000) | |
self.pulseWidthEvent = periodicEvent.pulseDetectorOfEventWithThreshold(30, width: 3, output: MBLPulseOutput.Width) | |
self.pulseWidthEvent.startLogging() | |
println("Logging Started") | |
} | |
} | |
// Config code | |
self.device.setConfiguration(MetawearConfig()) { error in | |
self.downloadLogButton.enabled = true | |
println("set Configuration successful") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment