Re: Implementing a multivibrator function with python

2013-11-12 Thread JL
I am actually running python on raspberry pi. The trigger event is a 
button-press.

On Monday, November 11, 2013 6:56:03 PM UTC+8, Dave Angel wrote:
 On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL lightai...@gmail.com 
 
 wrote:
 
  - If the event happens again before the 5secs expire, the high 
 
 duration will be extended by another 5 secs. This works like a 
 
 retriggerable multivibrator for those who are into electronics.
 
 
 
 More precisely a retriggerable monostable multivibrator.
 
 
 
 The question makes little sense unless you're running in an event 
 
 driven environment, such as a gui. Name the environment and somebody 
 
 can probably help.
 
 
 
 -- 
 
 DaveA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a multivibrator function with python

2013-11-12 Thread unknown
On Tue, 12 Nov 2013 06:44:05 -0800, JL wrote:

 I am actually running python on raspberry pi. The trigger event is a
 button-press.
 
 On Monday, November 11, 2013 6:56:03 PM UTC+8, Dave Angel wrote:
 On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL lightai...@gmail.com
 
 wrote:
 
  - If the event happens again before the 5secs expire, the high
 
 duration will be extended by another 5 secs. This works like a
 
 retriggerable multivibrator for those who are into electronics.
 
 
 
 More precisely a retriggerable monostable multivibrator.
 
 
 
 The question makes little sense unless you're running in an event
 
 driven environment, such as a gui. Name the environment and somebody
 
 can probably help.
 
 
 
 --
 
 DaveA

How critical is the output pulse time?
is it a state that can be polled to regularly  changed if the timeout 
has been exceeded or does it need to switch in the background?

if you need to trigger  switch in the background you will probably need 
to start playing with threads or multiprocessing.

greater detail on what you are trying to achieve project wise may assist 
here
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a multivibrator function with python

2013-11-12 Thread Antoon Pardon
Op 12-11-13 15:44, JL schreef:
 I am actually running python on raspberry pi. The trigger event is a 
 button-press.

That doesn't help. What does that button-press cause in terms of the OS. Does
it cause a signal? Does it produce a number of bytes that can be read from
some file like object? Something else?

This is not python specific, the answer to those questions is needed no matter
what language you use to implement your function.

-- 
Antoon Pardon



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a multivibrator function with python

2013-11-12 Thread Joel Goldstick
On Tue, Nov 12, 2013 at 11:37 AM, Antoon Pardon
antoon.par...@rece.vub.ac.be wrote:
 Op 12-11-13 15:44, JL schreef:
 I am actually running python on raspberry pi. The trigger event is a 
 button-press.

 That doesn't help. What does that button-press cause in terms of the OS. Does
 it cause a signal? Does it produce a number of bytes that can be read from
 some file like object? Something else?

 This is not python specific, the answer to those questions is needed no matter
 what language you use to implement your function.

This interests me because I started out in Electrical engineering
school in college.  I'm intrigued by raspberry pi.  I bet you would
find specific answers reading about how the hardware works.  Does
Raspberry pi come with push buttons that are connected to some io
ports or a usb port or a keyboard or?

If there is no physical switch, one of the gui frameworks for python
certainly will have hooks to invoke code when a (virtual) button is
pressed.

Maybe find a Raspberry pi newsgroup?



 --
 Antoon Pardon



 --
 https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Implementing a multivibrator function with python

2013-11-11 Thread JL
I am trying to implement a multivibrator function with python. This is how it 
works; 

- An trigger event happens
- Upon receiving the event, a variable goes high for 5secs, then go low.
- If the event happens again before the 5secs expire, the high duration will be 
extended by another 5 secs. This works like a retriggerable multivibrator for 
those who are into electronics. 

Is there some sample code for this problem or can someone point me to using the 
right library for this feature?

Thank you very much.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a multivibrator function with python

2013-11-11 Thread Dave Angel
On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL lightai...@gmail.com 
wrote:
- If the event happens again before the 5secs expire, the high 
duration will be extended by another 5 secs. This works like a 
retriggerable multivibrator for those who are into electronics.


More precisely a retriggerable monostable multivibrator.

The question makes little sense unless you're running in an event 
driven environment, such as a gui. Name the environment and somebody 
can probably help.


--
DaveA

--
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a multivibrator function with python

2013-11-11 Thread Terry Reedy

On 11/11/2013 4:41 AM, JL wrote:

I am trying to implement a multivibrator function with python. This is how it 
works;

- An trigger event happens
- Upon receiving the event, a variable goes high for 5secs, then go low.
- If the event happens again before the 5secs expire, the high duration will be 
extended by another 5 secs. This works like a retriggerable multivibrator for 
those who are into electronics.

Is there some sample code for this problem or can someone point me to using the 
right library for this feature?


Python 3.4 will have a new asyncio package that includes an event loop 
module. It will be in the forthcoming 3.4.b0 release; it might be in 
3.4.a4 but I have not installed that yet. In any case, I believe it 
should make the above easy.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a multivibrator function with python

2013-11-11 Thread Antoon Pardon
Op 11-11-13 10:41, JL schreef:
 I am trying to implement a multivibrator function with python. This is how it 
 works; 
 
 - An trigger event happens
 - Upon receiving the event, a variable goes high for 5secs, then go low.
 - If the event happens again before the 5secs expire, the high duration will 
 be extended by another 5 secs. This works like a retriggerable multivibrator 
 for those who are into electronics. 
 
 Is there some sample code for this problem or can someone point me to using 
 the right library for this feature?
 
 Thank you very much.
 
The problem is that it depnds on the kind of trigger event. Is it a signal?
Is it a character that arrives through a pipe or socket?

I would take a look at the signal module and see if it can get you started.

-- 
Antoon Pardon
-- 
https://mail.python.org/mailman/listinfo/python-list