Button Shim interface documentation

Hi, I recently purchased a button shim and intend to use it in a project programmed in C using wiringPi. Is there documentation available for accessing the buttons using I2C manually? I’m not looking forward to trying to reverse engineer the relevant information from the Python library with my scant knowledge of Python, so this would be very helpful. Thanks in advance.

Button SHIM’s buttons are connected to a TCA9554A, along with a single APA102 LED.

You can find the datasheet for the former here:

The clock and data pins on the APA are bits 7 and 6 of the output registers.

The Python library queues up the various different states the register has to be in to successfully generate an APA102 update packet, and sends them one-by-one. Briefly you only need:

0b00000000 # Start

0b11101111 # First 4 bits are the SOF, last 5 bytes are the brightness (0-31)
0b11111111 # Blue LED
0b11111111 # Green LED
0b11111111 # Red LED

0b00000000 # Latch

I wont give you much more than that- since driving the LED through the IC while also reading the buttons is a fun little challenge!

1 Like

Hi Gadgetoid,
Thank you so much for your help. That’s really useful. However, the APA102 datasheet suggests a different protocol to communicate with the LED (involving 32 0 bits, followed by the data, followed by 32 1 bits) - is there a reason for this?

Also, could you tell me which of the power and earth pins are used by the shim? Since there are two 3.3V pins, I’d like to use the other for something else (ditto with the earth pins).

Yes, you can see the pins that Button SHIM uses here:

This is a great source of nuance about the APA102 pixels: https://cpldcpu.wordpress.com/2014/08/27/apa102/

I’ve never seen any need to include the “End Frame” of 32 1s, it makes no sense from the perspective of the rest of the protocol since a continuous stream of 32 1s is indistinguishable from a full brightness RGB command to an individual LED.

My best guess is that the datasheet is simply wrong, out of date, or - at best - misleading. Given the other nuances I’ve seen with different versions of the APA102 pixels, I wouldn’t be surprised!

Thanks for your help again!

I was doing the soldering today and managed to mess it up completely by soldering the header to the wrong side of the board! Also, my desoldering pump is broken so this is going to be a challenge to correct (I don’t have any braid). Nevertheless, thanks for your help.