use of com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device in project robo4j by Robo4J.
the class AccelerometerLSM303Unit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
super.onInitialization(configuration);
PowerMode powerMode = PowerMode.valueOf(configuration.getString(PROPERTY_KEY_POWER_MODE, PowerMode.NORMAL.name()));
DataRate rate = DataRate.valueOf(configuration.getString(PROPERTY_KEY_RATE, DataRate.HZ_10.name()));
Integer axisEnable = configuration.getInteger(PROPERTY_KEY_AXIS_ENABLE, AccelerometerLSM303Device.AXIS_ENABLE_ALL);
FullScale fullScale = FullScale.valueOf(configuration.getString(PROPERTY_KEY_FULL_SCALE, FullScale.G_2.name()));
Boolean enableHighRes = configuration.getBoolean(PROPERTY_KEY_ENABLE_HIGH_RES, false);
Float3D offsets = readFloat3D(configuration.getChildConfiguration("offsets"));
Float3D multipliers = readFloat3D(configuration.getChildConfiguration("multipliers"));
period = configuration.getInteger(PROPERTY_KEY_PERIOD, 200);
try {
AccelerometerLSM303Device device = new AccelerometerLSM303Device(getBus(), getAddress(), powerMode, rate, axisEnable, fullScale, enableHighRes);
accelerometer = new CalibratedAccelerometer(device, offsets, multipliers);
} catch (IOException e) {
throw new ConfigurationException(String.format("Failed to initialize lidar device. Make sure it is hooked up to bus: %d address: %xd", getBus(), getAddress()), e);
}
}
Aggregations