bschwind / ir-slinger

A small C library for sending infrared packets on the Raspberry Pi
The Unlicense
99 stars 30 forks source link

Explanation of Wave_generator.one() method #9

Closed ffleandro closed 7 years ago

ffleandro commented 7 years ago

I've successfully made some small changes in your library to use the native Python client library instead of wrapping the C client in Python.

However I've noticed that pigpio breaks if I send codes larger than 10 bytes. I've then tried to understand your library and was intrigued with the Wave_generator.one() method.

Could you provide a more detailed explanation on the workings of this method? Why does it turn on/off several times during a one. I didn't understand the concept of duty cycle and it's use in this method. Shouldn't it always be on during the provided duration?

Let me know if you want me to make a Pull Request for merging my changes.

bschwind commented 7 years ago

Hi @ffleandro ,

The one here is perhaps unfortunately named, but it means a "logical 1" for the binary signal you're sending. It's a complement to the zero function, which is a logical 0.

With infrared, a 1 is indicated by an infrared pulse turning on and off at (typically) 38Khz. The infrared LED isn't simply turned on, it has to pulse at that particular frequency (called the carrier wave) to be picked up by the receiving device.

I highly recommend watching this video if you want a better understanding of how infrared signals are sent. Hope that helps!

ffleandro commented 7 years ago

Awesome, thanks for the explanation. Watching the video right now.

Would you like to Pull Request the changes regarding the pigpio use in native Python instead of wrapping C code in Python?

bschwind commented 7 years ago

Please also note that I'm not the original author of pyslinger.py and I haven't used it myself so I'm not familiar with any quirks it may possess. @danijelt would be better to talk to regarding that :)

Feel free to submit a pull request though! I'm about to sleep but I can look it over tomorrow or sometime soon.

ffleandro commented 7 years ago

Ok, I've read the original pull request for pyslinger and understood why the C library was used.

Regarding the problems I'm experiencing with large codes, I'll create a new issue for it.