vjou
February 18, 2018, 5:06am
1
Inky pHAT is really impressive. I’ve just started playing with this and CS pin assignment in the python code is puzzling me.
From pinout.xyz, Inky pHAT’s CS pin is BCM 8.
But, in “inky212x104.py”, the CS pin sounds like BCM 0.
Please tell me which pin is for the CS. I believe it is BCM 8, as BCM 0 seems reserved for ID EEPROM. I may be misunderstanding the python code. If so, please tell me how I am wrong about the code.
Thank you
This is slightly confusing because the CS0_PIN
constant in the Inky pHAT library actually refers to the value passed directly into SPI’s Open method.
See:
def __init__(self, resolution=(104, 212), cs_pin=CS0_PIN, dc_pin=DC_PIN, reset_pin=RESET_PIN, busy_pin=BUSY_PIN, h_flip=False, v_flip=False):
self.resolution = resolution
self.width, self.height = resolution
self.buffer = numpy.zeros((self.height, self.width), dtype=numpy.uint8)
self.dc_pin = dc_pin
self.reset_pin = reset_pin
self.busy_pin = busy_pin
self.cs_pin = cs_pin
self.h_flip = h_flip
self.v_flip = v_flip
self.update_x1 = 0
self.update_x2 = self.width
self.update_y1 = 0
self.update_y2 = self.height
self.partial_mode = False
self.partial_config = []
then:
self.set_version(1)
self.palette = (BLACK, WHITE, RED)
elif GPIO.input(self.busy_pin) == 0:
self.set_version(2)
self.palette = (WHITE, BLACK, RED)
else:
self.set_version(2)
self.palette = (WHITE, BLACK, RED)
self._spi = spidev.SpiDev()
self._spi.open(0, self.cs_pin)
self._spi.max_speed_hz = 488000
atexit.register(self._display_exit)
def set_version(self, version):
if version not in (1, 2):
raise ValueError("Version {} is not valid!".format(version))
self.inky_version = version
So the 0
is actually CE0
not BCM0
, and CE0
is on BCM8
.
This could probably stand to be documented better in the library itself!
vjou
February 18, 2018, 6:43pm
3
That explains clearly. I should have dug the code a little more.
Thank you!
No problem! You’re welcome.