element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Piface CAD - Event/Interrupt for keys
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 8 replies
  • Answers 1 answer
  • Subscribers 666 subscribers
  • Views 1031 views
  • Users 0 members are here
  • pifacecad
  • piface_control_and_display
  • raspberry_pi
  • events
  • raspeberry_pi_accessories
  • piface_control_&_display
  • piface_control&display
  • piface_control
  • piface
Related

Piface CAD - Event/Interrupt for keys

Former Member
Former Member over 11 years ago

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!

 

 

 

xylo

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 11 years ago

    Could you try the following test code?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 11 years ago

    Could you try the following test code?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Hi Andrew

    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...

     

    Regards,

     

    Tim

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Hello again

     

    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!

     

     

    Cheers,

     

    Tim

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    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....

     

     

     

    Kind Regards,

     

    Tim

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    The interrupts are handled using Python's multiprocessing and threading libraries. IDLE has some problems working with these, we've found.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • pkilcoyne
    0 pkilcoyne over 9 years ago in reply to Former Member

    Hi there,

    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

    import pifacecad

     

    cad = pifacecad.PiFaceCAD()

    listener = pifacecad.SwitchEventListener(cad)

     

    def button_pressed(event):

            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)

     

    listener.activate()

     

    ***********

     

    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?

     

    Thank you,

     

    Paul

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • smile123
    0 smile123 over 7 years ago in reply to pkilcoyne

    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.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube