Search in sources :

Example 1 with DeviceConfiguration

use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.

the class EditLegacyModuleControllerActivity method onCreate.

/**
 * In onCreate, we gather all of the linearLayout's that are associated with each port.
 * this is how the simple_device.xml file is reused, but we read and write to the correct
 * Spinners, EditTexts, TextViews, and Buttons. The TextView port# is set during onCreate
 * as a way to "name" that chunk of xml code. Each layout is then identified by the port number.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.legacy);
    info_port0 = createPortView(R.id.linearLayout0, 0);
    info_port1 = createPortView(R.id.linearLayout1, 1);
    info_port2 = createPortView(R.id.linearLayout2, 2);
    info_port3 = createPortView(R.id.linearLayout3, 3);
    info_port4 = createPortView(R.id.linearLayout4, 4);
    info_port5 = createPortView(R.id.linearLayout5, 5);
    controller_name = (EditText) findViewById(R.id.device_interface_module_name);
    EditParameters parameters = EditParameters.fromIntent(this, getIntent());
    deserialize(parameters);
    devices = (ArrayList<DeviceConfiguration>) controllerConfiguration.getDevices();
    controller_name.setText(controllerConfiguration.getName());
    controller_name.addTextChangedListener(new UsefulTextWatcher());
    showFixSwapButtons();
    for (int i = 0; i < devices.size(); i++) {
        DeviceConfiguration device = devices.get(i);
        if (DEBUG) {
            RobotLog.e("[onStart] device name: " + device.getName() + ", port: " + device.getPort() + ", type: " + device.getConfigurationType());
        }
        populatePort(findViewByPort(i), device);
    }
}
Also used : DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 2 with DeviceConfiguration

use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.

the class EditMatrixControllerActivity method handleDisabledDevice.

private void handleDisabledDevice(int port, View info_port, List<? extends DeviceConfiguration> list) {
    CheckBox checkbox = (CheckBox) info_port.findViewById(R.id.checkbox_port);
    DeviceConfiguration device = list.get(port - 1);
    if (device.isEnabled()) {
        checkbox.setChecked(true);
        EditText name = (EditText) info_port.findViewById(R.id.editTextResult);
        name.setText(device.getName());
    } else {
        // kind of a hack. Sets the checkbox to true, so
        checkbox.setChecked(true);
        // when performing the click programmatically,
        // the checkbox becomes "unclicked" which does the right thing.
        checkbox.performClick();
    }
}
Also used : EditText(android.widget.EditText) CheckBox(android.widget.CheckBox) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 3 with DeviceConfiguration

use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.

the class HardwareFactory method buildI2cDevices.

private void buildI2cDevices(List<DeviceConfiguration> list, HardwareMap map, DeviceManager deviceMgr, I2cController i2cController) {
    for (DeviceConfiguration deviceConfiguration : list) {
        ConfigurationType devType = deviceConfiguration.getConfigurationType();
        if (devType == BuiltInConfigurationType.I2C_DEVICE) {
            mapI2cDevice(map, deviceMgr, i2cController, deviceConfiguration);
            continue;
        }
        if (devType == BuiltInConfigurationType.I2C_DEVICE_SYNCH) {
            mapI2cDeviceSynch(map, deviceMgr, i2cController, deviceConfiguration);
            continue;
        }
        if (devType == BuiltInConfigurationType.IR_SEEKER_V3) {
            mapIrSeekerV3Device(map, deviceMgr, i2cController, deviceConfiguration);
            continue;
        }
        if (devType == BuiltInConfigurationType.ADAFRUIT_COLOR_SENSOR) {
            mapAdafruitColorSensor(map, deviceMgr, i2cController, deviceConfiguration);
            continue;
        }
        if (devType == BuiltInConfigurationType.COLOR_SENSOR) {
            mapModernRoboticsColorSensor(map, deviceMgr, i2cController, deviceConfiguration);
            continue;
        }
        if (devType == BuiltInConfigurationType.GYRO) {
            mapModernRoboticsGyro(map, deviceMgr, i2cController, deviceConfiguration);
            continue;
        }
        if (devType == BuiltInConfigurationType.NOTHING) {
            // nothing to do
            continue;
        }
        if (devType.isDeviceFlavor(UserConfigurationType.Flavor.I2C)) {
            if (devType instanceof UserI2cSensorType) {
                mapUserI2cDevice(map, deviceMgr, i2cController, deviceConfiguration);
                continue;
            }
        }
        RobotLog.w("Unexpected device type connected to I2c Controller while parsing XML: " + devType.toString());
    }
}
Also used : ConfigurationType(com.qualcomm.robotcore.hardware.configuration.ConfigurationType) BuiltInConfigurationType(com.qualcomm.robotcore.hardware.configuration.BuiltInConfigurationType) UserConfigurationType(com.qualcomm.robotcore.hardware.configuration.UserConfigurationType) UserI2cSensorType(com.qualcomm.robotcore.hardware.configuration.UserI2cSensorType) LynxUsbDeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.LynxUsbDeviceConfiguration) LynxI2cDeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.LynxI2cDeviceConfiguration) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 4 with DeviceConfiguration

use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.

the class HardwareFactory method mapUsbServoController.

private void mapUsbServoController(HardwareMap map, DeviceManager deviceMgr, ServoControllerConfiguration ctrlConf) throws RobotCoreException, InterruptedException {
    if (!ctrlConf.isEnabled()) {
        return;
    }
    ServoController servoController = deviceMgr.createUsbServoController(ctrlConf.getSerialNumber(), ctrlConf.getName());
    map.servoController.put(ctrlConf.getName(), servoController);
    for (DeviceConfiguration servoConf : ctrlConf.getDevices()) {
        mapServo(map, deviceMgr, servoConf, servoController);
    }
}
Also used : LynxServoController(com.qualcomm.hardware.lynx.LynxServoController) MatrixServoController(com.qualcomm.hardware.matrix.MatrixServoController) ServoController(com.qualcomm.robotcore.hardware.ServoController) LynxUsbDeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.LynxUsbDeviceConfiguration) LynxI2cDeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.LynxI2cDeviceConfiguration) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 5 with DeviceConfiguration

use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.

the class EditParameters method setItems.

private void setItems(Class<ITEM_T> itemClass, List<ITEM_T> list) {
    this.itemClass = itemClass;
    this.currentItems = list;
    for (DeviceConfiguration item : list) {
        Assert.assertTrue(itemClass.isInstance(item));
    }
}
Also used : DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Aggregations

DeviceConfiguration (com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)21 EditText (android.widget.EditText)8 LynxI2cDeviceConfiguration (com.qualcomm.robotcore.hardware.configuration.LynxI2cDeviceConfiguration)8 LynxUsbDeviceConfiguration (com.qualcomm.robotcore.hardware.configuration.LynxUsbDeviceConfiguration)8 TextView (android.widget.TextView)7 View (android.view.View)4 CheckBox (android.widget.CheckBox)4 LynxServoController (com.qualcomm.hardware.lynx.LynxServoController)4 MatrixServoController (com.qualcomm.hardware.matrix.MatrixServoController)3 ServoController (com.qualcomm.robotcore.hardware.ServoController)3 BuiltInConfigurationType (com.qualcomm.robotcore.hardware.configuration.BuiltInConfigurationType)3 ConfigurationType (com.qualcomm.robotcore.hardware.configuration.ConfigurationType)3 LynxDcMotorController (com.qualcomm.hardware.lynx.LynxDcMotorController)2 LynxModule (com.qualcomm.hardware.lynx.LynxModule)2 LynxModuleConfiguration (com.qualcomm.robotcore.hardware.configuration.LynxModuleConfiguration)2 MatrixControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.MatrixControllerConfiguration)2 MotorConfiguration (com.qualcomm.robotcore.hardware.configuration.MotorConfiguration)2 ServoControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.ServoControllerConfiguration)2 ArrayList (java.util.ArrayList)2 LinearLayout (android.widget.LinearLayout)1