Displayotron hat physical buttons


#1

Hello everyone,

I just received my displayotron hat and it’s good so far but I was wondering if it was possible to use external physical buttons instead of the sensitive one. I explain : I’m planning on doing some network music player in a box with only the screen being apparent. The position and the “sensitive” thing of the button is not suited and I like to put them elsewhere.

So is it possible to keep using python library button code with other buttons ? Or should I find another way ?

Thanks in advance !


#2

Unfortunately the library code is very specific to reading the capacative touch chip, so you can’t use it with external buttons. It’s relatively trivial to read a button- wired to any other GPIO pin- though.

See here for a list of pins you have free: https://pinout.xyz/pinout/display_o_tron_hat

Connect a button between any free pin, and Ground.

Set up the pin as an input, with a pull-up, and either read it in a loop, or use RPi.GPIO’s polling:

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(<your-pin>, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
GPIO.input(<your-pin>) # will be 1 for off, 0 for pressed

Then to handle a press:

def handle_button(pin):
    print("Button connected to pin {pin} has been pressed!".format(pin=pin))

GPIO.add_event_detect(<your-pin>, GPIO.FALLING, callback=handle_button, bouncetime=200)

( Note: above code was typed from memory, so uh handle with care :D )


#3

Thank you, I’ll be looking into this.


#4

I have a similar question. I was hoping that I can “extend” the touch pads with wires and move the actual touch area somewhere else (there seems to be an exposed “hole” near each pad. Is that possible?

Thanks,
P.K.


#5

You could certainly try- but it’s not something we’ve tested. Unfortunately the datasheets and design guides (for example: http://ww1.microchip.com/downloads/en/AppNotes/00001334B.pdf) don’t really go into any detail about how best to accomplish this, either, since they assume all the sensor pads will be routed on a PCB.

The sensor - CAP1166 on Display-o-Tron HAT if I remember correctly- has quite a large allowance for configuration and calibration, however, so you might be able to compensate for extended pads and make them work pretty well. Unfortunately, the datasheet is absolutely immense: http://ww1.microchip.com/downloads/en/DeviceDoc/CAP1166.pdf