There have been several posts here over the past two years requesting an IR library for receiving/decoding IR signals. Speaking personally, I have a product that is fully ported from Teensy to Photon with the exception of the IR remote functionality.
I know it’s not much, but I’m willing to PayPal $100 in beverage money immediately to the first person to port the IRrecv portion of the IRRemote library (IRsend is already ported).
Half-ported Particle library:
Original Library:
Please, would one of you godly, elite, low level types step in here and do us tinkerers a solid? This would be a powerful and long overdue library to have in the Particle arsenal.
@Jerware, I think I have an approach for porting the entire library using SparkIntervalTimer and the variable frequency PWM capability of the recent firmware. Stay tuned.
@mdoan7 It compiles, but when I press a button on my IR remote there is a ~5 second delay and then this is printed to the terminal:
Attempting NEC decode
Testing mark 50 vs 9000: 136 <= 1 <= 228
Attempting Sony decode
Attempting Sanyo decode
Attempting Mitsubishi decode
Attempting RC5 decode
Attempting RC6 decode
Testing mark 50 vs 2666: 41 <= 1 <= 70
Attempting Panasonic decode
Testing mark 50 vs 3502: 54 <= 1 <= 91
Attempting JVC decode
Testing mark 50 vs 8000: 121 <= 1 <= 203
These prints come from the library. If a signal is properly decoded, it doesn’t continue checking. Thank you for the port attempt though! Any idea what’s causing the delay and decode failure?
@Jerware, @mdoan7 used a Software Timer for sampling the IR input signal. The timer is supposed to fire at 50us intervals. However, Software Timers have a minimum 1ms accuracy so timing will be off.
The port requires a hardware timer implementation and thus why I suggested SparkIntervalTimer. His implementation of the variable frequency PWM for code output looks good though I don’t believe using the Atmel method for turning on and off the PWM output will work as expected. I’ll be working on the library over the weekend.
@peekay123, I’ve been playing with SparkIntervalTimer on another project so swapped it in here. @Jerware, give it a spin. I’m doing this for my own education so it’s a hack. @peekay123 will definitely be the one to use for production.
@mdoan7 Obviously @peekay123 meant to give you kudos, not me! I just tried your latest commit and it works! I’m overjoyed, thank you. The only thing I can’t figure out is how to turn off the debug prints. They’re only supposed to print if DEBUG is defined, and I can’t find a single instance of it being defined anywhere in the sketch or library. Any ideas?
PM me your paypal and I’ll deliver the bounty, as promised.
@Jerware, you are correct! I’ll use @mdoan7 work, add some spit and polish, fix the DEBUG flag thing and prepare everything for publishing on the IDE. Good work @mdoan7
@peekay123, thanks. You were the motivation…err… inspiration. @nrobinson2000 Cool. Mental sims are cool but now I have to get me an IR to play with this myself! @Jerware, debug… try now.