Button Shim and Inky navigation


Greetings all

I am very new to Python and I am still getting to grips with it - I am at a point where I have collected a whole load of phats and hats and I want to start combining them together for projects I have in mind. Right now I really want to get my inkyphat to display a picture when I press one of the buttons on my button shim. I have managed to create suitable artwork for the inky but I am unsure how to write the code to achieve this can anyone help?

Many thanks for any help I did try searching the forums but I failed to find anything that seemed relevant to what I am trying to achieve. If I consider my goal in blocks it would be along the lines of:

-Program starts and Pi displays an image and waits for button press

-user navigates through selection of choices posed by an image displayed on inky

-each choice advances the user through an image based narrative


First place I’d go is here,

And check for conflicts with pins or i2c addresses etc.


will do it for you, even if you don’t own or use a phat Stack.

Keep in mind the refresh rate on the inky on the slow side. It takes a while to update etc. 5 seconds or more I believe.

Once you do the installs for both, have a look at the examples for both.
I would check out the keyboard one for the button shim

Not sure which one fits for the inky


Thanks, I looked at the stack compatibility page but button shim isn’t listed only the touch phat.


Button shim pinout is here, https://pinout.xyz/pinout/button_shim#
I2C address (0x3f) Its linked to from the product page.
Which inky do you have?


I have the inkyphat display.


Inkyphat pinout is here https://pinout.xyz/pinout/inky_phat#
I don’t see any conflicts.


I don’t own either of them so your a bit on your own as far as coding it in python.
Unless somebody else replies.


No I appreciate any help people are kind enough to give! I have found some code online which seems somewhat similar to what I am trying to do thanks for checking with the pinout guide for me.

I’m working with the black and white version of the inky but I ordered a bunch of stuff which includes some of the red versions so I’m keen to work on the problems I’m having with the code.


If your clip and pasting code try to copy it right into an editor like say idle, that should keep the syntax intact. That will cut down on errors. And there is a check module option in the Run menu options in idle.
That will flag a lot of errors like incorrect indents etc. Resist the urge to save it as a text file, you want to save it as a .py file.


Here is the mess of things I’ve made so far…

#!/usr/bin/env python
import time
import subprocess
import signal
from PIL import Image
import sys
import buttonshim
import inky

print(""“Test buttons

Button A

def button_a(button, pressed):
inkyphat.colour = BLACK

Button B

def button_b(button, pressed):
inkyphat.colour = BLACK



If you past your code between 3 ``` and 3 more ` it will be in code tags and keep the indents etc.


On my keyboard its the key just under the esc key with a ~ and a ` on it.