System Architecture
Touch2USB is a single-board bridge. A resistive touch event becomes a 12-bit SPI reading, is calibrated and filtered in firmware, and leaves the Pico as an ordinary USB HID report. The same board presents one of two device personalities, decided only by which firmware is flashed.
Signal path
- Touch detection: the panel pulls PENIRQ low. Both firmwares treat GPIO 20 as an active-low input with the internal pull-up enabled.
- SPI read: the controller is a 12-bit ADC on SPI0 at 1 MHz, mode 0, MSB first. One control byte selects the X or Y plane.
- Calibration and mapping: raw ADC counts are mapped to the panel’s screen range using the measured limits. See XPT2046 and calibration.
- Filtering: a median filter, an exponential moving average, a jitter threshold and a release guard clean the coordinate stream. See Signal filtering.
- HID report: the coordinate is sent over USB, as a relative mouse delta or an absolute digitizer coordinate. See USB HID descriptors.
The two device personalities
| Firmware | USB class | Report | Host sees |
|---|---|---|---|
pico_platformio_touch_mouse | HID Mouse | relative X and Y deltas | a pointing device on any OS |
pico_sdk_touch | HID Digitizer | absolute X and Y, plus contact state | a single-touch touchscreen |
The two builds share the wiring, the SPI configuration and the signal chain, and differ only in the USB descriptor they present. The complete pin map, SPI settings and power notes are in Hardware; the choice between the builds is in Software.