Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96363
| Subject | Re: RPI.GPIO Help |
|---|---|
| References | <lG5Ax.73238$E26.47630@fx20.iad> <MKhIx.9889$6l6.5720@fx08.iad> <V%EIx.91820$zz6.84582@fx04.iad> |
| From | MRAB <python@mrabarnett.plus.com> |
| Date | 2015-09-11 19:49 +0100 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.379.1441997544.8327.python-list@python.org> (permalink) |
On 2015-09-11 19:24, John McKenzie wrote: > > Hello. > > Thanks to the help of people here and in other newsgroups I seem to have > something working doing the basics. (Buttons work, colours light up > appropriately.) > > When I followed MRAB's instructions and read about scopes of variables > that solved my most recent problem, but it introduced a bug. I think I > fixed the bug but after all my stupid mistakes and forgetfulness that > seems too good to be true. I expect there is a better, more elegant, or > more Pythonic way to do what I did so please feel free to share on the > subject. > > I had a problem where if I pressed a button while the LEDs were already > flashing the colour of that button it would block a new colour from > starting when I pressed a new button. So if the LED strip was red and I > pressed the red button again nothing would happen when I pressed the blue > or yellow button. Similar problem for the other two buttons. > > So inside my callbacks I added this code: > > if colour == 1: > pass > elif colour == 2 or 3: > colour = 1 > > > Now it seems OK from my limited testing. > [snip] "colour == 2 or 3" means the same as "(colour == 2) or 3", where 3 is a true value (zero is a false value; any non-zero number is a true value). What you mean is "colour == 2 or colour == 3". A shorter alternative is "colour in (2, 3)".
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-16 19:40 +0000
Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-08-16 21:15 +0100
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-20 15:12 +0000
Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-08-20 16:45 +0100
Re: RPI.GPIO Help alister <alister.nospam.ware@ntlworld.com> - 2015-08-20 15:54 +0000
Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-20 21:27 -0400
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-28 17:40 +0000
Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-08-28 13:56 -0700
Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-29 14:21 -0400
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-08-31 17:41 +0000
Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-08-31 11:25 -0700
Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-08-31 19:34 +0100
Re: RPI.GPIO Help Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-09-01 10:58 +0200
Re: RPI.GPIO Help Tim Daneliuk <tundra@bogus-city.tundraware.com> - 2015-08-31 14:07 -0500
Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-01 02:08 -0400
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-02 18:50 +0000
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-09 19:03 +0000
Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-09-09 20:29 +0100
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-10 15:56 +0000
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-11 18:24 +0000
Re: RPI.GPIO Help MRAB <python@mrabarnett.plus.com> - 2015-09-11 19:49 +0100
Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-09-11 12:00 -0700
Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-09-11 12:24 -0700
Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-11 21:10 -0400
Re: RPI.GPIO Help John McKenzie <davros@bellaliant.net> - 2015-09-13 06:08 +0000
Re: RPI.GPIO Help Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-13 12:24 -0400
Re: RPI.GPIO Help hakugin.gin@gmail.com - 2015-09-14 05:53 -0700
csiph-web