Actually, could be it would work,,,,at least the library import works, so worth trying:
-
Install node-red-contrib-python-function (it seems to be newer than the python3 you mentioned)
-
Import and deploy the flow below (NR must in this case run in the same Pi as the piFaceCAD is mounted)
If it works, you should be able to see messages written on the lcd and in the debug window
The simple flow:
[{"id":"13305b2.f5872a5","type":"python-function","z":"ae89c6f4.025a58","name":"","func":"import pifacecad\n\ndef update_pin_text(event):\n event.chip.lcd.set_cursor(13, 0)\n event.chip.lcd.write(str(event.pin_num))\n node.send(\"You pressed button:\"+str(event.pin_num))\n\ncad = pifacecad.PiFaceCAD()\ncad.lcd.write(\"Just a test\")\nlistener = pifacecad.SwitchEventListener(chip=cad)\nfor i in range(8):\n listener.register(i, pifacecad.IODIR_FALLING_EDGE, update_pin_text)\nlistener.activate()\n\nif msg['payload'] == 'abort':\n node.warn('aborting listener')\n listener.deactivate()","outputs":1,"x":740,"y":480,"wires":[["b2d81da9.0f60a"]]},{"id":"28c4c4cf.eb5c6c","type":"inject","z":"ae89c6f4.025a58","name":"","topic":"","payload":"abort","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":480,"wires":[["13305b2.f5872a5"]]},{"id":"b2d81da9.0f60a","type":"debug","z":"ae89c6f4.025a58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":920,"y":480,"wires":[]}]
The python code in the python function node:
import pifacecad
def update_pin_text(event):
event.chip.lcd.set_cursor(13, 0)
event.chip.lcd.write(str(event.pin_num))
node.send("You pressed button:"+str(event.pin_num))
cad = pifacecad.PiFaceCAD()
cad.lcd.write("Just a test")
listener = pifacecad.SwitchEventListener(chip=cad)
for i in range(8):
listener.register(i, pifacecad.IODIR_FALLING_EDGE, update_pin_text)
listener.activate()
if msg['payload'] == 'abort':
node.warn('aborting listener')
listener.deactivate()