0

CPX animations & IR - continuing until signal received?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CPX animations & IR - continuing until signal received?

by gallaugher on Tue Nov 27, 2018 12:17 am

Hi,
I've been trying to extend the neat Adafruit IR ornament:
https://learn.adafruit.com/remote-contr ... nd-express

so that it will also run animations when certain IR codes are sent.
I figured a starting place was to grab code from the Bike Light animations, but if there's a better choice, let me know:
https://learn.adafruit.com/circuit-play ... cuitpython

With my still very-much newbie knowledge of python (I normally code iOS in Swift), I'm struggling to figure out how to get animations that continue until an IR press is received.
The Bike Light code stops animating when a button is pressed
while not buttons_pressed():
I thought I'd replace the code above with a while True: and then "listen" for an IR signal (any signal), and if so, I'd break
However, I can't quite figure out how to keep going in the True loop until an IR signal is detected.
Docs state:
"The decoder class allows you to easily wait for and read a list of pulses from a remote control press"
Is there a way to otherwise listen for a pulse so I can while True: until something is picked up from IR, then break?

I then tried to use the fuzzy_pulse_compare function as part of this Adafruit tutorial:
https://learn.adafruit.com/ir-sensor/circuitpython

But it still doesn't seem to perform a continuous while or give me the background listener I was hoping for. Here's the code, if useful, but it's calibrated for an ELEGOO IR rather than the NEC that Adafruit sells (I have the NEC codes commented out if anyone is ambitious enough to try this on their own).
https://github.com/gallaugher/CPX_IR-An ... mations.py

Any advice is apprecaited. And please correct me if I'm going about this all the wrong way.

Thanks!
John

gallaugher
 
Posts: 83
Joined: Tue Aug 14, 2018 12:42 pm

Re: CPX animations & IR - continuing until signal received?

by tannewt2 on Tue Nov 27, 2018 2:51 pm

Try giving read_pulses blocking=False and then make sure it returns a list. Its source is here: https://github.com/adafruit/Adafruit_Ci ... te.py#L195

~Scott

tannewt2
 
Posts: 981
Joined: Thu Oct 06, 2016 8:48 pm

Re: CPX animations & IR - continuing until signal received?

by RCCHAMP on Sun Feb 17, 2019 3:28 pm

Thanks to the op for bringing this up, as I am having the same issue... I'm using a pro mini to read ir hex code while reading pwm and writing pwm to a servo and push led data to 10 rgbw pixels 6 act on pwm signal in 4 act on ir signal. Am I doing to much?

So I need to go into the library and uncomment use nonblocking? Thanks for the link

RCCHAMP
 
Posts: 1
Joined: Sun Feb 17, 2019 3:19 pm

Re: CPX animations & IR - continuing until signal received?

by kevinjwalters on Sun Feb 17, 2019 9:26 pm

I suspect he was referring to the named parameter to the read_pulses() method which defaults to the blocking=True. Ensure you aren't using an older verison of the library as this only appeared a few months ago, I think. Sometime around late November/December, see improve read_pulses/blocking reliability #18 if you're interested in the detail.

kevinjwalters
 
Posts: 231
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.