piface / pifacedigitalio Goto Github PK
View Code? Open in Web Editor NEWThe PiFace Digital input/output module.
License: GNU General Public License v3.0
The PiFace Digital input/output module.
License: GNU General Public License v3.0
I noticed that the indicator LED goes on/off but the relay itself doesn't.
If I slap the raspberry pi box it turns off. It seems to be a physical issue but I already tested all the other 3 pifaces i have and they behave the same way.
Have someone faced this issue before?
Setup: Raspberry 2 and Piface Digital 2
Hi,
I think I may have a problem with pifacedigitalio, but I'm not sure. I have a RPi Model B, all the latest updates, with 2 PiFaces connected via a PiRack. I have 8 door sensor switches connected to the 8 inputs on first PiFace, and an event handler defined to track door opens/closes. The 2nd PiFace has 2 motion sensors connected and a relay that trips when my house power goes out, connected to the inputs. I have separate event handlers for the door sensors, the 2 motion sensors and another one for the power-out relay. When I run my Python app it all works perfectly - door opens/closes get logged, motions and power outages get detected, etc. However, when I let everything run overnight at some point both of the event handlers (motion & power) for the 2nd PiFace stop working (the door interrupts on the 1st PiFace continue to work with no problem) and the events are no longer detected. I thought it might be a bug in my Python event handler code, so I left it running in a console window and no exceptions were displayed. If I interrupt the program and restart it everything works again, which makes me tend to think it's a sw problem, but I'm not sure how to verify.
Is there any way I can regularly check the status of the event handlers in my program to verify they are still active?
Thanks.
John
Hi all
I am VERY new to Raspberry pi and linux in general, so please excuse the noob questions.
I have followed the Piface Digital 2 installation instructions to the letter, however receive an interrupt error on line 213 of the Interrupts.py script when I try to run the blink.py script. I am using python 2 by default, but have tried to run the blink.py script under both python 2 and 3. I have attached response in both versions.
At first I thought the problem may relate to the SPI driver, but I have enabled the port and tested it by bridging the MOSI and MISO pins and running spidev_test.c. I receive the correct response.
python 2
python 3
Any help would be greatly appreciated.
Kind regards
Simon
What's a good way to do a software de-bounce when using interrupts on the PiFace? I've tried with just a sleep in the interrupt routine, hoping it would just pause that thread/process and then do another evaluation after the sleep. It didn't work that well though, sometimes it misses interrupts because of this (like if the return to 0 is within my 100ms sleep then I won't get another interrupt to indicate that the pin is now 0, even if the previous interrupt was 1.
I have a fresh install on my Pi and I cannot get the interupt code working i run
sudo python3 presslights.py
it just sits there and doesn't respond to switch presses. I have tried other example code and I get nothing on any of the interupts that I've tried.
I have no idea what the problem is, eventually i press ctrl-x-c and get
^X^CException KeyboardInterrupt: KeyboardInterrupt() in <module 'threading' from '/usr/lib/python3.2/threading.py'> ignored
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.2/multiprocessing/process.py", line 267, in _bootstrap
self.run()
File "/usr/lib/python3.2/multiprocessing/process.py", line 116, in run
self._target(_self._args, *_self._kwargs)
File "/usr/local/lib/python3.2/dist-packages/pifacecommon/interrupts.py", line 160, in watch_port_events
events = epoll.poll()
KeyboardInterrupt
Please help as I've just bought 5 pi faces for some school projects.
Thanks
Martyn
Hi all,
I am having a problem with interrupts when using multiple PiFace boards. I have a Model A Pi connected to multiple PiFace boards via a PiFace Rack.
If I have only 1 PiFace connected I can receive interrupts fine. Once I connect a second PiFace with different hardware address my interrupts are no longer received.
I have tried receiving interrupts using pifacecommon and pifacedigitalio methods.
pifacedigitalio test code is as follows
import pifacedigitalio as p
import pifacedigitalio.version as pfdioV
import pifacecommon.version as pfcV
import time
quit = False
def print_flag(event):
print("You pressed button ", event.pin_num)
def stop_listening(event):
global quit
quit = True
p.init()
print("pifacedigitalio version = ", pfdioV.__version__)
print("pifacecommon version = ", pfcV.__version__)
pfd = p.PiFaceDigital(0)
l = p.InputEventListener(pfd)
l.register(0, p.IODIR_OFF, print_flag)
l.register(1, p.IODIR_OFF, print_flag)
l.register(2, p.IODIR_OFF, print_flag)
l.register(3, p.IODIR_OFF, stop_listening)
l.activate()
while not quit:
time.sleep(1)
l.deactivate()
pifacecommon test code is
import pifacecommon.core
import pifacecommon.interrupts
import pifacecommon.mcp23s17
import time
quit = False
def print_flag(event):
print("You pressed button ", event.pin_num)
def stop_listening(event):
global quit
quit = True
port = pifacecommon.mcp23s17.GPIOB
chip = pifacecommon.mcp23s17.MCP23S17()
listener = pifacecommon.interrupts.PortEventListener(chip=chip, port=port)
listener.register(0, pifacecommon.interrupts.IODIR_FALLING_EDGE, print_flag)
listener.register(1, pifacecommon.interrupts.IODIR_FALLING_EDGE, print_flag)
listener.register(2, pifacecommon.interrupts.IODIR_FALLING_EDGE, print_flag)
listener.register(3, pifacecommon.interrupts.IODIR_FALLING_EDGE, stop_listening)
listener.activate()
while not quit:
time.sleep(1)
listener.deactivate()
Not sure if I am missing something or if there is an issue. I have tried on multiple PIs using multiple PiFaces.
Could it be changed so we can pass an init_board param:
listener = pifacedigitalio.InputEventListener(init_board=False)
Thanks!
This package does not load when you try to use it because asm_generic_ioctl is missing from the list of modules in setup.py so it does not get installed.
Also, README.md should say "sudo python3 setup.py install".
There seems to be a problem with simple InputEventListener.
The emulator works as well as output pins and input pins.
After trying several programs, I attempted the examples.
Blink works, presslights does not, whackamole does partially.
Two boards and 3 SD cards have been tried, with update and upgrade following instructions.
Have I missed something?
Additional information has been observed.
When rebooting, an error flashes by which says:
"Error loading module spi-bcm 2708 no such module."
lsmod shows: spi_bcm2835 4253 0
also shows: snd_bcm2835 19761 6
/lib/modules/4.0.8-v7+/kernel/drivers/spi/ has two files: spi-bcm2708.ko and spi-bcm2835.ko
The actual device shows to be bcm2709.
Thanks for any help on resolved the interrupt issue, which appears to be related to the bcm module
Tried to install 3.0.0 using pip from PYPI. The tarball on PYPI is missing files required by setup.py. These files are in github, but missing from the tarball.
README.md
CHANGELOG
etc ...
digital_write_pullup() does not work because it calls read_pullup() which is a typo. Should be read_pullups(). Same bug exists in the github piface repo.
Need a little more documentation on the pullup stuff. E.g. what is the default setting? Can you pull up, pull down, or leave floating?
You can find it here if it will help your users.
Hey,
does anyone know how to turn a relay on or off using the simplewebcontrol script?
There seems to be a problem with simple InputEventListener.
The emulator works as well as output pins and input pins.
After trying several programs, I attempted the examples.
Blink works, presslights does not, whackamole does.
Two boards and 3 SD cards have been tried, with update and upgrade.
Have I missed something?
Thanks
According to The Hitchiker's Guide, PyPi is the right solution to distribute Python software as it is cross-platform (many Linuxes, macOS and Windows I think).
GitHub supports Travis CI to automatically test and deploy (push to PyPi) software, which is something pifacedigitalio and friends require. With this change, bug fixes and improvements in the form of Pull Requests can reach users without too much intervention.
Tasks include:
"Provides common I/O methods for interfacing with PiFace Products" is for pifacecommon.
Evening folks,
I recently got my hands on a PiFace Digital 2, however, I'm struggling to make my Raspberry detect it.
Following the instructions found on the official page, I started by installing the latest Rasbian Stretch Lite and getting everything up to date:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
I enabled SPI using raspi-config and downloaded the necessary modules with pip, since they weren't in the repositories anymore:
sudo pip3 install pifacedigitalio
sudo pip3 install pifacecommon
Full of hope, I started a Python3 session and wrote the commands found on this page:
import pifacedigitalio
pfd = pifacedigitalio.PiFaceDigital()
For my efforts however, I was awarded with this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/pifacedigitalio/core.py", line 82, in __init__self.init_board()
File "/usr/local/lib/python3.5/dist-packages/pifacedigitalio/core.py", line 107, in init_board
h=self.hardware_addr, b=self.bus, c=self.chip_select))pifacedigitalio.core.NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).
Thus, I've found a bunch of people with the same problem but no solution. I've double checked everything a few times and made sure SPI is enabled. Any suggestions?
My piface was working. Then I dropped my motor and cables were disconnected from one of the 2 relays on the board. Now I can't seem to control my board. I use the emulator but it seems to have no effect on my outputs. No LEDs light up on demand anymore. Is there a way to determine if my board is ruined?.... A way to test it besides the emulator / Python.
So i created a fairly simple python program counting pulses using interrupts and i tested it on the bench with a single input for a couple of days and everything seemed to work well, when i started to use it for real i had 5 inputs and the pulse frequency was a bit higher, after around 22 hours the counting would stop. When i looked into why it could see that Python3 memory use was going up and up everytime a pulse was counted. The first thing i did was to create a test program that only counted and the problem persists with the pi eventually giving the error Cannot Allocate Memory - my test code is here;
def testcount(event):
global Count1
Count1 += 1
print(Count1)
pifacedigital = pifacedigitalio.PiFaceDigital()
listener = pifacedigitalio.InputEventListener(chip=pifacedigital)
listener.register(0, pifacedigitalio.IODIR_RISING_EDGE, testcount)
listener.activate()
Here is a screen shot of the pi back on the bench showing the memory use rising. it only rises when a pulse is received
Just started a new install of Stretch. I could not load through apt-get tried pip3. Pip3 said it was ok.
This is the error that I got
Traceback (most recent call last):
File "facke_bubble1.py", line 3, in
import pifacedigitalio
File "/usr/local/lib/python3.5/dist-packages/pifacedigitalio/init.py", line 18, in
from pifacecommon.interrupts import (
ImportError: No module named 'pifacecommon'
I have three PiFaces connected to a PiRack, which work well with python3 commands of the type p.digital_write(0,1,2) to switch on LED 0 on Board 2. I have downloaded the newest version of the Emulator (my RPi says it's the newest version), but this does not look like the picture of one as shown in the PiFace Guide; mine does not have the "View" option, so I cannot select which Board number I wish to address. Is there something else I need to do?
Similarly, I want to use these PiFaces with Scratch. I have carried out all the Guide instructions to enable Scratch to be used with the PiFace, but my version of Scratch does not produce the option to “Host Mesh” or “Join Mesh” when I shift-click the Share option. Instead I get “Stop Hosting Mesh” so, again, I assume I have an earlier version of Scratch, even though the RPi assures me I have the newest version. I cannot therefore configure the control instructions to talk to the PiFace at all (not even to Board 0) . Could someone please tell me what to try next?
I bought all new and tried to run some sample code.
But the board will not be found not under X nor on the
console. I've tried python and ruby as well.
The python output is
root@raspberrypi:/home/pi# python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pifacedigitalio as pfio;
>>> pfio.init();
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pifacedigitalio/core.py", line 166, in init
raise failed_boards[0]
pifacedigitalio.core.NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).
>>>
any ideas?
root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 3.18.5-v7+ #225 SMP PREEMPT Fri Jan 30 18:53:55 GMT 2015 armv7l GNU/Linux
root@raspberrypi:/home/pi# dpkg -l | grep pif
ii python-pifacecommon 4.0.0-1 all The PiFace common functions module.
ii python-pifacedigitalio 3.0.4-1 all The PiFace Digital I/O module.
ii python3-pifacecommon 4.0.0-1 all The PiFace common functions module.
ii python3-pifacedigital-scratch-handler 2.0.5-1 all The PiFace Digital Scratch Handler.
ii python3-pifacedigitalio 3.0.4-1 all The PiFace Digital I/O module.
root@raspberrypi:/home/pi# gem list
*** LOCAL GEMS ***
ffi (1.9.6)
piface (0.4.1)
The incompatibility with Python 3 is mostly due to the print function. We can use:
from __future__ import print_function
which will allow us to use the print function in Python 2.7.
Will need to check for other incompatibilities first.
Hi, I've bought https://wiki.geekworm.com/Raspberry_Pi_DIDO_Board , could you help me about https://ae01.alicdn.com/kf/H1af968b7b7ec4bce83c5e4152c6be2b2z.jpg connections schema?
Thank you so much
I had the problem that the HTTPRequest node (a HTTP client) from the godot engine doesn't handle the JSON content from the simplewebcontrol server example (examples/simplewebcontrol.py). The JSON content was always discarded. I have to add the Content-length property to the header at the simplewebcontrol example. I think this changes could also increase the compatibility of other HTTP clients and browsers. The pull request #42 adds the necessary changes.
Line 5 in examples starts off with board1. Very confusing to noob, as factory setting is board0, ,and most noobs will only have one board. Have seen complaints about this elsewhere. Knew it was a doc problem, since Pi face worked on pfio under Python 2.7
http://piface.github.io/pifacedigitalio/example.html#interrupts
When un-pressing switch 0, the event information reports:
Flag: 0b00000001
Capture: 0b11111110
Pin num: 0
Direction: 1
Which should actually be:
Flag: 0b00000001
Capture: 0b11111111
Pin num: 0
Direction: 1
Since the input port has been returned to it's original state.
Perhaps this example should be rewritten so that it's about pressing switch 0 instead.
Use the record
flag to track which files are installed.
$ sudo python3 setup.py install --record installedfiles.txt
Create an uninstall.sh script.
This should really be in the FAQ! I'm building a time-based code-lock with PiFace and an RPi (code will be published with a FL license, not to worry!), and because codes are time-critical I'd like a real-time clock. If I know for a fact that the RTC from PiFace is compatible with the Piface DIO board, I'll buy that, but I can't find mention of that in the RTC docs or on either issue tracker. It seems a strange omission..
Thanks!
Any reads from the piface chip are all returning 0. I don’t know if it’s a kernel issue or what.
Has this been tested on Buster?
OS Version: | Raspbian GNU/Linux 10 (buster)
Kernel Version: | 4.19.66-v7+
hello,
i've just re-install my piface and so upgrade to the 3.0.5 version.
but i was using the command : pfio.read_output() and it's not working anymore.
how can i know now the status of all my outputs?
thanks for help.
ps: excuse my english, i'm french
Hej
I am trying to exit my Python program when pressing a Button from the PiFace. A Event Listener is used, like described at the examples. It seems that "listener.deactivate()" makes a join on active thread. If it is the main thread of the process it fails and lead to a python hang up.
I attach a demo code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on 03.04.2015
@author: stj
'''
import os
import sys
import distutils.spawn
import pifacecad
import time
def checkExecutableProgram(program):
print('check '+program)
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
print(' is executable')
return exe_file
return None
def getExecutableFileList (searchPath, extra=['py']):
print('crawl '+searchPath)
pL = []
for (dirpath, dirnames, filenames) in os.walk(searchPath):
for f in filenames:
# if (f.endswith('py') is True) or (checkExecutableProgram(f) is not None):
#if (f.endswith('py') is True):
if (checkExecutableProgram(f) is not None):
pL.append(os.path.join(dirpath,f))
return pL
def printToLCD(line1, line2):
global cad
prtStr = line1 + '\n' + line2
cad.lcd.clear()
cad.lcd.write(prtStr)
def updateDisplayFiles():
global gIndx
global gFL
global gFLlen
if gIndx < 0:
printToLCD('<none>','<none>')
return
l1 = '> ' + gFL[gIndx]
l2 = '<none>' if (gIndx+1 >= gFLlen) else gFL[gIndx+1]
printToLCD(l1,l2)
def moveUp(e):
global gIndx
if gIndx > 0:
gIndx -= 1
updateDisplayFiles()
def moveDown (e):
global gIndx
if gIndx < gFLlen-1:
gIndx += 1
else:
gIndx = gFLlen - 1
updateDisplayFiles()
def execute(e):
global gIndx
if gIndx < 0:
printToLCD('nothing to execute','')
else:
printToLCD('execute','wait ...')
os.system( gFL[gIndx])
#execfile(gFL[gIndx] , {} )
printToLCD('finished','')
def printEvent(e):
print(e)
def exitCB (e):
global listener
listener.deactivate()
sys.exit(0)
if __name__ == '__main__':
global cad
global listener
global actionHandler
cad = None
listener = None
gFL = getExecutableFileList(os.path.expanduser("~"))
gFLlen = len(gFL)
gIndx = -1 if gFLlen < 1 else 0
actionHandler ={
6 : moveUp,
7 : moveDown,
5 : execute,
4 : exitCB
}
cad = pifacecad.PiFaceCAD()
cad.lcd.backlight_on()
printToLCD('starter v.1.0', 'select file')
time.sleep(2)
updateDisplayFiles()
try:
listener = pifacecad.SwitchEventListener(chip=cad)
for i in range(8):
h = actionHandler.get(i, printEvent)
listener.register(i, pifacecad.IODIR_FALLING_EDGE, h)
listener.activate()
except Exception as e:
print(e)
listener.deactivate()
sys.exit(0)
and the consol error print:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
self.run()
File "/usr/lib/python3.2/threading.py", line 693, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/pifacecommon/interrupts.py", line 339, in handle_events
function(event)
File "stjStarter.py", line 99, in exitCB
listener.deactivate()
File "/usr/lib/python3/dist-packages/pifacecommon/interrupts.py", line 220, in deactivate
self.dispatcher.join()
File "/usr/lib/python3.2/threading.py", line 844, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
pifacedigitalio v2 requires pifacecommon v2 but the installer only checks for any version of pifacecommon.
Packages and modules should contain version numbers so that this is detected and the correct dependency versions are installed.
A temporary fix is to install pifacecommon manually from: github.com/piface/pifacecommon
The InputEventListener.register
function should have a flag to optionally send events to callback functions.
import pifacedigitalio
def somefunction():
"""This function has no event argument."""
pass
listener = pifacedigitalio.InputEventListener()
l.register(0, p.IODIR_DIR, somefunction, send_event=False)
l.activate()
somefunction
is not passed an event object because send_event
was set to False in the register function. send_event
will default to True.
I'm not sure whether this should be implemented or not because it allows programmers to be inconsistent in callback definitions and you can just ignore the event anyway.
It is useful for directly calling existing library functions, that don't accept event objects. For example:
import robot
listener = pifacedigitalio.InputEventListener()
l.register(0, p.IODIR_DIR, robot.walk, send_event=False)
l.activate()
robot.walk()
is not expecting any event objects so we do not send it any. Currently this can be wrapped up with:
import robot
def do_robot_walk(event):
robot.walk()
listener = pifacedigitalio.InputEventListener()
l.register(0, p.IODIR_DIR, do_robot_walk)
l.activate()
Hello,
I need the library Pifacedigitalio for C, Is there any version for this language?
I need to use the InputEventListener function but I can not find any equivalent for C.
Could you help me?
Thank you.
With reference to the sample code
pfd = pifacedigitalio.PiFaceDigital()
has the effect of resetting the pins to default values.
Maybe this is intentional or a bug? I don't know
Anyway, the workaround that I use is the following
pfd = pifacedigitalio.PiFaceDigital(init_board=False)
Note, that the board still needs to be initialised at least once after initial boot.
Having a problem with the installation of piface on a Pi 3
Went through all the steps and get the following form the console
pi@raspberrypi:~ $ sudo apt-get install python{,3}-pifacedigitalio
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pifacedigitalio
E: Unable to locate package python3-pifacedigitalio
Tried cloning and I get the same result.
Hello,
i've just started with the Piface.
I have a PHP code that opens my Python script, this works fine.
And the Python script works on the Raspberry Pi (in the terminal).
But when i place this, in the Python script, the PHP script stops and doesn't do anything :
import pifacedigitalio
pifacedigitalio.init()
Can anyone please help me?
Sorry for my bad english.
Greetings Hendrik
Hi,
I'm having a problem with interrupts. I have a Pi 3 Mod B connected to a PiRack with 3 PiFaces installed; the PiFaces are set to addresses 0, 1 and 2. I installed Raspbian Jessie and all updates plus the pifacedigitalio packages on the Pi, then ran 'sudo apt-get update/upgrade' to update everything. I also ensured the SPI was enabled using raspi-config. The PiRack jumpers are set to external power for all slots, and both the PiRack and the Pi are powered from a common 5V/4A switched power supply. Nothing else is plugged into the Pi (e.g. USB, HDMI, etc.). The SPI jumpers on the PiRack are J1/3/5/7 set to 2-3 and J2/4/6/8 set to 1-2. I modified the blink.py program to test it all out:
from time import sleep
import pifacedigitalio
DELAY = 1.0 # seconds
def int_event0(event):
print('In interrupt event 0: pin - ' + str(event.pin_num) + ', dir - ' + str(event.direction))
def int_event1(event):
print('In interrupt event 1: pin - ' + str(event.pin_num) + ', dir - ' + str(event.direction))
def int_event2(event):
print('In interrupt event 2: pin - ' + str(event.pin_num) + ', dir - ' + str(event.direction))
def main():
pifacedigitalio.init()
pf0 = pifacedigitalio.PiFaceDigital(hardware_addr=0)
listener0 = pifacedigitalio.InputEventListener(chip=pf0)
listener0.register(0, pifacedigitalio.IODIR_FALLING_EDGE, int_event0, settle_time=0.1)
listener0.register(1, pifacedigitalio.IODIR_FALLING_EDGE, int_event0, settle_time=0.1)
listener0.register(2, pifacedigitalio.IODIR_FALLING_EDGE, int_event0, settle_time=0.1)
listener0.register(3, pifacedigitalio.IODIR_FALLING_EDGE, int_event0, settle_time=0.1)
listener0.activate()
pf1 = pifacedigitalio.PiFaceDigital(hardware_addr=1)
listener1 = pifacedigitalio.InputEventListener(chip=pf1)
listener1.register(0, pifacedigitalio.IODIR_FALLING_EDGE, int_event1, settle_time=0.1)
listener1.register(1, pifacedigitalio.IODIR_FALLING_EDGE, int_event1, settle_time=0.1)
listener1.register(2, pifacedigitalio.IODIR_FALLING_EDGE, int_event1, settle_time=0.1)
listener1.register(3, pifacedigitalio.IODIR_FALLING_EDGE, int_event1, settle_time=0.1)
listener1.activate()
pf2 = pifacedigitalio.PiFaceDigital(hardware_addr=2)
listener2 = pifacedigitalio.InputEventListener(chip=pf2)
listener2.register(0, pifacedigitalio.IODIR_FALLING_EDGE, int_event2, settle_time=0.1)
listener2.register(1, pifacedigitalio.IODIR_FALLING_EDGE, int_event2, settle_time=0.1)
listener2.register(2, pifacedigitalio.IODIR_FALLING_EDGE, int_event2, settle_time=0.1)
listener2.register(3, pifacedigitalio.IODIR_FALLING_EDGE, int_event2, settle_time=0.1)
listener2.activate()
while True:
pf0.leds[7].toggle()
pf1.leds[7].toggle()
pf2.leds[7].toggle()
sleep(DELAY)
if name == "main":
main()
When I run it as 'sudo python3 blink.py' the LEDs on all 3 PiFaces start blinking, but when I press any of the 4 buttons on the PiFaces (which should generate interrupts) nothing happens. Any suggestions?
Thanks
Hello,
I am having trouble getting the simple listener examples to work. I am using latest version of Raspbian on an original Raspberry Pi board with the original (version 1?) of the piface, with Python 3.
The piface emulator works just fine on inputs and outputs, and simple input and output examples work fine as well, so I know that the code is communicating with the piface board:
import pifacedigitalio
pfd = pifacedigitalio.PiFaceDigital() # creates a PiFace Digtal object
pfd.leds[1].turn_on() # turn on/set high the second LED
print(pfd.input_pins[0].value)
0
The last statement properly prints a 1 when run while the input 0 switch is pressed.
However, when I try the following listener example, nothing works when input 0 switch is pressed:
import pifacedigitalio
def toggle_led0(event):
... event.chip.leds[0].toggle()
...
pifacedigital = pifacedigitalio.PiFaceDigital()
listener = pifacedigitalio.InputEventListener(chip=pifacedigital)
listener.register(0, pifacedigitalio.IODIR_FALLING_EDGE, toggle_led0)
listener.activate()
Have googled this and been unable to come up with anything. Do I need to explicitly enable interrupts or some other feature? Would really appreciate some help with this. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.