Custom IO - Cypress FirstTouch Module
The Cypress FirstTouch IO module is a board that allows teams to interface to custom IO solutions such as potentiometers, buttons, switches, encoders, and much more. The methods used with the Cypress board in standard (compatible) mode may also be used to interface with virtual IO provided by the DS software if the Cypress board is not attached.
Programming the FirstTouch module
Before using the FirstTouch module the proper software must be loaded onto the board. For additional details see this article.
Configuring the mode
The Cypress board can be set to one of two modes when used with the FRC Driver Station. Additionally, the function of each pin and another of other advanced features can be configured if the board is set to advanced mode. To set the mode of the board, click on the I/O tab of the Driver Station, then click the Configure button. Select Compatible or Enhanced at the bottom of the dialog, and configure the settings in the box above if using Advanced mode (these settings do not apply to Compatible mode), then click Ok.
When the Cypress Board is in standard/compatible IO mode the data it provides is accessed through the Driver Station class. Each of the three types of IO requires a parameter of the channel number and digital outputs require a value. Valid channels for the IO types are:
- Analog: 1-4
- Digital Input: 1-8
- Digital Output: 1-8
The same Driver Station methods can be used to interact with Virtual IO if no Cypress Board is present. On the IO tab of the Driver Station there are controls for each of the 8 Digital Inputs (click to toggle), indicators for the 8 Digital Outputs, and controls for the 4 Analog Inputs (click and drag or type in the box to set).
If the Cypress board is set to enhanced mode, you must use the DriverStationEnhancedIO class to set and retrieve values. This class has additional methods to handle configuration of the board in enhanced mode and getting and setting values associated with the advanced features such as PWM generation and quadrature decoding.
The Enhanced IO configuration can be set either using the IO tab of the Driver Station as shown above or by using the methods in the DriverStationEnhancedIO class. Changes made in the Driver Station will persist across runs of the DS software by using a configuration file, but will not persist across different machines even if the same Cypress board is used. Configuration set in the robot code will override the configuration loaded from the file by the DS but may not override any changes that are made on the IO tab after the robot has linked to the DS.
The Enhanced I/O module has a very powerful and expanded set of capabilities beyond just simple analog and digital I/O. The table above details the available options.