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.

Touch2USB signal path from the resistive panel to the USB HID host Resistive touch panel XPT2046 controller PENIRQ, active low (GPIO 20) Raspberry Pi Pico (RP2040) XPT2046 SPI0, 1 MHz, mode 0 Raw ADC 12-bit reading Map and filter calibrated, smoothed USB HID TinyUSB stack USB device stack (TinyUSB) USB full speed (12 Mbps) Host: PC or embedded system Sees a HID mouse or a HID touchscreen, driverless
A resistive touch becomes a 12-bit SPI reading, is calibrated and filtered in firmware, and leaves the board as an ordinary USB HID report.

Signal path

  1. Touch detection: the panel pulls PENIRQ low. Both firmwares treat GPIO 20 as an active-low input with the internal pull-up enabled.
  2. 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.
  3. Calibration and mapping: raw ADC counts are mapped to the panel’s screen range using the measured limits. See XPT2046 and calibration.
  4. Filtering: a median filter, an exponential moving average, a jitter threshold and a release guard clean the coordinate stream. See Signal filtering.
  5. 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

FirmwareUSB classReportHost sees
pico_platformio_touch_mouseHID Mouserelative X and Y deltasa pointing device on any OS
pico_sdk_touchHID Digitizerabsolute X and Y, plus contact statea 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.