ThreeAxisDigitalAccelerometer16g sensor;
public override Task Initialize()
{
Resolver.Log.Info("Initializing");
sensor = new ThreeAxisDigitalAccelerometer16g(Device.CreateI2cBus());
sensor.SetPowerState(false, false, true, false, ThreeAxisDigitalAccelerometer16g.Frequencies.TwoHz);
sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
$"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
$"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]");
};
return Task.CompletedTask;
}
public override Task Run()
{
sensor.StartUpdating(TimeSpan.FromMilliseconds(500));
return Task.CompletedTask;
}