Skip to content

Instantly share code, notes, and snippets.

@HongyiZhu
Created November 17, 2016 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HongyiZhu/9dd12f0b3e20e72968cfa6edfadb3852 to your computer and use it in GitHub Desktop.
Save HongyiZhu/9dd12f0b3e20e72968cfa6edfadb3852 to your computer and use it in GitHub Desktop.
This is the configuration logic that failed with firmware 1.2.5
accel_module = board.getModule(Bmi160Accelerometer.class);
settings_module = board.getModule(Settings.class);
timerModule = board.getModule(com.mbientlab.metawear.module.Timer.class);
timerModule.scheduleTask(new com.mbientlab.metawear.module.Timer.Task() {
@Override
public void commands() {
accel_module.disableAxisSampling();
}
}, 3000, true).onComplete(new AsyncOperation.CompletionHandler<com.mbientlab.metawear.module.Timer.Controller>() {
@Override
public void success(final com.mbientlab.metawear.module.Timer.Controller result) {
accel_module.routeData().fromMotion().monitor(new DataSignal.ActivityHandler() {
@Override
public void onSignalActive(Map<String, DataProcessor> map, DataSignal.DataToken dataToken) {
result.start();
accel_module.enableAxisSampling();
}
}).commit().onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
accel_module.configureAxisSampling()
.setOutputDataRate(Bmi160Accelerometer.OutputDataRate.ODR_12_5_HZ)
.commit();
accel_module.routeData().fromAxes().log(SENSOR_DATA_LOG).commit().onComplete(accelHandler);
accel_module.configureAnyMotionDetection().setThreshold(0.032f).commit();
accel_module.enableMotionDetection(Bmi160Accelerometer.MotionType.ANY_MOTION);
accel_module.startLowPower();
}
@Override
public void failure(Throwable error) {
error.printStackTrace();
}
});
}
@Override
public void failure(Throwable error) {
error.printStackTrace();
connectionStage = Constants.STAGE.INIT;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment