Welcome

This documentation will guide you through the methods available in the Touch pHAT python library.

At A Glance

touchphat.all_off()[source]
touchphat.all_on()[source]
touchphat.led_off(pad)[source]
touchphat.led_on(pad)[source]
touchphat.on_release(pad, handler=None)[source]
touchphat.on_touch(pad, handler=None)[source]

Turn Off All Lights

touchphat.all_off()[source]

Turn off all LEDs

Turn On All Lights

touchphat.all_on()[source]

Turn on all LEDs

Turn On A Light

touchphat.led_on(pad)[source]

Turn on an LED corresponding to a single pad.

Parameters:pad – A single integer from 0 to 5 or a pad name (Back, A, B, C, D, Enter), corresponding to the pad whose LED you want to turn on.

Turn Off A Light

touchphat.led_off(pad)[source]

Turn off an LED corresponding to a single pad.

Parameters:pad – A single integer from 0 to 5 or a pad name (Back, A, B, C, D, Enter), corresponding to the pad whose LED you want to turn off.

Detect A Touch

touchphat.on_touch(pad, handler=None)[source]

Register a function to be called when a pad or pads are hit.

The function should expect one argument: event. You can look at event.pad to determine which pad was hit.

Parameters:
  • pad – A single integer 0 to 5, a pad name (Back, A, B, C, D, Enter), or a list
  • handler – The handler function to call on hit

Detect A Release

touchphat.on_release(pad, handler=None)[source]

Register a function to be called when a pad or pads are released.

The function should expect one argument: event. You can look at event.pad to determine which pad was released.

Parameters:
  • pad – A single integer from 0 to 5, a pad name (Back, A, B, C, D, Enter), or a list
  • handler – The handler function to call on release