Skip to content

Commit

Permalink
narrowed constraints for RC5 RC6
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin committed Feb 10, 2023
1 parent 919ddf8 commit 1750eca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/ReceiveDump/ReceiveDump.ino
Expand Up @@ -56,7 +56,7 @@
*/
#define MARK_EXCESS_MICROS 20 // Adapt it to your IR receiver module. 20 is recommended for the cheap VS1838 modules.

#define RECORD_GAP_MICROS 120000 // Default is 5000. Activate it for some LG air conditioner protocols
//#define RECORD_GAP_MICROS 12000 // Default is 5000. Activate it for some LG air conditioner protocols
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.

#include <IRremote.hpp>
Expand Down
16 changes: 8 additions & 8 deletions src/ir_RC5_RC6.hpp
@@ -1,7 +1,7 @@
/*
* ir_RC5_RC6.hpp
*
* Contains functions for receiving and sending RC5, RC5X Protocols
* Contains functions for receiving and sending RC5, RC5X, RC6 protocols
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
*
Expand Down Expand Up @@ -74,7 +74,7 @@ uint8_t sLastSendToggleValue = 1; // To start first command with toggle 0
// MSB first 1 start bit, 1 field bit, 1 toggle bit + 5 bit address + 6 bit command, no stop bit
// Field bit is 1 for RC5 and inverted 7. command bit for RC5X. That way the first 64 commands of RC5X remain compatible with the original RC5.
// SF TAAA AACC CCCC
// duty factor is 25%,
// IR duty factor is 25%,
//
#define RC5_ADDRESS_BITS 5
#define RC5_COMMAND_BITS 6
Expand All @@ -85,7 +85,7 @@ uint8_t sLastSendToggleValue = 1; // To start first command with toggle 0

#define RC5_UNIT 889 // 32 periods of 36 kHz (888.8888)

#define MIN_RC5_MARKS ((RC5_BITS + 1) / 2) // 7
#define MIN_RC5_MARKS ((RC5_BITS + 1) / 2) // 7. Divided by 2 to handle the bit sequence of 01010101 which gives one mark and space for each 2 bits

#define RC5_DURATION (15L * RC5_UNIT) // 13335
#define RC5_REPEAT_PERIOD (128L * RC5_UNIT) // 113792
Expand Down Expand Up @@ -163,12 +163,12 @@ bool IRrecv::decodeRC5() {
initBiphaselevel(1, RC5_UNIT); // Skip gap space

// Check we have the right amount of data (11 to 26). The +2 is for initial gap and start bit mark.
if (decodedIRData.rawDataPtr->rawlen < MIN_RC5_MARKS + 2 && decodedIRData.rawDataPtr->rawlen > ((2 * RC5_BITS) + 2)) {
if (decodedIRData.rawDataPtr->rawlen < ((RC5_BITS + 1) / 2) + 2 && (RC5_BITS + 2) < decodedIRData.rawDataPtr->rawlen) {
// no debug output, since this check is mainly to determine the received protocol
IR_DEBUG_PRINT(F("RC5: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINTLN(F(" is not between 11 and 26"));
IR_DEBUG_PRINTLN(F(" is not between 9 and 15"));
return false;
}

Expand Down Expand Up @@ -265,7 +265,7 @@ bool IRrecv::decodeRC5() {
#define RC6_ADDRESS_BITS 8
#define RC6_COMMAND_BITS 8

#define RC6_BITS (RC6_LEADING_BIT + RC6_MODE_BITS + RC6_TOGGLE_BIT + RC6_ADDRESS_BITS + RC6_COMMAND_BITS) // 13
#define RC6_BITS (RC6_LEADING_BIT + RC6_MODE_BITS + RC6_TOGGLE_BIT + RC6_ADDRESS_BITS + RC6_COMMAND_BITS) // 21

#define RC6_UNIT 444 // 16 periods of 36 kHz (444.4444)

Expand Down Expand Up @@ -405,11 +405,11 @@ bool IRrecv::decodeRC6() {
uint32_t tDecodedRawData = 0;

// Check we have the right amount of data (). The +3 for initial gap, start bit mark and space
if (decodedIRData.rawDataPtr->rawlen < MIN_RC6_MARKS + 3 && decodedIRData.rawDataPtr->rawlen > ((2 * RC6_BITS) + 3)) {
if (decodedIRData.rawDataPtr->rawlen < MIN_RC6_MARKS + 3 && (RC6_BITS + 3) < decodedIRData.rawDataPtr->rawlen) {
IR_DEBUG_PRINT(F("RC6: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINTLN(F(" is not between 15 and 45"));
IR_DEBUG_PRINTLN(F(" is not between 15 and 25"));
return false;
}

Expand Down

0 comments on commit 1750eca

Please sign in to comment.