TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: EWHOLZ
from: ALISTER
date: 2018-02-27 16:13:00
subject: Re: How to use while loop

On Sun, 25 Feb 2018 12:32:49 -0800, ewholz wrote:

> On Sunday, February 25, 2018 at 2:59:35 AM UTC-8, The Natural
> Philosopher wrote:
>> On 25/02/18 08:39, Michael J. Mahon wrote:
>> > Andy Burns  wrote:
>> >> ewholz@gmail.com wrote:
>> >>
>> >>> Do I save anything using interrupt vs. the while loop code?
>> >>
>> >> It depends if the code could do something else useful during the
>> >> 99.99%
>> >> of the time it *isn't* noticing the door become open or closed ...
>> >>
>> >>
>> >>
>> > ...and on how easy, or hard, it is to do that “something else” while
>> > maintaining a polling rate adequate to the application.
>> >
>> Well that is the point of interrupts.
>>
>> Your foreground polling rate then represents how often you want to
>> *know* that it's happened, not how often it HAS happened, or for how
>> long.
>>
>>
>>
>> --
>> "In our post-modern world, climate science is not powerful because it
>> is true: it is true because it is powerful."
>>
>> Lucas Bergkamp
>
> Every One!
> Well thanks for this scholarly reply. I have implemented a test program
> using an interrupt on a GPIO pin - but have noticed that I was getting
> "interrupts" when the door was not being opened or closed. I have since
> discovered (complemnts of the internet) that Linux interrupts here and
> there, and thus may cause the bogus messages I was getting.  The python
> program does take up some resources, but the Pi is used only for door
> open/close events. I have concluded after reading your treatise, that an
> interrupt implementation is not really practical for my "bush league"
> program, and checking, saving, and comparing the newState and lastState
> is plenty good enough.
>
> Thanks for all the replies!
> ewholz

if it is important not to miss an event (Ie the door is opened & closed
before you are able to read it)  you may want to consider adding a latch
of some type (S-r or D type flip flop) to the circuit that you then reset
once the state change has been processed.
This would be the same way a pin change interrupt in a microcontroler
such as an Audrino would normally operate.




--
A journey of a thousand miles begins with a cash advance.

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.