Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import Foundation
class MetawearConfig:NSObject, MBLRestorable {
var pulseWidthEvent:MBLEvent!
func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(self.pulseWidthEvent, forKey: "pulseWidthEvent")
required init(coder: NSCoder) {
self.pulseWidthEvent = coder.decodeObjectForKey("pulseWidthEvent") as? MBLEvent
override 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)
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
You can’t perform that action at this time.