Logging and manipulating accelerometer (and gyro) data simultaneously
I am trying to log accelerometer data and also manipulate it in real time.
I call this function:
@IBAction func accelerometerBMI160StartLogPressed(_ sender: Any) {
accelerometerBMI160StartLog.isEnabled = false
accelerometerBMI160StopLog.isEnabled = true
accelerometerBMI160StartStream.isEnabled = false
accelerometerBMI160StopStream.isEnabled = false
updateAccelerometerBMI160Settings()
device.accelerometer!.dataReadyEvent.startLoggingAsync()
manipulate_data()
Under: manipulate_data(), I have added:
================================
var array = [MBLAccelerometerData]() /* capacity: 1000 */
accelerometerBMI160Data = array
device.accelerometer!.dataReadyEvent.startNotificationsAsync { (obj, error) in
if let obj = obj {
//Manipulate data
}
}
================================
Then when Stop log is pressed, I call the stop log function and have added:
device.accelerometer!.dataReadyEvent.stopNotificationsAsync()
================================
Is that ok? Any causes of concern here?
I call this function:
@IBAction func accelerometerBMI160StartLogPressed(_ sender: Any) {
accelerometerBMI160StartLog.isEnabled = false
accelerometerBMI160StopLog.isEnabled = true
accelerometerBMI160StartStream.isEnabled = false
accelerometerBMI160StopStream.isEnabled = false
updateAccelerometerBMI160Settings()
device.accelerometer!.dataReadyEvent.startLoggingAsync()
manipulate_data()
Under: manipulate_data(), I have added:
================================
var array = [MBLAccelerometerData]() /* capacity: 1000 */
accelerometerBMI160Data = array
device.accelerometer!.dataReadyEvent.startNotificationsAsync { (obj, error) in
if let obj = obj {
//Manipulate data
}
}
================================
Then when Stop log is pressed, I call the stop log function and have added:
device.accelerometer!.dataReadyEvent.stopNotificationsAsync()
================================
Is that ok? Any causes of concern here?
This discussion has been closed.
Comments