From af90f55364a7fcbb5f72d196f09a118077ff0f0e Mon Sep 17 00:00:00 2001 From: dbhaig Date: Thu, 4 Oct 2018 13:47:46 -0400 Subject: [PATCH 1/3] Added protocol for Ruwido slim remote used by Bell Fibe in Canada - protocol is a variant of the RCMM protocol using different mark and space values --- IRLibProtocols/IRLibProtocols.cpp | 4 +- IRLibProtocols/IRLibProtocols.h | 4 +- IRLibProtocols/IRLib_P13_BellFibe.h | 94 +++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 IRLibProtocols/IRLib_P13_BellFibe.h diff --git a/IRLibProtocols/IRLibProtocols.cpp b/IRLibProtocols/IRLibProtocols.cpp index d7cccb8..5ea06fe 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")//expand or edit these }; return Names[type]; }; diff --git a/IRLibProtocols/IRLibProtocols.h b/IRLibProtocols/IRLibProtocols.h index 1114316..ec27872 100644 --- a/IRLibProtocols/IRLibProtocols.h +++ b/IRLibProtocols/IRLibProtocols.h @@ -24,9 +24,9 @@ #define DIRECTV 10 #define RCMM 11 #define CYKM 12 -//#define ADDITIONAL_13 13 //add additional protocols here +#define BELLFIBE 13 //#define ADDITIONAL_14 14 -#define LAST_PROTOCOL 12 //Be sure to update this when adding protocols +#define LAST_PROTOCOL 13 //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..96ad303 --- /dev/null +++ b/IRLibProtocols/IRLib_P13_BellFibe.h @@ -0,0 +1,94 @@ +/* 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. + */ +#define RUWIDO_HEAD_MARK 334 +#define RUWIDO_DATA_MARK 86 +#define RUWIDO_ZERO 360 +#define RUWIDO_ONE 526 +#define RUWIDO_TWO 700 +#define RUWIDO_THREE 865 + +#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= 12) { + if (nBits==0) nBits=12; + extent=0; + data <<= (32 - nBits); + nBits=nBits/2; + enableIROut(36); + mark(RUWIDO_HEAD_MARK); space(RUWIDO_ZERO);//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); + space(27778-extent); + }; +}; +#endif //IRLIBSENDBASE_H + +#ifdef IRLIBDECODEBASE_H +#define RUWIDO_TOLERANCE 80 +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)) 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 From 0904d710dcb69de0f6b4ae80ab29f24999d289ba Mon Sep 17 00:00:00 2001 From: dbhaig Date: Sun, 14 Oct 2018 20:14:15 -0400 Subject: [PATCH 2/3] Modified send routine for BellFibe to send 32 bits --- IRLibProtocols/IRLib_P13_BellFibe.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IRLibProtocols/IRLib_P13_BellFibe.h b/IRLibProtocols/IRLib_P13_BellFibe.h index 96ad303..c6caf4f 100644 --- a/IRLibProtocols/IRLib_P13_BellFibe.h +++ b/IRLibProtocols/IRLib_P13_BellFibe.h @@ -28,8 +28,8 @@ #ifdef IRLIBSENDBASE_H class IRsendBellFibe: public virtual IRsendBase { public: - void send(uint32_t data, uint8_t nBits= 12) { - if (nBits==0) nBits=12; + void send(uint32_t data, uint8_t nBits= 32) { + if (nBits==0) nBits=32; extent=0; data <<= (32 - nBits); nBits=nBits/2; From b0699a025bf26d83ac7d71028bbc3f25a04bc252 Mon Sep 17 00:00:00 2001 From: dbhaig Date: Thu, 25 Oct 2018 22:24:13 -0400 Subject: [PATCH 3/3] Added protocol for Ruwido slim remote control - This protocol is used to control Bell Fibe TV boxes widely available from Bell Canada. --- IRLibProtocols/IRLibProtocols.cpp | 4 +- IRLibProtocols/IRLibProtocols.h | 4 +- IRLibProtocols/IRLib_P13_BellFibe.h | 113 ++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 IRLibProtocols/IRLib_P13_BellFibe.h diff --git a/IRLibProtocols/IRLibProtocols.cpp b/IRLibProtocols/IRLibProtocols.cpp index d7cccb8..5ea06fe 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")//expand or edit these }; return Names[type]; }; diff --git a/IRLibProtocols/IRLibProtocols.h b/IRLibProtocols/IRLibProtocols.h index 1114316..ec27872 100644 --- a/IRLibProtocols/IRLibProtocols.h +++ b/IRLibProtocols/IRLibProtocols.h @@ -24,9 +24,9 @@ #define DIRECTV 10 #define RCMM 11 #define CYKM 12 -//#define ADDITIONAL_13 13 //add additional protocols here +#define BELLFIBE 13 //#define ADDITIONAL_14 14 -#define LAST_PROTOCOL 12 //Be sure to update this when adding protocols +#define LAST_PROTOCOL 13 //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