diff --git a/IRLibProtocols/IRLibCombo.h b/IRLibProtocols/IRLibCombo.h index 91c32f0..3e3a6df 100644 --- a/IRLibProtocols/IRLibCombo.h +++ b/IRLibProtocols/IRLibCombo.h @@ -117,6 +117,12 @@ #define PV_IR_DECODE_PROTOCOL_14 #define PV_IR_SEND_PROTOCOL_14 #endif +#ifndef IRLIB_PROTOCOL_15_H + #define IR_SEND_PROTOCOL_15 + #define IR_DECODE_PROTOCOL_15 + #define PV_IR_DECODE_PROTOCOL_15 + #define PV_IR_SEND_PROTOCOL_15 +#endif //Add additional protocols 15, 16, etc. above. //Note protocol 90- 99 for sample code that will be unsupported in the final version. @@ -160,6 +166,7 @@ class IRdecode: PV_IR_DECODE_PROTOCOL_12 PV_IR_DECODE_PROTOCOL_13 PV_IR_DECODE_PROTOCOL_14 + PV_IR_DECODE_PROTOCOL_15 PV_IR_DECODE_PROTOCOL_90 //Add additional 15, 16 etc. above this PV_IR_DECODE_PROTOCOL_91 PV_IR_DECODE_PROTOCOL_92 @@ -181,6 +188,7 @@ class IRdecode: IR_DECODE_PROTOCOL_12 IR_DECODE_PROTOCOL_13 IR_DECODE_PROTOCOL_14 + IR_DECODE_PROTOCOL_15 IR_DECODE_PROTOCOL_90 //Add additional 15, 16 etc. above this IR_DECODE_PROTOCOL_91 IR_DECODE_PROTOCOL_92 @@ -216,6 +224,7 @@ class IRsend: PV_IR_SEND_PROTOCOL_12 PV_IR_SEND_PROTOCOL_13 PV_IR_SEND_PROTOCOL_14 + PV_IR_SEND_PROTOCOL_15 PV_IR_SEND_PROTOCOL_90 //Add additional 15, 16 etc. above this PV_IR_SEND_PROTOCOL_91 PV_IR_SEND_PROTOCOL_92 @@ -239,6 +248,7 @@ class IRsend: IR_SEND_PROTOCOL_12 IR_SEND_PROTOCOL_13 IR_SEND_PROTOCOL_14 + IR_SEND_PROTOCOL_15 IR_SEND_PROTOCOL_90 //Add additional 15, 16 etc. above this IR_SEND_PROTOCOL_91 IR_SEND_PROTOCOL_92 diff --git a/IRLibProtocols/IRLibProtocols.cpp b/IRLibProtocols/IRLibProtocols.cpp index d7cccb8..64ef8d4 100644 --- a/IRLibProtocols/IRLibProtocols.cpp +++ b/IRLibProtocols/IRLibProtocols.cpp @@ -18,8 +18,8 @@ const __FlashStringHelper *Pnames(uint8_t type) { // You can add additional strings before the entry for hash code. const __FlashStringHelper *Names[LAST_PROTOCOL+1]={ F("Unknown"),F("NEC"),F("Sony"),F("RC5"),F("RC6"),F("Panasonic Old"),F("JVC"), - F("NECx"),F("Samsung36"),F("G.I.Cable"),F("DirecTV"),F("rcmm"),F("CYKM") - //,F("Additional_13")//expand or edit these + F("NECx"),F("Samsung36"),F("G.I.Cable"),F("DirecTV"),F("rcmm"),F("CYKM"), + F("BellFibe"),F("RCA")//expand or edit these }; return Names[type]; }; diff --git a/IRLibProtocols/IRLibProtocols.h b/IRLibProtocols/IRLibProtocols.h index 1114316..7a647da 100644 --- a/IRLibProtocols/IRLibProtocols.h +++ b/IRLibProtocols/IRLibProtocols.h @@ -24,9 +24,10 @@ #define DIRECTV 10 #define RCMM 11 #define CYKM 12 -//#define ADDITIONAL_13 13 //add additional protocols here +#define BELLFIBE 13 +#define RCA 14 //#define ADDITIONAL_14 14 -#define LAST_PROTOCOL 12 //Be sure to update this when adding protocols +#define LAST_PROTOCOL 14 //Be sure to update this when adding protocols /* * Returns a pointer to a flash stored string that is the name of the protocol received. diff --git a/IRLibProtocols/IRLib_P13_BellFibe.h b/IRLibProtocols/IRLib_P13_BellFibe.h new file mode 100644 index 0000000..aab73fc --- /dev/null +++ b/IRLibProtocols/IRLib_P13_BellFibe.h @@ -0,0 +1,113 @@ +/* IRLib_P13_BellFibe.h + * Part of IRLib2 Library for Arduino receiving, decoding, and sending + * infrared signals. See COPYRIGHT.txt and LICENSE.txt for more information. + */ +/* + * This file implements the protocol used by Bell Fibe slim remote controls + * manufactured by Ruwido. + * + * Note that it is up to the user to implement the 0x00008000 toggle bit + */ +#define RUWIDO_HEAD_MARK 260 +#define RUWIDO_DATA_MARK 90 +#define RUWIDO_ZERO 320 +#define RUWIDO_ONE 480 +#define RUWIDO_TWO 660 +#define RUWIDO_THREE 850 + +#ifndef IRLIB_P13_H +#define IRLIB_PROTOCOL_13_H +#define IR_SEND_PROTOCOL_13 case 13: IRsendBellFibe::send(data); break; +#define IR_DECODE_PROTOCOL_13 if(IRdecodeBellFibe::decode()) return true; +#ifdef IRLIB_HAVE_COMBO + #define PV_IR_DECODE_PROTOCOL_13 ,public virtual IRdecodeBellFibe + #define PV_IR_SEND_PROTOCOL_13 ,public virtual IRsendBellFibe +#else + #define PV_IR_DECODE_PROTOCOL_13 public virtual IRdecodeBellFibe + #define PV_IR_SEND_PROTOCOL_13 public virtual IRsendBellFibe +#endif + +#ifdef IRLIBSENDBASE_H +class IRsendBellFibe: public virtual IRsendBase { + public: + void send(uint32_t data, uint8_t nBits= 32) { + if (nBits==0) nBits=32; + extent=0; + data <<= (32 - nBits); + nBits=nBits/2; + enableIROut(36); + mark(RUWIDO_HEAD_MARK+100); space(RUWIDO_HEAD_MARK);//Send header + for (uint8_t i = 0; i < nBits; i++) { + mark(RUWIDO_DATA_MARK); + switch (data & 0xC0000000UL) {//use the leftmost two bits + case 0x00000000UL: space(RUWIDO_ZERO); break; + case 0x40000000UL: space(RUWIDO_ONE); break; + case 0x80000000UL: space(RUWIDO_TWO); break; + case 0xC0000000UL: space(RUWIDO_THREE); break; + } + data <<= 2; + }; + mark(RUWIDO_DATA_MARK+100); + space(27778-extent); + }; +}; +#endif //IRLIBSENDBASE_H + +#ifdef IRLIBDECODEBASE_H +#define RUWIDO_TOLERANCE 100 +class IRdecodeBellFibe: public virtual IRdecodeBase { + public: + bool decode(void) { + resetDecoder();//This used to be in the receiver getResults. + IRLIB_ATTEMPT_MESSAGE(F("BellFibe")); + + if ( (recvGlobal.decodeLength!=(12+4)) && (recvGlobal.decodeLength!=(24+4)) && (recvGlobal.decodeLength!=(32+4)) ){ + return RAW_COUNT_ERROR; + } + + if (!ignoreHeader) if (!MATCH(recvGlobal.decodeBuffer[1],RUWIDO_HEAD_MARK+60)){ + return HEADER_MARK_ERROR(RUWIDO_HEAD_MARK); + } + + if (!MATCH(recvGlobal.decodeBuffer[2],RUWIDO_ZERO)){ + return HEADER_SPACE_ERROR(RUWIDO_ZERO); + } + + offset=3; uint32_t data=0; + while (offset < (recvGlobal.decodeLength-1)) { + if (!ABS_MATCH(recvGlobal.decodeBuffer[offset],RUWIDO_DATA_MARK,RUWIDO_TOLERANCE)){ + return DATA_MARK_ERROR(RUWIDO_DATA_MARK); + } + offset++; + + if (ABS_MATCH(recvGlobal.decodeBuffer[offset],RUWIDO_ZERO, RUWIDO_TOLERANCE) ) { //Logical "0" + data <<= 2; + } + else if (ABS_MATCH(recvGlobal.decodeBuffer[offset],RUWIDO_ONE, RUWIDO_TOLERANCE) ) { //Logical "1" + data = (data<<2) + 1; + } + else if (ABS_MATCH(recvGlobal.decodeBuffer[offset],RUWIDO_TWO, RUWIDO_TOLERANCE) ) { //Logical "2" + data = (data<<2) + 2; + } + else if (ABS_MATCH(recvGlobal.decodeBuffer[offset],RUWIDO_THREE, RUWIDO_TOLERANCE) ) { //Logical "3" + data = (data<<2) + 3; + } + else { + return DATA_SPACE_ERROR(RUWIDO_ZERO); + } + offset++; + } + if (!MATCH(recvGlobal.decodeBuffer[offset],RUWIDO_DATA_MARK)){ + return DATA_MARK_ERROR(RUWIDO_DATA_MARK); + } + bits = recvGlobal.decodeLength-4;//set bit length + value = data;//put remaining bits in value + protocolNum=BELLFIBE; + return true; + } +}; +#endif //IRLIBDECODEBASE_H + +#define IRLIB_HAVE_COMBO + +#endif //IRLIB_PROTOCOL_13_H diff --git a/IRLibProtocols/IRLib_P14_RCA.h b/IRLibProtocols/IRLib_P14_RCA.h new file mode 100644 index 0000000..2707c41 --- /dev/null +++ b/IRLibProtocols/IRLib_P14_RCA.h @@ -0,0 +1,61 @@ +/* IRLib_P14_RCA.h + * Part of IRLib Library for Arduino receiving, decoding, and sending + * infrared signals. See COPYRIGHT.txt and LICENSE.txt for more information. + */ + +/* + * This is code implements the TV IR codes for an RCA CRCRN04GR remote control. + */ +#define RCA_HEAD_MARK 3950 +#define RCA_HEAD_SPACE 3950 +#define RCA_DATA_MARK 470 +#define RCA_ZERO 1000 +#define RCA_ONE 2020 +#define RCA_TOLERANCE 100 + +#ifndef IRLIB_PROTOCOL_14_H +#define IRLIB_PROTOCOL_14_H +#define IR_SEND_PROTOCOL_14 case 14: IRsendRCA::send(data); break; +#define IR_DECODE_PROTOCOL_14 if(IRdecodeRCA::decode()) return true; +#ifdef IRLIB_HAVE_COMBO + #define PV_IR_DECODE_PROTOCOL_14 ,public virtual IRdecodeRCA + #define PV_IR_SEND_PROTOCOL_14 ,public virtual IRsendRCA +#else + #define PV_IR_DECODE_PROTOCOL_14 public virtual IRdecodeRCA + #define PV_IR_SEND_PROTOCOL_14 public virtual IRsendRCA +#endif + +#ifdef IRLIBSENDBASE_H +class IRsendRCA: public virtual IRsendBase { + public: + void send(uint32_t data, uint8_t kHz=38) { + if (data==REPEAT_CODE) { + sendGeneric(data,24, 0, 0, RCA_DATA_MARK+80, RCA_DATA_MARK+80, RCA_ONE-100, RCA_ZERO-100, kHz, true); + } else { + sendGeneric(data,24, RCA_HEAD_MARK, RCA_HEAD_SPACE, RCA_DATA_MARK+80, RCA_DATA_MARK+80, RCA_ONE-100, + RCA_ZERO-100, kHz, true); + } + }; +}; +#endif //IRLIBSENDBASE_H + +#ifdef IRLIBDECODEBASE_H +class IRdecodeRCA: public virtual IRdecodeBase { + public: + bool decode(void) { + resetDecoder();//This used to be in the receiver getResults. + IRLIB_ATTEMPT_MESSAGE(F("RCA")); + + if ( (recvGlobal.decodeLength!=(52)) && (recvGlobal.decodeLength!=(50)) ){ + return RAW_COUNT_ERROR; + } + + if ( (!decodeGeneric(52, RCA_HEAD_MARK, RCA_HEAD_SPACE, RCA_DATA_MARK , RCA_ONE, RCA_ZERO)) && + (!decodeGeneric(50, 0, 0, RCA_DATA_MARK , RCA_ONE, RCA_ZERO)) ) return false; + + protocolNum=RCA; + return true; + } +}; +#endif //IRLIBDECODEBASE_H +#endif IRLIB_PROTOCOL_14_H