Using multiple InkyPHAT displays with one Pi

Can I use more than one InkyPHAT with one Pi? If so, how do I structure the code to differentiate between the two when I input the message to display?

1 Like

I don’t think so, not easily anyway. Pinout is here, https://pinout.xyz/pinout/inky_phat#
It uses SPI. https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md

I have the mini black hat hack3r, which gives me multiple sets of pinouts. Could they be independently controlled?

I honestly don’t know? How do you differentiate one from the other is the big question?
They both will be using the exact same GPIO pins? I suspect they will just mirror each other and display the same image. There may well be some trickery to do it, its above my meager Linux skills though.

The new Inky library (https://github.com/pimoroni/inky) does permit you to specify an alternate chip-select pin (the pin used by the Pi to signify to Inky pHAT that it’s currently being talked to). I think changing just that would be sufficient to control two Inky pHAT’s, but you could not simply place them onto a Black HAT Hack3r in line and control them individually without either:

a. Physically modifying one of the pHATs to cut the Chip-Select trace and route it to the other CS pin (https://pinout.xyz/pinout/pin26_gpio7)
or
b. Wiring the pHAT with individual strands of jumper jerky making sure to swap the wire to CE0 (BCM8) over to CE1 (BCM7).

You would then need to subclass inky.Inky to talk to your new pHAT:

(note this code is untested and dumped right from my brain into the forum, so use beware :D)

from inky import InkyPHAT, inky

class InkyPHAT2(inky.Inky):
    WIDTH = 212
    HEIGHT = 104

    WHITE = 0
    BLACK = 1
    RED = 2
    YELLOW = 2

    def __init__(self, colour):
        inky.Inky.__init__(
            self,
            cs_pin=7,  # <-- pass in the changed chip-select pin
            resolution=(self.WIDTH, self.HEIGHT),
            colour=colour,
            h_flip=False,
            v_flip=False)

inky1 = InkyPHAT()
inky2 = InkyPHAT2()

And, in theory, you would then be able to control the Inky pHATs individually.

1 Like

This is a great question, I had hoped to have two Inkys connected using the Hat Hack3r

SPI can have multiple devices connected, each device has to use a different chip select pin though. I have three of the 0.96 Color LCD breakouts wired to SPI1. They are on a Proto Board though, which lets me wire each of their CS pins to different GPIO pins.
You can’t do that on a Hat Hacker, you’d have to rewire the chip select pin on the inky itself.

1 Like