1 of 1 people found this helpful
Could you try the following test code?
thanks for this code.
I ran it and got a blank (but backlit) display.
There is no activity.
If I press buttons nothing happens (from the code it looks like I should see stuff on the shell window?)
I ran another app which writes to the lcd and it works, as I said, but no event action...
I'm afraid I can't get this to work and can only assume that either the CAD board or the original PI is faulty in some way.
I don't understand how the low level software interacts with data changes on the GPIO interface from the buttons on the CAD board - I assume they're somehow coded into SPI?
As I said, writing to the display is fine, as is explictly reading the state of the switches. I just can't get the event callback to work at all.
I think I have an early model B - it has 256K RAM - I'm not sure what other info I should look for. I don't really want to send it back just in case, but I don't have access to another PI to see if it's the PI itself.
The OS is the latest Raspbian, updated python etc., including downloading the beautiful soup stuff so the traintimes demo will run.
(Again, this one shows up manchester piccadilly times fine, but you can't change to another station because the buttons don't work...
As a former hardware and software designer I am frustrated with my lack of hardware specific knowledge on this system... but in the first place I kinda expected it to "just work".
Any further pointers would be great - I'd like to interest my children in this but until it interacts I'm not feeling very hopeful to capture their attention!
Hmm - update!
If I do this on the Python3 terminal shell it works OK - my problem is using IDLE3.
I wonder if there is something I've missed in running the apps from the IDE shell?
Sorry I didn't clarify this before....
The interrupts are handled using Python's multiprocessing and threading libraries. IDLE has some problems working with these, we've found.
I'm having the exact same problem as yourself. Just wondering have you found a solution?
Also, I put together the following script:
import time, os
cad = pifacecad.PiFaceCAD()
listener = pifacecad.SwitchEventListener(cad)
print('you pressed', event.pin_num)
listener.register(0, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(1, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(2, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(3, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(4, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(5, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(6, pifacecad.IODIR_FALLING_EDGE, button_pressed)
listener.register(7, pifacecad.IODIR_FALLING_EDGE, button_pressed)
I run it initially, via "python3 myscript.py", and nothing happens when I press switch 1 for example.
I quit the programme via a CTRL C but the next time I run it I get printed to my terminal screen: "you pressed 1"
Does this make sense?
Is this script running as expected?
I have the same problem. Somehow there is no return after pressing a button. Maybe it's because a ran a python script to control an other extension board in the past.
Have you successfully writen a python script supporting the switch event from the PiFace CAD?
I can't get it to work.
The display is fine, and I can poll the state of the switches satisfactorily.
Also no success with infrared events, although again the poll application shows that the receiver is working fine.
I tried running the sample train times and radio application examples, and whilst they show something, there is no way to interact with it since the buttons don;t register.
I was wondering if there was an interrupt not configured somewhere...
I think the syntax I tried is correct (and anyway the example programs run without error)
Any ideas appreciated!