mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-11 08:56:14 +00:00
More cleanup and a few minor optimisations
This commit is contained in:
419
IRremote.h
419
IRremote.h
@@ -1,17 +1,104 @@
|
|||||||
|
|
||||||
|
//******************************************************************************
|
||||||
|
// IRremote
|
||||||
|
// Version 0.1 July, 2009
|
||||||
|
// Copyright 2009 Ken Shirriff
|
||||||
|
// For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com
|
||||||
|
// Edited by Mitra to add new controller SANYO
|
||||||
|
//
|
||||||
|
// Interrupt code based on NECIRrcv by Joe Knapp
|
||||||
|
// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
||||||
|
// Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
||||||
|
//
|
||||||
|
// JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
||||||
|
// LG added by Darryl Smith (based on the JVC protocol)
|
||||||
|
// Whynter A/C ARC-110WD added by Francesco Meschia
|
||||||
|
//******************************************************************************
|
||||||
|
|
||||||
#ifndef IRremote_h
|
#ifndef IRremote_h
|
||||||
#define IRremote_h
|
#define IRremote_h
|
||||||
|
|
||||||
#define DEBUG
|
//------------------------------------------------------------------------------
|
||||||
#undef DEBUG
|
// Supported IR protocols
|
||||||
|
// Each protocol you include costs memory and, during decode, costs time
|
||||||
|
// Disable (set to 0) all the protocols you do not need/want!
|
||||||
|
//
|
||||||
|
#define DECODE_RC5 1
|
||||||
|
#define SEND_RC5 1
|
||||||
|
|
||||||
|
#define DECODE_RC6 1
|
||||||
|
#define SEND_RC6 1
|
||||||
|
|
||||||
|
#define DECODE_NEC 1
|
||||||
|
#define SEND_NEC 1
|
||||||
|
|
||||||
|
#define DECODE_SONY 1
|
||||||
|
#define SEND_SONY 1
|
||||||
|
|
||||||
|
#define DECODE_PANASONIC 1
|
||||||
|
#define SEND_PANASONIC 1
|
||||||
|
|
||||||
|
#define DECODE_JVC 1
|
||||||
|
#define SEND_JVC 1
|
||||||
|
|
||||||
|
#define DECODE_SAMSUNG 1
|
||||||
|
#define SEND_SAMSUNG 1
|
||||||
|
|
||||||
|
#define DECODE_WHYNTER 1
|
||||||
|
#define SEND_WHYNTER 1
|
||||||
|
|
||||||
|
#define DECODE_AIWA_RC_T501 1
|
||||||
|
#define SEND_AIWA_RC_T501 1
|
||||||
|
|
||||||
|
#define DECODE_LG 1
|
||||||
|
#define SEND_LG 0 // NOT WRITTEN
|
||||||
|
|
||||||
|
#define DECODE_SANYO 1
|
||||||
|
#define SEND_SANYO 0 // NOT WRITTEN
|
||||||
|
|
||||||
|
#define DECODE_MITSUBISHI 1
|
||||||
|
#define SEND_MITSUBISHI 0 // NOT WRITTEN
|
||||||
|
|
||||||
|
#define DECODE_DISH 0 // NOT WRITTEN
|
||||||
|
#define SEND_DISH 1
|
||||||
|
|
||||||
|
#define DECODE_SHARP 0 // NOT WRITTEN
|
||||||
|
#define SEND_SHARP 1
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int MATCH_SPACE (int measured_ticks, int desired_us) ;
|
// An enumerated list of all supported formats
|
||||||
int MATCH_MARK (int measured_ticks, int desired_us) ;
|
// You do NOT need to remove entries from this list when disabling protocols!
|
||||||
int MATCH (int measured, int desired) ;
|
//
|
||||||
|
typedef
|
||||||
|
enum {
|
||||||
|
UNKNOWN = -1,
|
||||||
|
UNUSED = 0,
|
||||||
|
RC5 = 1,
|
||||||
|
RC6 = 2,
|
||||||
|
NEC = 3,
|
||||||
|
SONY = 4,
|
||||||
|
PANASONIC = 5,
|
||||||
|
JVC = 6,
|
||||||
|
SAMSUNG = 7,
|
||||||
|
WHYNTER = 8,
|
||||||
|
AIWA_RC_T501 = 9,
|
||||||
|
LG = 10,
|
||||||
|
SANYO = 11,
|
||||||
|
MITSUBISHI = 12,
|
||||||
|
DISH = 13,
|
||||||
|
SHARP = 14,
|
||||||
|
}
|
||||||
|
decode_type_t;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Set DEBUG to 1 for lots of lovely debug output
|
||||||
|
//
|
||||||
|
#define DEBUG 0
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Debug directives
|
// Debug directives
|
||||||
#ifdef DEBUG
|
//
|
||||||
|
#if DEBUG
|
||||||
# define DBG_PRINT(...) Serial.print(__VA_ARGS__)
|
# define DBG_PRINT(...) Serial.print(__VA_ARGS__)
|
||||||
# define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
|
# define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
@@ -20,77 +107,11 @@ int MATCH (int measured, int desired) ;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#define SEND_NEC
|
// Mark & Space matching functions
|
||||||
#define DECODE_NEC
|
|
||||||
#define SEND_WHYNTER
|
|
||||||
#define DECODE_WHYNTER
|
|
||||||
#define SEND_SONY
|
|
||||||
#define DECODE_SONY
|
|
||||||
#define DECODE_SANYO
|
|
||||||
#define SEND_RC5
|
|
||||||
#define DECODE_RC5
|
|
||||||
#define SEND_RC6
|
|
||||||
#define DECODE_RC6
|
|
||||||
#define SEND_PANASONIC
|
|
||||||
#define DECODE_PANASONIC
|
|
||||||
#define SEND_JVC
|
|
||||||
#define DECODE_JVC
|
|
||||||
#define SEND_SAMSUNG
|
|
||||||
#define DECODE_SAMSUNG
|
|
||||||
#define DECODE_LG
|
|
||||||
#define DECODE_MITSUBISHI
|
|
||||||
#define SEND_AIWA_RC_T501
|
|
||||||
#define DECODE_AIWA_RC_T501
|
|
||||||
#define SEND_SHARP
|
|
||||||
#define SEND_DISH
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IRremote
|
|
||||||
* Version 0.1 July, 2009
|
|
||||||
* Copyright 2009 Ken Shirriff
|
|
||||||
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com
|
|
||||||
* Edited by Mitra to add new controller SANYO
|
|
||||||
*
|
|
||||||
* Interrupt code based on NECIRrcv by Joe Knapp
|
|
||||||
* http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
|
|
||||||
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
|
|
||||||
*
|
|
||||||
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
|
|
||||||
* LG added by Darryl Smith (based on the JVC protocol)
|
|
||||||
* Whynter A/C ARC-110WD added by Francesco Meschia
|
|
||||||
*/
|
|
||||||
|
|
||||||
// The following are compile-time library options.
|
|
||||||
// If you change them, recompile the library.
|
|
||||||
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
|
|
||||||
// TEST must be defined for the IRtest unittests to work. It will make some
|
|
||||||
// methods virtual, which will be slightly slower, which is why it is optional.
|
|
||||||
//#define DEBUG
|
|
||||||
// #define TEST
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// An enumerated list of all supported formats
|
|
||||||
//
|
//
|
||||||
typedef
|
int MATCH (int measured, int desired) ;
|
||||||
enum {
|
int MATCH_MARK (int measured_ticks, int desired_us) ;
|
||||||
UNKNOWN = -1,
|
int MATCH_SPACE (int measured_ticks, int desired_us) ;
|
||||||
UNUSED = 0,
|
|
||||||
NEC = 1,
|
|
||||||
SONY = 2,
|
|
||||||
RC5 = 3,
|
|
||||||
RC6 = 4,
|
|
||||||
DISH = 5,
|
|
||||||
SHARP = 6,
|
|
||||||
PANASONIC = 7,
|
|
||||||
JVC = 8,
|
|
||||||
SANYO = 9,
|
|
||||||
MITSUBISHI = 10,
|
|
||||||
SAMSUNG = 11,
|
|
||||||
LG = 12,
|
|
||||||
WHYNTER = 13,
|
|
||||||
AIWA_RC_T501 = 14,
|
|
||||||
}
|
|
||||||
decode_type_t;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Results returned from the decoder
|
// Results returned from the decoder
|
||||||
@@ -99,130 +120,168 @@ class decode_results
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
|
decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
|
||||||
unsigned int address; // Used by Panasonic & Sharp
|
unsigned int address; // Used by Panasonic & Sharp [16-bits]
|
||||||
unsigned long value; // Decoded value
|
unsigned long value; // Decoded value [max 32-bits]
|
||||||
int bits; // Number of bits in decoded value
|
int bits; // Number of bits in decoded value
|
||||||
volatile unsigned int *rawbuf; // Raw intervals in 50uS ticks
|
volatile unsigned int *rawbuf; // Raw intervals in 50uS ticks
|
||||||
int rawlen; // Number of records in rawbuf.
|
int rawlen; // Number of records in rawbuf
|
||||||
int overflow; // true iff IR raw code too long
|
int overflow; // true iff IR raw code too long
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Decoded value for NEC when a repeat code is received
|
// Decoded value for NEC when a repeat code is received
|
||||||
//
|
//
|
||||||
#define REPEAT 0xffffffff
|
#define REPEAT 0xFFFFFFFF
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// main class for receiving IR
|
// Main class for receiving IR
|
||||||
|
//
|
||||||
class IRrecv
|
class IRrecv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IRrecv(int recvpin);
|
IRrecv (int recvpin) ;
|
||||||
void blink13(int blinkflag);
|
|
||||||
int decode(decode_results *results);
|
|
||||||
void enableIRIn();
|
|
||||||
void resume();
|
|
||||||
private:
|
|
||||||
// These are called by decode
|
|
||||||
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
|
||||||
#ifdef DECODE_NEC
|
|
||||||
long decodeNEC(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_SONY
|
|
||||||
long decodeSony(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_SANYO
|
|
||||||
long decodeSanyo(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_MITSUBISHI
|
|
||||||
long decodeMitsubishi(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_RC5
|
|
||||||
long decodeRC5(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_RC6
|
|
||||||
long decodeRC6(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_PANASONIC
|
|
||||||
long decodePanasonic(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_LG
|
|
||||||
long decodeLG(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_JVC
|
|
||||||
long decodeJVC(decode_results *results);
|
|
||||||
#endif
|
|
||||||
#ifdef DECODE_SAMSUNG
|
|
||||||
long decodeSAMSUNG(decode_results *results);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DECODE_WHYNTER
|
void blink13 (int blinkflag) ;
|
||||||
long decodeWhynter(decode_results *results);
|
int decode (decode_results *results) ;
|
||||||
#endif
|
void enableIRIn ( ) ;
|
||||||
|
void resume ( ) ;
|
||||||
|
|
||||||
#ifdef DECODE_AIWA_RC_T501
|
private:
|
||||||
long decodeAiwaRCT501(decode_results *results);
|
long decodeHash (decode_results *results) ;
|
||||||
#endif
|
int compare (unsigned int oldval, unsigned int newval) ;
|
||||||
|
|
||||||
long decodeHash(decode_results *results);
|
|
||||||
int compare(unsigned int oldval, unsigned int newval);
|
|
||||||
|
|
||||||
|
//......................................................................
|
||||||
|
# if (DECODE_RC5 || DECODE_RC6)
|
||||||
|
// This helper function is shared by RC5 and RC6
|
||||||
|
int getRClevel (decode_results *results, int *offset, int *used, int t1) ;
|
||||||
|
# endif
|
||||||
|
# if DECODE_RC5
|
||||||
|
bool decodeRC5 (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
# if DECODE_RC6
|
||||||
|
bool decodeRC6 (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_NEC
|
||||||
|
bool decodeNEC (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_SONY
|
||||||
|
bool decodeSony (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_PANASONIC
|
||||||
|
bool decodePanasonic (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_JVC
|
||||||
|
bool decodeJVC (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_SAMSUNG
|
||||||
|
bool decodeSAMSUNG (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_WHYNTER
|
||||||
|
bool decodeWhynter (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_AIWA_RC_T501
|
||||||
|
bool decodeAiwaRCT501 (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_LG
|
||||||
|
bool decodeLG (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_SANYO
|
||||||
|
bool decodeSanyo (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_MITSUBISHI
|
||||||
|
bool decodeMitsubishi (decode_results *results) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_DISH
|
||||||
|
bool decodeDish (decode_results *results) ; // NOT WRITTEN
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if DECODE_SHARP
|
||||||
|
bool decodeSharp (decode_results *results) ; // NOT WRITTEN
|
||||||
|
# endif
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Only used for testing; can remove virtual for shorter code
|
|
||||||
#ifdef TEST
|
|
||||||
#define VIRTUAL virtual
|
|
||||||
#else
|
|
||||||
#define VIRTUAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
class IRsend
|
class IRsend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IRsend() {}
|
IRsend () { }
|
||||||
void sendRaw(unsigned int buf[], int len, int hz);
|
|
||||||
#ifdef SEND_RC5
|
void enableIROut (int khz) ;
|
||||||
void sendRC5(unsigned long data, int nbits);
|
void mark (int usec) ;
|
||||||
#endif
|
void space (int usec) ;
|
||||||
#ifdef SEND_RC6
|
void sendRaw (unsigned int buf[], int len, int hz) ;
|
||||||
void sendRC6(unsigned long data, int nbits);
|
|
||||||
#endif
|
//......................................................................
|
||||||
#ifdef SEND_WHYNTER
|
# if SEND_RC5
|
||||||
void sendWhynter(unsigned long data, int nbits);
|
void sendRC5 (unsigned long data, int nbits) ;
|
||||||
#endif
|
# endif
|
||||||
#ifdef SEND_NEC
|
# if SEND_RC6
|
||||||
void sendNEC(unsigned long data, int nbits);
|
void sendRC6 (unsigned long data, int nbits) ;
|
||||||
#endif
|
# endif
|
||||||
#ifdef SEND_SONY
|
//......................................................................
|
||||||
void sendSony(unsigned long data, int nbits);
|
# if SEND_NEC
|
||||||
// Neither Sanyo nor Mitsubishi send is implemented yet
|
void sendNEC (unsigned long data, int nbits) ;
|
||||||
// void sendSanyo(unsigned long data, int nbits);
|
# endif
|
||||||
// void sendMitsubishi(unsigned long data, int nbits);
|
//......................................................................
|
||||||
#endif
|
# if SEND_SONY
|
||||||
#ifdef SEND_DISH
|
void sendSony (unsigned long data, int nbits) ;
|
||||||
void sendDISH(unsigned long data, int nbits);
|
# endif
|
||||||
#endif
|
//......................................................................
|
||||||
#ifdef SEND_SHARP
|
# if SEND_PANASONIC
|
||||||
void sendSharpRaw(unsigned long data, int nbits);
|
void sendPanasonic (unsigned int address, unsigned long data) ;
|
||||||
void sendSharp(unsigned int address, unsigned int command);
|
# endif
|
||||||
#endif
|
//......................................................................
|
||||||
#ifdef SEND_PANASONIC
|
# if SEND_JVC
|
||||||
void sendPanasonic(unsigned int address, unsigned long data);
|
// JVC does NOT repeat by sending a separate code (like NEC does).
|
||||||
#endif
|
// The JVC protocol repeats by skipping the header.
|
||||||
#ifdef SEND_JVC
|
// To send a JVC repeat signal, send the original code value
|
||||||
void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
|
// and set 'repeat' to true
|
||||||
#endif
|
void sendJVC (unsigned long data, int nbits, bool repeat) ;
|
||||||
#ifdef SEND_AIWA_RC_T501
|
# endif
|
||||||
void sendAiwaRCT501(int code);
|
//......................................................................
|
||||||
#endif
|
# if SEND_SAMSUNG
|
||||||
#ifdef SEND_SAMSUNG
|
void sendSAMSUNG (unsigned long data, int nbits) ;
|
||||||
void sendSAMSUNG(unsigned long data, int nbits);
|
# endif
|
||||||
#endif
|
//......................................................................
|
||||||
void enableIROut(int khz);
|
# if SEND_WHYNTER
|
||||||
VIRTUAL void mark(int usec);
|
void sendWhynter (unsigned long data, int nbits) ;
|
||||||
VIRTUAL void space(int usec);
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if SEND_AIWA_RC_T501
|
||||||
|
void sendAiwaRCT501 (int code) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if SEND_LG
|
||||||
|
void sendLG ( ) ; // NOT WRITTEN
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if SEND_SANYO
|
||||||
|
void sendSanyo ( ) ; // NOT WRITTEN
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if SEND_MISUBISHI
|
||||||
|
void sendMitsubishi ( ) ; // NOT WRITTEN
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if SEND_DISH
|
||||||
|
void sendDISH (unsigned long data, int nbits) ;
|
||||||
|
# endif
|
||||||
|
//......................................................................
|
||||||
|
# if SEND_SHARP
|
||||||
|
void sendSharpRaw (unsigned long data, int nbits) ;
|
||||||
|
void sendSharp (unsigned int address, unsigned int command) ;
|
||||||
|
# endif
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
58
ir_Aiwa.cpp
58
ir_Aiwa.cpp
@@ -24,7 +24,7 @@
|
|||||||
#define AIWA_RC_T501_ZERO_SPACE 1700
|
#define AIWA_RC_T501_ZERO_SPACE 1700
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_AIWA_RC_T501
|
#if SEND_AIWA_RC_T501
|
||||||
void IRsend::sendAiwaRCT501 (int code)
|
void IRsend::sendAiwaRCT501 (int code)
|
||||||
{
|
{
|
||||||
unsigned long pre = 0x0227EEC0; // 26-bits
|
unsigned long pre = 0x0227EEC0; // 26-bits
|
||||||
@@ -48,7 +48,8 @@ void IRsend::sendAiwaRCT501 (int code)
|
|||||||
// it only send 15bits and ignores the top bit
|
// it only send 15bits and ignores the top bit
|
||||||
// then uses TOPBIT which is 0x80000000 to check the bit code
|
// then uses TOPBIT which is 0x80000000 to check the bit code
|
||||||
// I suspect TOPBIT should be changed to 0x00008000
|
// I suspect TOPBIT should be changed to 0x00008000
|
||||||
// Skip firts code bit
|
|
||||||
|
// Skip first code bit
|
||||||
code <<= 1;
|
code <<= 1;
|
||||||
// Send code
|
// Send code
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
@@ -57,6 +58,7 @@ void IRsend::sendAiwaRCT501 (int code)
|
|||||||
else space(AIWA_RC_T501_ZERO_SPACE) ;
|
else space(AIWA_RC_T501_ZERO_SPACE) ;
|
||||||
code <<= 1;
|
code <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
|
//-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
|
||||||
|
|
||||||
// POST-DATA, 1 bit, 0x0
|
// POST-DATA, 1 bit, 0x0
|
||||||
@@ -69,40 +71,36 @@ void IRsend::sendAiwaRCT501 (int code)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_AIWA_RC_T501
|
#if DECODE_AIWA_RC_T501
|
||||||
long IRrecv::decodeAiwaRCT501 (decode_results *results)
|
bool IRrecv::decodeAiwaRCT501 (decode_results *results)
|
||||||
{
|
{
|
||||||
int data = 0;
|
int data = 0;
|
||||||
int offset = 1; // skip first garbage read
|
int offset = 1;
|
||||||
|
|
||||||
// Check SIZE
|
// Check SIZE
|
||||||
if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ;
|
if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ;
|
||||||
|
|
||||||
// Check HDR
|
// Check HDR Mark/Space
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_HDR_MARK)) return false ;
|
if (!MATCH_MARK (results->rawbuf[offset++], AIWA_RC_T501_HDR_MARK )) return false ;
|
||||||
offset++;
|
if (!MATCH_SPACE(results->rawbuf[offset++], AIWA_RC_T501_HDR_SPACE)) return false ;
|
||||||
|
|
||||||
// Check HDR space
|
offset += 26; // skip pre-data - optional
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_HDR_SPACE)) return false ;
|
while(offset < irparams.rawlen - 4) {
|
||||||
offset++;
|
if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ;
|
||||||
|
else return false ;
|
||||||
|
|
||||||
offset += 26; // skip pre-data - optional
|
// ONE & ZERO
|
||||||
while(offset < irparams.rawlen - 4) {
|
if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ;
|
||||||
if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ;
|
else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) data = (data << 1) | 0 ;
|
||||||
else return false ;
|
else break ; // End of one & zero detected
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
// ONE & ZERO
|
results->bits = (offset - 1) / 2;
|
||||||
if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ;
|
if (results->bits < 42) return false ;
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) data <<= 1 ;
|
|
||||||
else break ; // End of one & zero detected
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
results->bits = (offset - 1) / 2;
|
results->value = data;
|
||||||
if (results->bits < 42) return false ;
|
results->decode_type = AIWA_RC_T501;
|
||||||
results->value = data;
|
return true;
|
||||||
results->decode_type = AIWA_RC_T501;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
44
ir_Dish.cpp
44
ir_Dish.cpp
@@ -21,35 +21,33 @@
|
|||||||
// DISH NETWORK (echostar 301):
|
// DISH NETWORK (echostar 301):
|
||||||
// http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
|
// http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
|
||||||
|
|
||||||
#define DISH_BITS 16
|
#define DISH_BITS 16
|
||||||
|
#define DISH_HDR_MARK 400
|
||||||
#define DISH_HDR_MARK 400
|
#define DISH_HDR_SPACE 6100
|
||||||
#define DISH_HDR_SPACE 6100
|
#define DISH_BIT_MARK 400
|
||||||
#define DISH_BIT_MARK 400
|
#define DISH_ONE_SPACE 1700
|
||||||
#define DISH_ONE_SPACE 1700
|
#define DISH_ZERO_SPACE 2800
|
||||||
#define DISH_ZERO_SPACE 2800
|
#define DISH_RPT_SPACE 6200
|
||||||
#define DISH_RPT_SPACE 6200
|
|
||||||
#define DISH_TOP_BIT 0x8000
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_DISH
|
#if SEND_DISH
|
||||||
void IRsend::sendDISH (unsigned long data, int nbits)
|
void IRsend::sendDISH (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
enableIROut(56);
|
enableIROut(56);
|
||||||
|
|
||||||
mark(DISH_HDR_MARK);
|
mark(DISH_HDR_MARK);
|
||||||
space(DISH_HDR_SPACE);
|
space(DISH_HDR_SPACE);
|
||||||
|
|
||||||
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
|
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
|
||||||
if (data & mask) {
|
if (data & mask) {
|
||||||
mark(DISH_BIT_MARK);
|
mark(DISH_BIT_MARK);
|
||||||
space(DISH_ONE_SPACE);
|
space(DISH_ONE_SPACE);
|
||||||
} else {
|
} else {
|
||||||
mark(DISH_BIT_MARK);
|
mark(DISH_BIT_MARK);
|
||||||
space(DISH_ZERO_SPACE);
|
space(DISH_ZERO_SPACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
38
ir_JVC.cpp
38
ir_JVC.cpp
@@ -18,8 +18,13 @@
|
|||||||
#define JVC_RPT_LENGTH 60000
|
#define JVC_RPT_LENGTH 60000
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_JVC
|
// JVC does NOT repeat by sending a separate code (like NEC does).
|
||||||
void IRsend::sendJVC (unsigned long data, int nbits, int repeat)
|
// The JVC protocol repeats by skipping the header.
|
||||||
|
// To send a JVC repeat signal, send the original code value
|
||||||
|
// and set 'repeat' to true
|
||||||
|
//
|
||||||
|
#if SEND_JVC
|
||||||
|
void IRsend::sendJVC (unsigned long data, int nbits, bool repeat)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
enableIROut(38);
|
enableIROut(38);
|
||||||
@@ -48,37 +53,36 @@ void IRsend::sendJVC (unsigned long data, int nbits, int repeat)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_JVC
|
#if DECODE_JVC
|
||||||
long IRrecv::decodeJVC (decode_results *results)
|
bool IRrecv::decodeJVC (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0;
|
long data = 0;
|
||||||
int offset = 1; // Skip first space
|
int offset = 1; // Skip first space
|
||||||
|
|
||||||
// Check for repeat
|
// Check for repeat
|
||||||
if (irparams.rawlen - 1 == 33 &&
|
if ( (irparams.rawlen - 1 == 33)
|
||||||
MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK) &&
|
&& MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)
|
||||||
MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)) {
|
&& MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)
|
||||||
results->bits = 0;
|
) {
|
||||||
results->value = REPEAT;
|
results->bits = 0;
|
||||||
|
results->value = REPEAT;
|
||||||
results->decode_type = JVC;
|
results->decode_type = JVC;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial mark
|
// Initial mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], JVC_HDR_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
if (irparams.rawlen < 2 * JVC_BITS + 1 ) return false ;
|
if (irparams.rawlen < (2 * JVC_BITS) + 1 ) return false ;
|
||||||
|
|
||||||
// Initial space
|
// Initial space
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) return false ;
|
if (!MATCH_SPACE(results->rawbuf[offset++], JVC_HDR_SPACE)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
for (int i = 0; i < JVC_BITS; i++) {
|
for (int i = 0; i < JVC_BITS; i++) {
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], JVC_BIT_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) data = (data << 1) | 1 ;
|
if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) data = (data << 1) | 1 ;
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) data <<= 1 ;
|
else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) data = (data << 1) | 0 ;
|
||||||
else return false ;
|
else return false ;
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|||||||
28
ir_LG.cpp
28
ir_LG.cpp
@@ -19,24 +19,24 @@
|
|||||||
#define LG_RPT_LENGTH 60000
|
#define LG_RPT_LENGTH 60000
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_LG
|
#if DECODE_LG
|
||||||
long IRrecv::decodeLG (decode_results *results)
|
bool IRrecv::decodeLG (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0;
|
long data = 0;
|
||||||
int offset = 1; // Skip first space
|
int offset = 1; // Skip first space
|
||||||
|
|
||||||
// Initial mark
|
// Check we have the right amount of data
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) return false ;
|
if (irparams.rawlen < (2 * LG_BITS) + 1 ) return false ;
|
||||||
offset++;
|
|
||||||
if (irparams.rawlen < 2 * LG_BITS + 1 ) return false ;
|
// Initial mark/space
|
||||||
// Initial space
|
if (!MATCH_MARK(results->rawbuf[offset++], LG_HDR_MARK)) return false ;
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) return false ;
|
if (!MATCH_SPACE(results->rawbuf[offset++], LG_HDR_SPACE)) return false ;
|
||||||
offset++;
|
|
||||||
for (int i = 0; i < LG_BITS; i++) {
|
for (int i = 0; i < LG_BITS; i++) {
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], LG_BIT_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) data = (data << 1) | 1 ;
|
if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) data = (data << 1) | 1 ;
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) data <<= 1 ;
|
else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) data = (data << 1) | 0 ;
|
||||||
else return false ;
|
else return false ;
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
@@ -45,8 +45,8 @@ long IRrecv::decodeLG (decode_results *results)
|
|||||||
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
results->bits = LG_BITS;
|
results->bits = LG_BITS;
|
||||||
results->value = data;
|
results->value = data;
|
||||||
results->decode_type = LG;
|
results->decode_type = LG;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
// #define MITSUBISHI_RPT_LENGTH 45000
|
// #define MITSUBISHI_RPT_LENGTH 45000
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_MITSUBISHI
|
#if DECODE_MITSUBISHI
|
||||||
long IRrecv::decodeMitsubishi (decode_results *results)
|
bool IRrecv::decodeMitsubishi (decode_results *results)
|
||||||
{
|
{
|
||||||
// Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
|
// Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
|
||||||
long data = 0;
|
long data = 0;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#define NEC_RPT_SPACE 2250
|
#define NEC_RPT_SPACE 2250
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_NEC
|
#if SEND_NEC
|
||||||
void IRsend::sendNEC (unsigned long data, int nbits)
|
void IRsend::sendNEC (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -48,8 +48,8 @@ void IRsend::sendNEC (unsigned long data, int nbits)
|
|||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// NECs have a repeat only 4 items long
|
// NECs have a repeat only 4 items long
|
||||||
//
|
//
|
||||||
#ifdef DECODE_NEC
|
#if DECODE_NEC
|
||||||
long IRrecv::decodeNEC (decode_results *results)
|
bool IRrecv::decodeNEC (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0; // We decode in to here; Start with nothing
|
long data = 0; // We decode in to here; Start with nothing
|
||||||
int offset = 1; // Index in to results; Skip first entry!?
|
int offset = 1; // Index in to results; Skip first entry!?
|
||||||
|
|||||||
@@ -9,15 +9,15 @@
|
|||||||
// P A A N N A A SSSS OOO N N IIIII CCCC
|
// P A A N N A A SSSS OOO N N IIIII CCCC
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#define PANASONIC_BITS 48
|
#define PANASONIC_BITS 48
|
||||||
#define PANASONIC_HDR_MARK 3502
|
#define PANASONIC_HDR_MARK 3502
|
||||||
#define PANASONIC_HDR_SPACE 1750
|
#define PANASONIC_HDR_SPACE 1750
|
||||||
#define PANASONIC_BIT_MARK 502
|
#define PANASONIC_BIT_MARK 502
|
||||||
#define PANASONIC_ONE_SPACE 1244
|
#define PANASONIC_ONE_SPACE 1244
|
||||||
#define PANASONIC_ZERO_SPACE 400
|
#define PANASONIC_ZERO_SPACE 400
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_PANASONIC
|
#if SEND_PANASONIC
|
||||||
void IRsend::sendPanasonic (unsigned int address, unsigned long data)
|
void IRsend::sendPanasonic (unsigned int address, unsigned long data)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -48,16 +48,14 @@ void IRsend::sendPanasonic (unsigned int address, unsigned long data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_PANASONIC
|
#if DECODE_PANASONIC
|
||||||
long IRrecv::decodePanasonic (decode_results *results)
|
bool IRrecv::decodePanasonic (decode_results *results)
|
||||||
{
|
{
|
||||||
unsigned long long data = 0;
|
unsigned long long data = 0;
|
||||||
int offset = 1;
|
int offset = 1;
|
||||||
|
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_MARK )) return false ;
|
||||||
offset++;
|
if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_SPACE)) return false ;
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) return false ;
|
|
||||||
offset++;
|
|
||||||
|
|
||||||
// decode address
|
// decode address
|
||||||
for (int i = 0; i < PANASONIC_BITS; i++) {
|
for (int i = 0; i < PANASONIC_BITS; i++) {
|
||||||
|
|||||||
121
ir_RC5_RC6.cpp
121
ir_RC5_RC6.cpp
@@ -12,25 +12,30 @@
|
|||||||
//
|
//
|
||||||
int IRrecv::getRClevel (decode_results *results, int *offset, int *used, int t1)
|
int IRrecv::getRClevel (decode_results *results, int *offset, int *used, int t1)
|
||||||
{
|
{
|
||||||
if (*offset >= results->rawlen) return SPACE ; // After end of recorded buffer, assume SPACE.
|
int width;
|
||||||
int width = results->rawbuf[*offset];
|
int val;
|
||||||
int val = ((*offset) % 2) ? MARK : SPACE;
|
int correction;
|
||||||
int correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS;
|
int avail;
|
||||||
|
|
||||||
int avail;
|
if (*offset >= results->rawlen) return SPACE ; // After end of recorded buffer, assume SPACE.
|
||||||
if (MATCH(width, t1 + correction)) avail = 1 ;
|
width = results->rawbuf[*offset];
|
||||||
else if (MATCH(width, 2*t1 + correction)) avail = 2 ;
|
val = ((*offset) % 2) ? MARK : SPACE;
|
||||||
else if (MATCH(width, 3*t1 + correction)) avail = 3 ;
|
correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS;
|
||||||
else return -1 ;
|
|
||||||
|
|
||||||
(*used)++;
|
if (MATCH(width, ( t1) + correction)) avail = 1 ;
|
||||||
if (*used >= avail) {
|
else if (MATCH(width, (2*t1) + correction)) avail = 2 ;
|
||||||
*used = 0;
|
else if (MATCH(width, (3*t1) + correction)) avail = 3 ;
|
||||||
(*offset)++;
|
else return -1 ;
|
||||||
}
|
|
||||||
|
|
||||||
DBG_PRINTLN( (val == MARK) ? "MARK" : "SPACE" );
|
(*used)++;
|
||||||
return val;
|
if (*used >= avail) {
|
||||||
|
*used = 0;
|
||||||
|
(*offset)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_PRINTLN( (val == MARK) ? "MARK" : "SPACE" );
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@@ -42,12 +47,12 @@ int IRrecv::getRClevel (decode_results *results, int *offset, int *used, int
|
|||||||
//
|
//
|
||||||
// NB: First bit must be a one (start bit)
|
// NB: First bit must be a one (start bit)
|
||||||
//
|
//
|
||||||
#define MIN_RC5_SAMPLES 11
|
#define MIN_RC5_SAMPLES 11
|
||||||
#define RC5_T1 889
|
#define RC5_T1 889
|
||||||
#define RC5_RPT_LENGTH 46000
|
#define RC5_RPT_LENGTH 46000
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_RC5
|
#if SEND_RC5
|
||||||
void IRsend::sendRC5 (unsigned long data, int nbits)
|
void IRsend::sendRC5 (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -74,25 +79,28 @@ void IRsend::sendRC5 (unsigned long data, int nbits)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_RC5
|
#if DECODE_RC5
|
||||||
long IRrecv::decodeRC5 (decode_results *results)
|
bool IRrecv::decodeRC5 (decode_results *results)
|
||||||
{
|
{
|
||||||
|
int nbits;
|
||||||
|
long data = 0;
|
||||||
|
int used = 0;
|
||||||
|
int offset = 1; // Skip gap space
|
||||||
|
|
||||||
if (irparams.rawlen < MIN_RC5_SAMPLES + 2) return false ;
|
if (irparams.rawlen < MIN_RC5_SAMPLES + 2) return false ;
|
||||||
int offset = 1; // Skip gap space
|
|
||||||
long data = 0;
|
|
||||||
int used = 0;
|
|
||||||
// Get start bits
|
// Get start bits
|
||||||
if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return false ;
|
if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return false ;
|
||||||
if (getRClevel(results, &offset, &used, RC5_T1) != SPACE) return false ;
|
if (getRClevel(results, &offset, &used, RC5_T1) != SPACE) return false ;
|
||||||
if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return false ;
|
if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return false ;
|
||||||
int nbits;
|
|
||||||
for (nbits = 0; offset < irparams.rawlen; nbits++) {
|
|
||||||
int levelA = getRClevel(results, &offset, &used, RC5_T1);
|
|
||||||
int levelB = getRClevel(results, &offset, &used, RC5_T1);
|
|
||||||
|
|
||||||
if (levelA == SPACE && levelB == MARK) data = (data << 1) | 1 ; // 1 bit
|
for (nbits = 0; offset < irparams.rawlen; nbits++) {
|
||||||
else if (levelA == MARK && levelB == SPACE) data <<= 1 ; // zero bit
|
int levelA = getRClevel(results, &offset, &used, RC5_T1);
|
||||||
else return false ;
|
int levelB = getRClevel(results, &offset, &used, RC5_T1);
|
||||||
|
|
||||||
|
if ((levelA == SPACE) && (levelB == MARK )) data = (data << 1) | 1 ;
|
||||||
|
else if ((levelA == MARK ) && (levelB == SPACE)) data = (data << 1) | 0 ;
|
||||||
|
else return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
@@ -112,13 +120,13 @@ long IRrecv::decodeRC5 (decode_results *results)
|
|||||||
//
|
//
|
||||||
// NB : Caller needs to take care of flipping the toggle bit
|
// NB : Caller needs to take care of flipping the toggle bit
|
||||||
//
|
//
|
||||||
#define MIN_RC6_SAMPLES 1
|
#define MIN_RC6_SAMPLES 1
|
||||||
#define RC6_HDR_MARK 2666
|
#define RC6_HDR_MARK 2666
|
||||||
#define RC6_HDR_SPACE 889
|
#define RC6_HDR_SPACE 889
|
||||||
#define RC6_T1 444
|
#define RC6_T1 444
|
||||||
#define RC6_RPT_LENGTH 46000
|
#define RC6_RPT_LENGTH 46000
|
||||||
|
|
||||||
#ifdef SEND_RC6
|
#if SEND_RC6
|
||||||
void IRsend::sendRC6 (unsigned long data, int nbits)
|
void IRsend::sendRC6 (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -150,46 +158,47 @@ void IRsend::sendRC6 (unsigned long data, int nbits)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_RC6
|
#if DECODE_RC6
|
||||||
long IRrecv::decodeRC6 (decode_results *results)
|
bool IRrecv::decodeRC6 (decode_results *results)
|
||||||
{
|
{
|
||||||
|
int nbits;
|
||||||
|
long data = 0;
|
||||||
|
int used = 0;
|
||||||
|
int offset = 1; // Skip first space
|
||||||
|
|
||||||
if (results->rawlen < MIN_RC6_SAMPLES) return false ;
|
if (results->rawlen < MIN_RC6_SAMPLES) return false ;
|
||||||
int offset = 1; // Skip first space
|
|
||||||
|
|
||||||
// Initial mark
|
// Initial mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], RC6_HDR_MARK)) return false ;
|
||||||
offset++;
|
if (!MATCH_SPACE(results->rawbuf[offset++], RC6_HDR_SPACE)) return false ;
|
||||||
|
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) return false ;
|
|
||||||
offset++;
|
|
||||||
|
|
||||||
long data = 0;
|
|
||||||
int used = 0;
|
|
||||||
|
|
||||||
// Get start bit (1)
|
// Get start bit (1)
|
||||||
if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return false ;
|
if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return false ;
|
||||||
if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return false ;
|
if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return false ;
|
||||||
int nbits;
|
|
||||||
for (nbits = 0; offset < results->rawlen; nbits++) {
|
for (nbits = 0; offset < results->rawlen; nbits++) {
|
||||||
int levelA, levelB; // Next two levels
|
int levelA, levelB; // Next two levels
|
||||||
|
|
||||||
levelA = getRClevel(results, &offset, &used, RC6_T1);
|
levelA = getRClevel(results, &offset, &used, RC6_T1);
|
||||||
if (nbits == 3) {
|
if (nbits == 3) {
|
||||||
// T bit is double wide; make sure second half matches
|
// T bit is double wide; make sure second half matches
|
||||||
if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return false;
|
if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
levelB = getRClevel(results, &offset, &used, RC6_T1);
|
levelB = getRClevel(results, &offset, &used, RC6_T1);
|
||||||
if (nbits == 3) {
|
if (nbits == 3) {
|
||||||
// T bit is double wide; make sure second half matches
|
// T bit is double wide; make sure second half matches
|
||||||
if (levelB != getRClevel(results, &offset, &used, RC6_T1)) return false;
|
if (levelB != getRClevel(results, &offset, &used, RC6_T1)) return false;
|
||||||
}
|
}
|
||||||
if (levelA == MARK && levelB == SPACE) data = (data << 1) | 1 ; // 1-bit (reversed compared to RC5)
|
|
||||||
else if (levelA == SPACE && levelB == MARK) data <<= 1 ; // zero bit
|
if ((levelA == MARK ) && (levelB == SPACE)) data = (data << 1) | 1 ; // inverted compared to RC5
|
||||||
else return false ; // Error
|
else if ((levelA == SPACE) && (levelB == MARK )) data = (data << 1) | 0 ; // ...
|
||||||
|
else return false ; // Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
results->bits = nbits;
|
results->bits = nbits;
|
||||||
results->value = data;
|
results->value = data;
|
||||||
results->decode_type = RC6;
|
results->decode_type = RC6;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#define SAMSUNG_RPT_SPACE 2250
|
#define SAMSUNG_RPT_SPACE 2250
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_SAMSUNG
|
#if SEND_SAMSUNG
|
||||||
void IRsend::sendSAMSUNG (unsigned long data, int nbits)
|
void IRsend::sendSAMSUNG (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -48,38 +48,36 @@ void IRsend::sendSAMSUNG (unsigned long data, int nbits)
|
|||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// SAMSUNGs have a repeat only 4 items long
|
// SAMSUNGs have a repeat only 4 items long
|
||||||
//
|
//
|
||||||
#ifdef DECODE_SAMSUNG
|
#if DECODE_SAMSUNG
|
||||||
long IRrecv::decodeSAMSUNG (decode_results *results)
|
bool IRrecv::decodeSAMSUNG (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0;
|
long data = 0;
|
||||||
int offset = 1; // Skip first space
|
int offset = 1; // Skip first space
|
||||||
|
|
||||||
// Initial mark
|
// Initial mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) return false ;
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
// Check for repeat
|
// Check for repeat
|
||||||
if (irparams.rawlen == 4 &&
|
if ( (irparams.rawlen == 4)
|
||||||
MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE) &&
|
&& MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE)
|
||||||
MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)) {
|
&& MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)
|
||||||
results->bits = 0;
|
) {
|
||||||
results->value = REPEAT;
|
results->bits = 0;
|
||||||
|
results->value = REPEAT;
|
||||||
results->decode_type = SAMSUNG;
|
results->decode_type = SAMSUNG;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (irparams.rawlen < 2 * SAMSUNG_BITS + 4) return false ;
|
if (irparams.rawlen < (2 * SAMSUNG_BITS) + 4) return false ;
|
||||||
|
|
||||||
// Initial space
|
// Initial space
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) return false ;
|
if (!MATCH_SPACE(results->rawbuf[offset++], SAMSUNG_HDR_SPACE)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
for (int i = 0; i < SAMSUNG_BITS; i++) {
|
for (int i = 0; i < SAMSUNG_BITS; i++) {
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], SAMSUNG_BIT_MARK)) return false ;
|
||||||
|
|
||||||
offset++;
|
|
||||||
|
|
||||||
if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) data = (data << 1) | 1 ;
|
if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) data = (data << 1) | 1 ;
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) data <<= 1 ;
|
else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) data = (data << 1) | 0 ;
|
||||||
else return false ;
|
else return false ;
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|||||||
99
ir_Sanyo.cpp
99
ir_Sanyo.cpp
@@ -12,68 +12,65 @@
|
|||||||
// I think this is a Sanyo decoder: Serial = SA 8650B
|
// I think this is a Sanyo decoder: Serial = SA 8650B
|
||||||
// Looks like Sony except for timings, 48 chars of data and time/space different
|
// Looks like Sony except for timings, 48 chars of data and time/space different
|
||||||
|
|
||||||
#define SANYO_BITS 12
|
#define SANYO_BITS 12
|
||||||
|
#define SANYO_HDR_MARK 3500 // seen range 3500
|
||||||
#define SANYO_HDR_MARK 3500 // seen range 3500
|
#define SANYO_HDR_SPACE 950 // seen 950
|
||||||
#define SANYO_HDR_SPACE 950 // seen 950
|
#define SANYO_ONE_MARK 2400 // seen 2400
|
||||||
#define SANYO_ONE_MARK 2400 // seen 2400
|
#define SANYO_ZERO_MARK 700 // seen 700
|
||||||
#define SANYO_ZERO_MARK 700 // seen 700
|
#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
|
||||||
#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
|
#define SANYO_RPT_LENGTH 45000
|
||||||
#define SANYO_RPT_LENGTH 45000
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_SANYO
|
#if DECODE_SANYO
|
||||||
long IRrecv::decodeSanyo (decode_results *results)
|
bool IRrecv::decodeSanyo (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0;
|
long data = 0;
|
||||||
if (irparams.rawlen < 2 * SANYO_BITS + 2) return false ;
|
int offset = 0; // Skip first space <-- CHECK THIS!
|
||||||
int offset = 0; // Skip first space
|
|
||||||
// Initial space
|
if (irparams.rawlen < (2 * SANYO_BITS) + 2) return false ;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
|
// Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
|
||||||
Serial.print("IR Gap: ");
|
Serial.print("IR Gap: ");
|
||||||
Serial.println( results->rawbuf[offset]);
|
Serial.println( results->rawbuf[offset]);
|
||||||
Serial.println( "test against:");
|
Serial.println( "test against:");
|
||||||
Serial.println(results->rawbuf[offset]);
|
Serial.println(results->rawbuf[offset]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
|
// Initial space
|
||||||
// Serial.print("IR Gap found: ");
|
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
|
||||||
results->bits = 0;
|
//Serial.print("IR Gap found: ");
|
||||||
results->value = REPEAT;
|
results->bits = 0;
|
||||||
results->decode_type = SANYO;
|
results->value = REPEAT;
|
||||||
return true;
|
results->decode_type = SANYO;
|
||||||
}
|
return true;
|
||||||
offset++;
|
}
|
||||||
|
offset++;
|
||||||
|
|
||||||
// Initial mark
|
// Initial mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
// Skip Second Mark
|
// Skip Second Mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
while (offset + 1 < irparams.rawlen) {
|
while (offset + 1 < irparams.rawlen) {
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], SANYO_HDR_SPACE)) break ;
|
if (!MATCH_SPACE(results->rawbuf[offset++], SANYO_HDR_SPACE)) break ;
|
||||||
offset++;
|
|
||||||
if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ;
|
|
||||||
else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data <<= 1 ;
|
|
||||||
else return false ;
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Success
|
if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ;
|
||||||
results->bits = (offset - 1) / 2;
|
else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data = (data << 1) | 0 ;
|
||||||
if (results->bits < 12) {
|
else return false ;
|
||||||
results->bits = 0;
|
offset++;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
results->value = data;
|
// Success
|
||||||
results->decode_type = SANYO;
|
results->bits = (offset - 1) / 2;
|
||||||
return true;
|
if (results->bits < 12) {
|
||||||
|
results->bits = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
results->value = data;
|
||||||
|
results->decode_type = SANYO;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
62
ir_Sharp.cpp
62
ir_Sharp.cpp
@@ -9,63 +9,63 @@
|
|||||||
// SSSS H H A A R R P
|
// SSSS H H A A R R P
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
// Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand )
|
// Sharp and DISH support by Todd Treece: http://unionbridge.org/design/ircommand
|
||||||
//
|
//
|
||||||
// The send function has the necessary repeat built in because of the need to
|
// The send function has the necessary repeat built in because of the need to
|
||||||
// invert the signal.
|
// invert the signal.
|
||||||
//
|
//
|
||||||
// Sharp protocol documentation:
|
// Sharp protocol documentation:
|
||||||
// http://www.sbprojects.com/knowledge/ir/sharp.htm
|
// http://www.sbprojects.com/knowledge/ir/sharp.htm
|
||||||
//
|
//
|
||||||
// Here is the LIRC file I found that seems to match the remote codes from the
|
// Here is the LIRC file I found that seems to match the remote codes from the
|
||||||
// oscilloscope:
|
// oscilloscope:
|
||||||
// Sharp LCD TV:
|
// Sharp LCD TV:
|
||||||
// http://lirc.sourceforge.net/remotes/sharp/GA538WJSA
|
// http://lirc.sourceforge.net/remotes/sharp/GA538WJSA
|
||||||
|
|
||||||
#define SHARP_BITS 15
|
#define SHARP_BITS 15
|
||||||
|
#define SHARP_BIT_MARK 245
|
||||||
|
#define SHARP_ONE_SPACE 1805
|
||||||
|
#define SHARP_ZERO_SPACE 795
|
||||||
|
#define SHARP_GAP 600000
|
||||||
|
#define SHARP_RPT_SPACE 3000
|
||||||
|
|
||||||
#define SHARP_BIT_MARK 245
|
#define SHARP_TOGGLE_MASK 0x3FF
|
||||||
#define SHARP_ONE_SPACE 1805
|
|
||||||
#define SHARP_ZERO_SPACE 795
|
|
||||||
#define SHARP_GAP 600000
|
|
||||||
#define SHARP_TOGGLE_MASK 0x3FF
|
|
||||||
#define SHARP_RPT_SPACE 3000
|
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_SHARP
|
#if SEND_SHARP
|
||||||
void IRsend::sendSharpRaw (unsigned long data, int nbits)
|
void IRsend::sendSharpRaw (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
unsigned long invertdata = data ^ SHARP_TOGGLE_MASK;
|
enableIROut(38);
|
||||||
enableIROut(38);
|
|
||||||
|
|
||||||
// Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
|
// Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
|
||||||
// much more reliable. That's the exact behaviour of CD-S6470 remote control.
|
// much more reliable. That's the exact behaviour of CD-S6470 remote control.
|
||||||
for (int n = 0; n < 3; n++) {
|
for (int n = 0; n < 3; n++) {
|
||||||
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
|
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
|
||||||
if (data & mask) {
|
if (data & mask) {
|
||||||
mark(SHARP_BIT_MARK);
|
mark(SHARP_BIT_MARK);
|
||||||
space(SHARP_ONE_SPACE);
|
space(SHARP_ONE_SPACE);
|
||||||
} else {
|
} else {
|
||||||
mark(SHARP_BIT_MARK);
|
mark(SHARP_BIT_MARK);
|
||||||
space(SHARP_ZERO_SPACE);
|
space(SHARP_ZERO_SPACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mark(SHARP_BIT_MARK);
|
mark(SHARP_BIT_MARK);
|
||||||
space(SHARP_ZERO_SPACE);
|
space(SHARP_ZERO_SPACE);
|
||||||
delay(40);
|
delay(40);
|
||||||
|
|
||||||
data = data ^ SHARP_TOGGLE_MASK;
|
data = data ^ SHARP_TOGGLE_MASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
// Sharp send compatible with data obtained through decodeSharp()
|
// Sharp send compatible with data obtained through decodeSharp()
|
||||||
// ^^^^^^^^^^^^^ FUNCTION MISSING!
|
// ^^^^^^^^^^^^^ FUNCTION MISSING!
|
||||||
//
|
//
|
||||||
|
#if SEND_SHARP
|
||||||
void IRsend::sendSharp (unsigned int address, unsigned int command)
|
void IRsend::sendSharp (unsigned int address, unsigned int command)
|
||||||
{
|
{
|
||||||
sendSharpRaw((address << 10) | (command << 2) | 2, 15);
|
sendSharpRaw((address << 10) | (command << 2) | 2, SHARP_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
22
ir_Sony.cpp
22
ir_Sony.cpp
@@ -18,7 +18,7 @@
|
|||||||
#define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround
|
#define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_SONY
|
#if SEND_SONY
|
||||||
void IRsend::sendSony (unsigned long data, int nbits)
|
void IRsend::sendSony (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -44,12 +44,13 @@ void IRsend::sendSony (unsigned long data, int nbits)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_SONY
|
#if DECODE_SONY
|
||||||
long IRrecv::decodeSony (decode_results *results)
|
bool IRrecv::decodeSony (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0;
|
long data = 0;
|
||||||
if (irparams.rawlen < 2 * SONY_BITS + 2) return false ;
|
int offset = 0; // Dont skip first space, check its size
|
||||||
int offset = 0; // Dont skip first space, check its size
|
|
||||||
|
if (irparams.rawlen < (2 * SONY_BITS) + 2) return false ;
|
||||||
|
|
||||||
// Some Sony's deliver repeats fast after first
|
// Some Sony's deliver repeats fast after first
|
||||||
// unfortunately can't spot difference from of repeat from two fast clicks
|
// unfortunately can't spot difference from of repeat from two fast clicks
|
||||||
@@ -69,14 +70,13 @@ long IRrecv::decodeSony (decode_results *results)
|
|||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
// Initial mark
|
// Initial mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], SONY_HDR_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
while (offset + 1 < irparams.rawlen) {
|
while (offset + 1 < irparams.rawlen) {
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) break ;
|
if (!MATCH_SPACE(results->rawbuf[offset++], SONY_HDR_SPACE)) break ;
|
||||||
offset++;
|
|
||||||
if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) data = (data << 1) | 1 ;
|
if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) data = (data << 1) | 1 ;
|
||||||
else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) data <<= 1 ;
|
else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) data = (data << 1) | 0 ;
|
||||||
else return false ;
|
else return false ;
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#define WHYNTER_ZERO_SPACE 750
|
#define WHYNTER_ZERO_SPACE 750
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef SEND_WHYNTER
|
#if SEND_WHYNTER
|
||||||
void IRsend::sendWhynter (unsigned long data, int nbits)
|
void IRsend::sendWhynter (unsigned long data, int nbits)
|
||||||
{
|
{
|
||||||
// Set IR carrier frequency
|
// Set IR carrier frequency
|
||||||
@@ -51,35 +51,30 @@ void IRsend::sendWhynter (unsigned long data, int nbits)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//+=============================================================================
|
//+=============================================================================
|
||||||
#ifdef DECODE_WHYNTER
|
#if DECODE_WHYNTER
|
||||||
long IRrecv::decodeWhynter (decode_results *results)
|
bool IRrecv::decodeWhynter (decode_results *results)
|
||||||
{
|
{
|
||||||
long data = 0;
|
long data = 0;
|
||||||
|
int offset = 1; // skip initial space
|
||||||
|
|
||||||
if (irparams.rawlen < 2 * WHYNTER_BITS + 6) return false ;
|
// Check we have the right amount of data
|
||||||
|
if (irparams.rawlen < (2 * WHYNTER_BITS) + 6) return false ;
|
||||||
|
|
||||||
int offset = 1; // skip initial space
|
// Sequence begins with a bit mark and a zero space
|
||||||
|
if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_BIT_MARK )) return false ;
|
||||||
// sequence begins with a bit mark and a zero space
|
if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_ZERO_SPACE)) return false ;
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) return false ;
|
|
||||||
offset++;
|
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) return false ;
|
|
||||||
offset++;
|
|
||||||
|
|
||||||
// header mark and space
|
// header mark and space
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) return false ;
|
if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_HDR_MARK )) return false ;
|
||||||
offset++;
|
if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_HDR_SPACE)) return false ;
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) return false ;
|
|
||||||
offset++;
|
|
||||||
|
|
||||||
// data bits
|
// data bits
|
||||||
for (int i = 0; i < WHYNTER_BITS; i++) {
|
for (int i = 0; i < WHYNTER_BITS; i++) {
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) return false ;
|
if (!MATCH_MARK(results->rawbuf[offset++], WHYNTER_BIT_MARK)) return false ;
|
||||||
offset++;
|
|
||||||
|
|
||||||
if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) data = (data << 1) | 1 ;
|
if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE )) data = (data << 1) | 1 ;
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) data <<= 1 ;
|
else if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) data = (data << 1) | 0 ;
|
||||||
else return false ;
|
else return false ;
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user