cyborg5 / IRLib2

Library for receiving, decoding, and sending infrared signals using Arduino
GNU General Public License v3.0
384 stars 138 forks source link

Problem in IRLib_P01_NEC.h not setting the modulation frequency correctly #57

Open hiduino opened 5 years ago

hiduino commented 5 years ago

The definition to pass the frequency from IRLibCombo.h send case statement is using 'khz' parameter. public: void send(uint8_t protocolNum, uint32_t data, uint16_t data2=0, uint8_t khz=38) { if(khz==0)khz=38; switch(protocolNum) { IR_SEND_PROTOCOL_01

However, the IRLib_P01_NEC.h is using 'data2' which is passing the wrong parameter for frequency. #define IR_SEND_PROTOCOL_01 case 1: if(data2==0)data2=38;IRsendNEC::send(data,data2); break;

This should be changed to: #define IR_SEND_PROTOCOL_01 case 1: if(khz==0)khz=38;IRsendNEC::send(data,khz); break;

FidgetyRat commented 5 years ago

I concur with @hiduino. Until I found this post, I spent two days fighting what I thought was a hardware issue as my television was intermittently receiving codes I sent. My code is using the IRLibCombo send method with 3 paramters, the protocol, code, and number of bits as my device handles multiple protocols at the same time.

With the above bug, when the # of bits is supplied for an NEC code (32) it overrides the frequency to 32 khz instead of 38 khz. The result was that my television had a weak response to codes which sometimes were skipped altogether.

With the corrections above, my device now has complete reliability in transmitting codes.