Polling inputs

Topics about the Software of Revolution Pi
Post Reply
jbarry
Posts: 4
Joined: 13 Feb 2018, 17:43

Polling inputs

Post by jbarry »

Hello,

I am trying to develop an application that uses both a software and hardware setup to control my system. What I need to figure out is how I can setup 3 momentary switches on three separate input pins so that when I press the button it will turn off specific output pins. I need to also turn the same output pin on/off through a GUI. Is there a way to poll the inputs using an interrupt? If not how can I achieve this?

Thanks,

jbarry
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: Polling inputs

Post by volker »

jbarry,
polling and interrupt are two different methods to monitor Inputs. Our modular system with DIO modules connected to a Core does not have interrupts like GPIOs. But you can and need to poll the inputs. The input state of all inputs can be found in what we call the "central process image". That is a part of the RevPi Core's memory which is structured by the configuration (using the PiCtory tool) and controlled by the Kernel driver PiControl. You need to poll this memory using simple Linux file access methods (open driver, seek to the offset of the input byte and then read the byte). There is a python library which wraps these generic access method which is written by our user Sven (see his blog "revpidmodio"). With this library you get also event driven IO (although internally it also uses polling).
So you poll the input bit of your momentary switch, program a flip-flop type function to toggle the output and if you want to use a GUI switch in parallel you just kind of "or-ing" the input bit with the GUI button.
If this sounds all like a lot of bushwa to you then I suggest you start watching and reading the tutorials and get a good book about "physical computing". If you got what I was talking about and need further explanation of details then please ask more specific and I'll try to explain...
Unser RevPi Motto: Don't just claim it - make it!
jbarry
Posts: 4
Joined: 13 Feb 2018, 17:43

Re: Polling inputs

Post by jbarry »

can you post a link to his blog?
digohm
Posts: 35
Joined: 10 Aug 2017, 23:00

Re: Polling inputs

Post by digohm »

Post Reply