Search in sources :

Example 16 with DeviceConfiguration

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

the class EditLegacyModuleControllerActivity method clearDevice.

/**
 * Sets device to a non-attached device (name "NO DEVICE ATTACHED" and name field grayed out).
 * Removes the button if necessary.
 *
 * @param itemView - the view that holds all the necessary UI elements
 */
@Override
protected void clearDevice(View itemView) {
    TextView portNumber = (TextView) itemView.findViewById(R.id.portNumber);
    int port = Integer.parseInt(portNumber.getText().toString());
    EditText nameText = (EditText) itemView.findViewById(R.id.editTextResult);
    nameText.setEnabled(false);
    nameText.setText(disabledDeviceName());
    DeviceConfiguration newModule = new DeviceConfiguration(BuiltInConfigurationType.NOTHING);
    newModule.setPort(port);
    setModule(newModule);
    setButtonVisibility(port, View.GONE);
}
Also used : EditText(android.widget.EditText) TextView(android.widget.TextView) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 17 with DeviceConfiguration

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

the class EditLegacyModuleControllerActivity method changeDevice.

/**
 * Updates the module behind the scenes to the type that was selected on the spinner.
 *
 * @param itemView - - the view that holds all the necessary UI elements
 * @param type     - the new type that was just selected
 */
@Override
protected void changeDevice(View itemView, ConfigurationType type) {
    TextView portNumber = (TextView) itemView.findViewById(R.id.portNumber);
    int port = Integer.parseInt(portNumber.getText().toString());
    EditText nameText = (EditText) itemView.findViewById(R.id.editTextResult);
    DeviceConfiguration currentModule = devices.get(port);
    nameText.setEnabled(true);
    clearNameIfNecessary(nameText, currentModule);
    if (type == BuiltInConfigurationType.MOTOR_CONTROLLER || type == BuiltInConfigurationType.SERVO_CONTROLLER || type == BuiltInConfigurationType.MATRIX_CONTROLLER) {
        createController(port, type);
        setButtonVisibility(port, View.VISIBLE);
    } else {
        currentModule.setConfigurationType(type);
        if (type == BuiltInConfigurationType.NOTHING) {
            currentModule.setEnabled(false);
        } else {
            currentModule.setEnabled(true);
        }
        setButtonVisibility(port, View.GONE);
    }
    if (DEBUG) {
        DeviceConfiguration module = devices.get(port);
        RobotLog.e("[changeDevice] modules.get(port) name: " + module.getName() + ", port: " + module.getPort() + ", type: " + module.getConfigurationType());
    }
}
Also used : EditText(android.widget.EditText) TextView(android.widget.TextView) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 18 with DeviceConfiguration

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

the class EditMatrixControllerActivity method addCheckBoxListenerOnPort.

private void addCheckBoxListenerOnPort(final int port, View info_port, List<? extends DeviceConfiguration> list) {
    final EditText name;
    name = (EditText) info_port.findViewById(R.id.editTextResult);
    final DeviceConfiguration device;
    device = list.get(port - 1);
    CheckBox checkbox = (CheckBox) info_port.findViewById(R.id.checkbox_port);
    checkbox.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (((CheckBox) view).isChecked()) {
                name.setEnabled(true);
                name.setText("");
                device.setEnabled(true);
                device.setName("");
            } else {
                name.setEnabled(false);
                device.setEnabled(false);
                device.setName(disabledDeviceName());
                name.setText(disabledDeviceName());
            }
        }
    });
}
Also used : EditText(android.widget.EditText) CheckBox(android.widget.CheckBox) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration) TextView(android.widget.TextView) View(android.view.View)

Example 19 with DeviceConfiguration

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

the class EditPortListCheckboxActivity method handleDisabledDeviceByIndex.

protected void handleDisabledDeviceByIndex(int index) {
    View itemView = findViewByIndex(index);
    CheckBox checkbox = (CheckBox) itemView.findViewById(idItemCheckbox);
    DeviceConfiguration device = this.itemList.get(index);
    if (device.isEnabled()) {
        checkbox.setChecked(true);
        EditText name = (EditText) itemView.findViewById(idItemEditTextResult);
        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) View(android.view.View) DeviceConfiguration(com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)

Example 20 with DeviceConfiguration

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

the class EditPortListSpinnerActivity method clearDevice.

@Override
protected void clearDevice(View itemView) {
    TextView textViewPortNumber = (TextView) itemView.findViewById(this.idItemPortNumber);
    int portNumber = Integer.parseInt(textViewPortNumber.getText().toString());
    EditText nameText = (EditText) itemView.findViewById(this.idItemEditTextResult);
    nameText.setEnabled(false);
    nameText.setText(disabledDeviceName());
    DeviceConfiguration config = findConfigByPort(portNumber);
    config.setEnabled(false);
}
Also used : EditText(android.widget.EditText) TextView(android.widget.TextView) 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