Welcome

This documentation will guide you through the methods available in the Drum HAT python library.

Drum HAT is a musical Raspberry Pi add-on with 8 capacitive-touch drum pads.

At A Glance

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

Turn Off All Lights

drumhat.all_off()[source]

Turn off all LEDs

Turn On All Lights

drumhat.all_on()[source]

Turn on all LEDs

Turn On A Light

drumhat.led_on(pad)[source]

Turn on an LED corresponding to a single pad.

Parameters:pad – A single integer from 0 to 7, corresponding to the pad whose LED you want to turn on.

Turn Off A Light

drumhat.led_off(pad)[source]

Turn off an LED corresponding to a single pad.

Parameters:pad – A single integer from 0 to 7, corresponding to the pad whose LED you want to turn off.

Detect A Hit

drumhat.on_hit(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 from 0 to 7, or a list of integers
  • handler – The handler function to call on hit

Detect A Release

drumhat.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 7, or a list of integers
  • handler – The handler function to call on release