mbl_mw_acc_set_odr not working
Hello! I want my app to change the device's data collecting frequency. Below is my code.
func accelerometerStartLog(device: MetaWear) {
mbl_mw_acc_set_odr(device.board, 2.0)
mbl_mw_acc_bosch_write_acceleration_config(device.board)
guard let signal = mbl_mw_acc_bosch_get_acceleration_data_signal(metaWearDevice!.board) else {
print("Error: Acceleration signal not given")
return
}
mbl_mw_datasignal_log(signal, bridge(obj: self)) { (context, logger) in
if let _ = logger {
print("logger ready\n");
}
let _self: DeviceViewController = bridge(ptr: context!)
let cString = mbl_mw_logger_generate_identifier(logger)!
let identifier = String(cString: cString)
let intBitPattern = Int(bitPattern: logger!)
_self.loggers[identifier] = intBitPattern
_self.logger = logger
}
mbl_mw_logging_start(metaWearDevice!.board, 0)
mbl_mw_acc_bosch_enable_acceleration_sampling(metaWearDevice!.board)
mbl_mw_acc_start(metaWearDevice!.board)
}
However, it seems that the line mbl_mw_acc_set_odr(device.board, 2.0)
is not working. I think I am mistaken about a few functions. Can someone tell me what's wrong? Thank you.
Comments
Your code looks fine, it would set the ODR to 1.5625Hz (the closest value to 2.0). What makes you think it isn't working?
@Laura
When I tested the code through streaming, the data was collected too frequently. mbl_mw_acc_set_odr(device.board, 2.0) doesn't seem to work.
Below is my test code.
Your code looks fine. Do you have data to show why you think this isn't working?
@Laura
According to the file, acceleration data is collected every 80ms. Even though I set it to 2Hz, I think the MMS accelerometer is set to 12.5Hz.
This has been fixed in the new cpp lib update: https://github.com/mbientlab/MetaWear-SDK-Cpp/releases