Re: "Latching" variables in function

2014-04-09 Thread alister
On Wed, 09 Apr 2014 08:53:19 -0500, Mark H Harris wrote: > On 4/8/14 3:09 PM, Grawburg wrote: > >> I have a N/O pushbutton that I want to "latch" a value to a variable >> when it's been pressed. >> I need button_value to become '1' when the button is pressed and to >> remain '1' until ... > >> W

Re: "Latching" variables in function

2014-04-09 Thread Mark H Harris
On 4/8/14 3:09 PM, Grawburg wrote: I have a N/O pushbutton that I want to "latch" a value to a variable when it's been pressed. I need button_value to become '1' when the button is pressed and to remain '1' until ... What do I use to 'latch' button_value? Philosophically speaking buttons

Re: "Latching" variables in function

2014-04-09 Thread Tim Chase
On 2014-04-08 16:09, Grawburg wrote: > def button(): >    pushbutton = 0 >   button_value = 0 >    pushbutton=bus.read_byte_data(address,GPIOB) >    if pushbutton > 0: >         button_value = 1 >    return button_value > > I need button_value to become '1' when the button is pressed and to > rema

Re: "Latching" variables in function

2014-04-09 Thread William Ray Wing
On Apr 9, 2014, at 12:35 AM, Terry Reedy wrote: > On 4/8/2014 4:09 PM, Grawburg wrote: >> >> I've probably used the wrong term - I'm thinking of what I do when writing >> PLC code - so I can't find how to do this in my reference books. >> This is part of a project I'm working on with a Raspberr

Re: "Latching" variables in function

2014-04-08 Thread Terry Reedy
On 4/8/2014 4:09 PM, Grawburg wrote: I've probably used the wrong term - I'm thinking of what I do when writing PLC code - so I can't find how to do this in my reference books. This is part of a project I'm working on with a Raspberry Pi and an MCP23017 port expander. I have a N/O pushbutton t

Re: "Latching" variables in function

2014-04-08 Thread Ethan Furman
On 04/08/2014 01:09 PM, Grawburg wrote: I've probably used the wrong term - I'm thinking of what I do when writing PLC code - so I can't find how to do this in my reference books. This is part of a project I'm working on with a Raspberry Pi and an MCP23017 port expander. I have a N/O pushbutto

Re: "Latching" variables in function

2014-04-08 Thread Denis McMahon
On Tue, 08 Apr 2014 16:09:28 -0400, Grawburg wrote: > def button(): >    pushbutton = 0 >   button_value = 0 >    pushbutton=bus.read_byte_data(address,GPIOB) >    if pushbutton > 0: >         button_value = 1 >    return button_value Every time your function is called, you start out with button_