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);
}
}
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();
}
}
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());
}
}
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);
}
}
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));
}
}
Aggregations