Search in sources :

Example 1 with ConfigurationException

use of com.robo4j.ConfigurationException in project robo4j by Robo4J.

the class Adafruit8x8MatrixUnit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    super.onInitialization(configuration);
    int brightness = configuration.getInteger(ATTRIBUTE_BRIGHTNESS, AbstractBackpack.DEFAULT_BRIGHTNESS);
    MatrixRotation rotation = MatrixRotation.valueOf(configuration.getString(ATTRIBUTE_ROTATION, DEFAULT_MATRIX_ROTATION).toUpperCase());
    try {
        device = new BiColor8x8MatrixDevice(getBus(), getAddress(), brightness);
    } catch (IOException e) {
        throw new ConfigurationException("Failed to instantiate device", e);
    }
    device.setRotation(rotation);
}
Also used : BiColor8x8MatrixDevice(com.robo4j.hw.rpi.i2c.adafruitbackpack.BiColor8x8MatrixDevice) ConfigurationException(com.robo4j.ConfigurationException) MatrixRotation(com.robo4j.hw.rpi.i2c.adafruitbackpack.MatrixRotation) IOException(java.io.IOException)

Example 2 with ConfigurationException

use of com.robo4j.ConfigurationException in project robo4j by Robo4J.

the class AdafruitAlphanumericUnit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    super.onInitialization(configuration);
    int brightness = configuration.getInteger(AbstractI2CBackpackUnit.ATTRIBUTE_BRIGHTNESS, AbstractBackpack.DEFAULT_BRIGHTNESS);
    try {
        device = new AlphanumericDevice(getBus(), getAddress(), brightness);
    } catch (IOException e) {
        throw new ConfigurationException("Failed to instantiate device", e);
    }
}
Also used : AlphanumericDevice(com.robo4j.hw.rpi.i2c.adafruitbackpack.AlphanumericDevice) ConfigurationException(com.robo4j.ConfigurationException) IOException(java.io.IOException)

Example 3 with ConfigurationException

use of com.robo4j.ConfigurationException in project robo4j by Robo4J.

the class Bno080Unit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    final String reportType = configuration.getString(PROPERTY_REPORT_TYPE, null);
    report = SensorReportId.valueOf(reportType.toUpperCase());
    if (report.equals(SensorReportId.NONE)) {
        throw new ConfigurationException(PROPERTY_REPORT_TYPE);
    }
    final Integer delay = configuration.getInteger(PROPERTY_REPORT_DELAY, null);
    if (delay == null || delay <= 0) {
        throw new ConfigurationException(PROPERTY_REPORT_DELAY);
    }
    this.reportDelay = delay;
    try {
        // TODO: make device configurable
        device = Bno080Factory.createDefaultSPIDevice();
    } catch (IOException | InterruptedException e) {
        throw new ConfigurationException("Could not initiate device", e);
    }
    device.start(report, reportDelay);
}
Also used : ConfigurationException(com.robo4j.ConfigurationException) IOException(java.io.IOException)

Example 4 with ConfigurationException

use of com.robo4j.ConfigurationException in project robo4j by Robo4J.

the class GyroL3GD20Unit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    super.onInitialization(configuration);
    sensitivity = Sensitivity.valueOf(configuration.getString(PROPERTY_KEY_SENSITIVITY, "DPS_245"));
    period = configuration.getInteger(PROPERTY_KEY_PERIOD, 10);
    highPassFilter = configuration.getBoolean(PROPERTY_KEY_HIGH_PASS_FILTER, true);
    try {
        gyro = new CalibratedGyro(new GyroL3GD20Device(getBus(), getAddress(), sensitivity, highPassFilter));
    } 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);
    }
}
Also used : CalibratedGyro(com.robo4j.hw.rpi.i2c.gyro.CalibratedGyro) ConfigurationException(com.robo4j.ConfigurationException) IOException(java.io.IOException) GyroL3GD20Device(com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device)

Example 5 with ConfigurationException

use of com.robo4j.ConfigurationException in project robo4j by Robo4J.

the class InfraSensorUnit method onInitialization.

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
    setState(LifecycleState.UNINITIALIZED);
    scanInitialDelay = configuration.getInteger(PROPERTY_SCAN_INIT_DELAY, VALUE_SCAN_INIT_DELAY);
    scanPeriod = configuration.getInteger(PROPERTY_SCAN_PERIOD, VALUE_SCAN_PERIOD);
    String port = configuration.getString(PROPERTY_SENSOR_PORT, null);
    DigitalPortEnum sensorPort = DigitalPortEnum.getByType(port);
    target = configuration.getString(PROPERTY_TARGET, null);
    if (sensorPort == null) {
        throw new ConfigurationException("infraRed sensor port required: {S1,S2,S3,S4}");
    }
    if (target == null) {
        throw new ConfigurationException("infraRed sensor target required");
    }
    SensorProvider provider = new SensorProvider();
    sensor = new SensorWrapper<>(provider, sensorPort, SensorTypeEnum.INFRA);
    setState(LifecycleState.INITIALIZED);
}
Also used : SensorProvider(com.robo4j.hw.lego.provider.SensorProvider) ConfigurationException(com.robo4j.ConfigurationException) DigitalPortEnum(com.robo4j.hw.lego.enums.DigitalPortEnum)

Aggregations

ConfigurationException (com.robo4j.ConfigurationException)13 IOException (java.io.IOException)10 SensorProvider (com.robo4j.hw.lego.provider.SensorProvider)3 DigitalPortEnum (com.robo4j.hw.lego.enums.DigitalPortEnum)2 AccelerometerLSM303Device (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device)1 DataRate (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device.DataRate)1 FullScale (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device.FullScale)1 PowerMode (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device.PowerMode)1 CalibratedAccelerometer (com.robo4j.hw.rpi.i2c.accelerometer.CalibratedAccelerometer)1 AlphanumericDevice (com.robo4j.hw.rpi.i2c.adafruitbackpack.AlphanumericDevice)1 BiColor24BarDevice (com.robo4j.hw.rpi.i2c.adafruitbackpack.BiColor24BarDevice)1 BiColor8x8MatrixDevice (com.robo4j.hw.rpi.i2c.adafruitbackpack.BiColor8x8MatrixDevice)1 MatrixRotation (com.robo4j.hw.rpi.i2c.adafruitbackpack.MatrixRotation)1 CalibratedGyro (com.robo4j.hw.rpi.i2c.gyro.CalibratedGyro)1 GyroL3GD20Device (com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device)1 LidarLiteDevice (com.robo4j.hw.rpi.i2c.lidar.LidarLiteDevice)1 PCA9685Servo (com.robo4j.hw.rpi.i2c.pwm.PCA9685Servo)1 PWMPCA9685Device (com.robo4j.hw.rpi.i2c.pwm.PWMPCA9685Device)1 RoboClawRCTank (com.robo4j.hw.rpi.pwm.roboclaw.RoboClawRCTank)1 MTK3339GPS (com.robo4j.hw.rpi.serial.gps.MTK3339GPS)1