From 6510b2c05c504d60cd49d1a914725d5a368f23ae Mon Sep 17 00:00:00 2001 From: Ken Shirriff Date: Fri, 22 Jan 2010 23:39:46 -0800 Subject: [PATCH] Add Sharp and DISH transmission support. This change is from Todd Treece: http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html?showComment=1264093513759#c3138785324309374640 --- IRremote.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ IRremote.h | 4 +++ IRremoteInt.h | 18 +++++++++++++ 3 files changed, 94 insertions(+) diff --git a/IRremote.cpp b/IRremote.cpp index 236737d..d91fb1b 100644 --- a/IRremote.cpp +++ b/IRremote.cpp @@ -652,3 +652,75 @@ long IRrecv::decodeHash(decode_results *results) { results->decode_type = UNKNOWN; return DECODED; } + +/* Sharp and DISH support by Todd Treece + +The Dish send function needs to be repeated 4 times and the Sharp function +has the necessary repeats built in. I know that it's not consistent, +but I don't have the time to update my code. + +Here are the LIRC files that I found that seem to match the remote codes +from the oscilloscope: + +Sharp LCD TV: +http://lirc.sourceforge.net/remotes/sharp/GA538WJSA + +DISH NETWORK (echostar 301): +http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx + +For the DISH codes, only send the last for characters of the hex. +i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the +linked LIRC file. +*/ + +void IRsend::sendSharp(unsigned long data, int nbits) { + unsigned long invertdata = data ^ SHARP_TOGGLE_MASK; + enableIROut(38); + for (int i = 0; i < nbits; i++) { + if (data & 0x4000) { + mark(SHARP_BIT_MARK); + space(SHARP_ONE_SPACE); + } + else { + mark(SHARP_BIT_MARK); + space(SHARP_ZERO_SPACE); + } + data <<= 1; + } + + mark(SHARP_BIT_MARK); + space(SHARP_ZERO_SPACE); + delay(46); + for (int i = 0; i < nbits; i++) { + if (invertdata & 0x4000) { + mark(SHARP_BIT_MARK); + space(SHARP_ONE_SPACE); + } + else { + mark(SHARP_BIT_MARK); + space(SHARP_ZERO_SPACE); + } + invertdata <<= 1; + } + mark(SHARP_BIT_MARK); + space(SHARP_ZERO_SPACE); + delay(46); +} + +void IRsend::sendDISH(unsigned long data, int nbits) +{ + enableIROut(56); + mark(DISH_HDR_MARK); + space(DISH_HDR_SPACE); + for (int i = 0; i < nbits; i++) { + if (data & DISH_TOP_BIT) { + mark(DISH_BIT_MARK); + space(DISH_ONE_SPACE); + } + else { + mark(DISH_BIT_MARK); + space(DISH_ZERO_SPACE); + } + data <<= 1; + } +} diff --git a/IRremote.h b/IRremote.h index f5e7a7b..9bb514a 100644 --- a/IRremote.h +++ b/IRremote.h @@ -35,6 +35,8 @@ public: #define SONY 2 #define RC5 3 #define RC6 4 +#define DISH 5 +#define SHARP 6 #define UNKNOWN -1 // Decoded value for NEC when a repeat code is received @@ -78,6 +80,8 @@ public: void sendRaw(unsigned int buf[], int len, int hz); void sendRC5(unsigned long data, int nbits); void sendRC6(unsigned long data, int nbits); + void sendDISH(unsigned long data, int nbits); + void sendSharp(unsigned long data, int nbits); // private: void enableIROut(int khz); VIRTUAL void mark(int usec); diff --git a/IRremoteInt.h b/IRremoteInt.h index 3824dbb..4325972 100644 --- a/IRremoteInt.h +++ b/IRremoteInt.h @@ -59,6 +59,24 @@ #define RC6_T1 444 #define RC6_RPT_LENGTH 46000 +#define SHARP_BIT_MARK 245 +#define SHARP_ONE_SPACE 1805 +#define SHARP_ZERO_SPACE 795 +#define SHARP_GAP 600000 +#define SHARP_TOGGLE_MASK 0x3FF +#define SHARP_RPT_SPACE 3000 + +#define DISH_HDR_MARK 400 +#define DISH_HDR_SPACE 6100 +#define DISH_BIT_MARK 400 +#define DISH_ONE_SPACE 1700 +#define DISH_ZERO_SPACE 2800 +#define DISH_RPT_SPACE 6200 +#define DISH_TOP_BIT 0x8000 + +#define SHARP_BITS 15 +#define DISH_BITS 16 + #define TOLERANCE 25 // percent tolerance in measurements #define LTOL (1.0 - TOLERANCE/100.) #define UTOL (1.0 + TOLERANCE/100.)