More cleanup and a few minor optimisations

This commit is contained in:
Bluechip
2015-06-20 20:27:59 +01:00
parent 6087fabfe1
commit c58507655c
14 changed files with 526 additions and 470 deletions

View File

@@ -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
#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) ;
int MATCH_MARK (int measured_ticks, int desired_us) ;
int MATCH (int measured, int desired) ;
// An enumerated list of all supported formats
// You do NOT need to remove entries from this list when disabling protocols!
//
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
#ifdef DEBUG
//
#if DEBUG
# define DBG_PRINT(...) Serial.print(__VA_ARGS__)
# define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
#else
@@ -20,77 +107,11 @@ int MATCH (int measured, int desired) ;
#endif
//------------------------------------------------------------------------------
#define SEND_NEC
#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
// Mark & Space matching functions
//
typedef
enum {
UNKNOWN = -1,
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;
int MATCH (int measured, int desired) ;
int MATCH_MARK (int measured_ticks, int desired_us) ;
int MATCH_SPACE (int measured_ticks, int desired_us) ;
//------------------------------------------------------------------------------
// Results returned from the decoder
@@ -99,130 +120,168 @@ class decode_results
{
public:
decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
unsigned int address; // Used by Panasonic & Sharp
unsigned long value; // Decoded value
unsigned int address; // Used by Panasonic & Sharp [16-bits]
unsigned long value; // Decoded value [max 32-bits]
int bits; // Number of bits in decoded value
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
};
//------------------------------------------------------------------------------
// 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
{
public:
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
public:
IRrecv (int recvpin) ;
#ifdef DECODE_WHYNTER
long decodeWhynter(decode_results *results);
#endif
void blink13 (int blinkflag) ;
int decode (decode_results *results) ;
void enableIRIn ( ) ;
void resume ( ) ;
#ifdef DECODE_AIWA_RC_T501
long decodeAiwaRCT501(decode_results *results);
#endif
long decodeHash(decode_results *results);
int compare(unsigned int oldval, unsigned int newval);
private:
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
{
public:
IRsend() {}
void sendRaw(unsigned int buf[], int len, int hz);
#ifdef SEND_RC5
void sendRC5(unsigned long data, int nbits);
#endif
#ifdef SEND_RC6
void sendRC6(unsigned long data, int nbits);
#endif
#ifdef SEND_WHYNTER
void sendWhynter(unsigned long data, int nbits);
#endif
#ifdef SEND_NEC
void sendNEC(unsigned long data, int nbits);
#endif
#ifdef SEND_SONY
void sendSony(unsigned long data, int nbits);
// Neither Sanyo nor Mitsubishi send is implemented yet
// void sendSanyo(unsigned long data, int nbits);
// void sendMitsubishi(unsigned long data, int nbits);
#endif
#ifdef SEND_DISH
void sendDISH(unsigned long data, int nbits);
#endif
#ifdef SEND_SHARP
void sendSharpRaw(unsigned long data, int nbits);
void sendSharp(unsigned int address, unsigned int command);
#endif
#ifdef SEND_PANASONIC
void sendPanasonic(unsigned int address, unsigned long data);
#endif
#ifdef SEND_JVC
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.
#endif
#ifdef SEND_AIWA_RC_T501
void sendAiwaRCT501(int code);
#endif
#ifdef SEND_SAMSUNG
void sendSAMSUNG(unsigned long data, int nbits);
#endif
void enableIROut(int khz);
VIRTUAL void mark(int usec);
VIRTUAL void space(int usec);
public:
IRsend () { }
void enableIROut (int khz) ;
void mark (int usec) ;
void space (int usec) ;
void sendRaw (unsigned int buf[], int len, int hz) ;
//......................................................................
# if SEND_RC5
void sendRC5 (unsigned long data, int nbits) ;
# endif
# if SEND_RC6
void sendRC6 (unsigned long data, int nbits) ;
# endif
//......................................................................
# if SEND_NEC
void sendNEC (unsigned long data, int nbits) ;
# endif
//......................................................................
# if SEND_SONY
void sendSony (unsigned long data, int nbits) ;
# endif
//......................................................................
# if SEND_PANASONIC
void sendPanasonic (unsigned int address, unsigned long data) ;
# endif
//......................................................................
# if SEND_JVC
// JVC does NOT repeat by sending a separate code (like NEC does).
// The JVC protocol repeats by skipping the header.
// To send a JVC repeat signal, send the original code value
// and set 'repeat' to true
void sendJVC (unsigned long data, int nbits, bool repeat) ;
# endif
//......................................................................
# if SEND_SAMSUNG
void sendSAMSUNG (unsigned long data, int nbits) ;
# endif
//......................................................................
# if SEND_WHYNTER
void sendWhynter (unsigned long data, int nbits) ;
# 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

View File

@@ -24,7 +24,7 @@
#define AIWA_RC_T501_ZERO_SPACE 1700
//+=============================================================================
#ifdef SEND_AIWA_RC_T501
#if SEND_AIWA_RC_T501
void IRsend::sendAiwaRCT501 (int code)
{
unsigned long pre = 0x0227EEC0; // 26-bits
@@ -48,7 +48,8 @@ void IRsend::sendAiwaRCT501 (int code)
// it only send 15bits and ignores the top bit
// then uses TOPBIT which is 0x80000000 to check the bit code
// I suspect TOPBIT should be changed to 0x00008000
// Skip firts code bit
// Skip first code bit
code <<= 1;
// Send code
for (int i = 0; i < 15; i++) {
@@ -57,6 +58,7 @@ void IRsend::sendAiwaRCT501 (int code)
else space(AIWA_RC_T501_ZERO_SPACE) ;
code <<= 1;
}
//-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
// POST-DATA, 1 bit, 0x0
@@ -69,40 +71,36 @@ void IRsend::sendAiwaRCT501 (int code)
#endif
//+=============================================================================
#ifdef DECODE_AIWA_RC_T501
long IRrecv::decodeAiwaRCT501 (decode_results *results)
#if DECODE_AIWA_RC_T501
bool IRrecv::decodeAiwaRCT501 (decode_results *results)
{
int data = 0;
int offset = 1; // skip first garbage read
int data = 0;
int offset = 1;
// Check SIZE
if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ;
// Check SIZE
if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ;
// Check HDR
if (!MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_HDR_MARK)) return false ;
offset++;
// Check HDR Mark/Space
if (!MATCH_MARK (results->rawbuf[offset++], AIWA_RC_T501_HDR_MARK )) return false ;
if (!MATCH_SPACE(results->rawbuf[offset++], AIWA_RC_T501_HDR_SPACE)) return false ;
// Check HDR space
if (!MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_HDR_SPACE)) return false ;
offset++;
offset += 26; // skip pre-data - optional
while(offset < irparams.rawlen - 4) {
if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ;
else return false ;
offset += 26; // skip pre-data - optional
while(offset < irparams.rawlen - 4) {
if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ;
else return false ;
// ONE & ZERO
if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ;
else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) data = (data << 1) | 0 ;
else break ; // End of one & zero detected
offset++;
}
// ONE & ZERO
if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ;
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;
if (results->bits < 42) return false ;
results->bits = (offset - 1) / 2;
if (results->bits < 42) return false ;
results->value = data;
results->decode_type = AIWA_RC_T501;
return true;
results->value = data;
results->decode_type = AIWA_RC_T501;
return true;
}
#endif

View File

@@ -21,35 +21,33 @@
// DISH NETWORK (echostar 301):
// http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
#define DISH_BITS 16
#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 DISH_BITS 16
#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
//+=============================================================================
#ifdef SEND_DISH
#if SEND_DISH
void IRsend::sendDISH (unsigned long data, int nbits)
{
// Set IR carrier frequency
enableIROut(56);
// Set IR carrier frequency
enableIROut(56);
mark(DISH_HDR_MARK);
space(DISH_HDR_SPACE);
mark(DISH_HDR_MARK);
space(DISH_HDR_SPACE);
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
if (data & mask) {
mark(DISH_BIT_MARK);
space(DISH_ONE_SPACE);
} else {
mark(DISH_BIT_MARK);
space(DISH_ZERO_SPACE);
}
}
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
if (data & mask) {
mark(DISH_BIT_MARK);
space(DISH_ONE_SPACE);
} else {
mark(DISH_BIT_MARK);
space(DISH_ZERO_SPACE);
}
}
}
#endif

View File

@@ -18,8 +18,13 @@
#define JVC_RPT_LENGTH 60000
//+=============================================================================
#ifdef SEND_JVC
void IRsend::sendJVC (unsigned long data, int nbits, int repeat)
// JVC does NOT repeat by sending a separate code (like NEC does).
// 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
enableIROut(38);
@@ -48,37 +53,36 @@ void IRsend::sendJVC (unsigned long data, int nbits, int repeat)
#endif
//+=============================================================================
#ifdef DECODE_JVC
long IRrecv::decodeJVC (decode_results *results)
#if DECODE_JVC
bool IRrecv::decodeJVC (decode_results *results)
{
long data = 0;
int offset = 1; // Skip first space
// Check for repeat
if (irparams.rawlen - 1 == 33 &&
MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK) &&
MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)) {
results->bits = 0;
results->value = REPEAT;
if ( (irparams.rawlen - 1 == 33)
&& MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)
&& MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)
) {
results->bits = 0;
results->value = REPEAT;
results->decode_type = JVC;
return true;
}
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], JVC_HDR_MARK)) return false ;
if (irparams.rawlen < 2 * JVC_BITS + 1 ) return false ;
if (irparams.rawlen < (2 * JVC_BITS) + 1 ) return false ;
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) return false ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset++], JVC_HDR_SPACE)) return false ;
for (int i = 0; i < JVC_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], JVC_BIT_MARK)) return false ;
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 ;
offset++;
}

View File

@@ -19,24 +19,24 @@
#define LG_RPT_LENGTH 60000
//+=============================================================================
#ifdef DECODE_LG
long IRrecv::decodeLG (decode_results *results)
#if DECODE_LG
bool IRrecv::decodeLG (decode_results *results)
{
long data = 0;
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) return false ;
offset++;
if (irparams.rawlen < 2 * LG_BITS + 1 ) return false ;
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) return false ;
offset++;
// Check we have the right amount of data
if (irparams.rawlen < (2 * LG_BITS) + 1 ) return false ;
// Initial mark/space
if (!MATCH_MARK(results->rawbuf[offset++], LG_HDR_MARK)) return false ;
if (!MATCH_SPACE(results->rawbuf[offset++], LG_HDR_SPACE)) return false ;
for (int i = 0; i < LG_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], LG_BIT_MARK)) return false ;
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 ;
offset++;
}
@@ -45,8 +45,8 @@ long IRrecv::decodeLG (decode_results *results)
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
// Success
results->bits = LG_BITS;
results->value = data;
results->bits = LG_BITS;
results->value = data;
results->decode_type = LG;
return true;
}

View File

@@ -23,8 +23,8 @@
// #define MITSUBISHI_RPT_LENGTH 45000
//+=============================================================================
#ifdef DECODE_MITSUBISHI
long IRrecv::decodeMitsubishi (decode_results *results)
#if DECODE_MITSUBISHI
bool IRrecv::decodeMitsubishi (decode_results *results)
{
// Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
long data = 0;

View File

@@ -18,7 +18,7 @@
#define NEC_RPT_SPACE 2250
//+=============================================================================
#ifdef SEND_NEC
#if SEND_NEC
void IRsend::sendNEC (unsigned long data, int nbits)
{
// Set IR carrier frequency
@@ -48,8 +48,8 @@ void IRsend::sendNEC (unsigned long data, int nbits)
//+=============================================================================
// NECs have a repeat only 4 items long
//
#ifdef DECODE_NEC
long IRrecv::decodeNEC (decode_results *results)
#if DECODE_NEC
bool IRrecv::decodeNEC (decode_results *results)
{
long data = 0; // We decode in to here; Start with nothing
int offset = 1; // Index in to results; Skip first entry!?

View File

@@ -9,15 +9,15 @@
// P A A N N A A SSSS OOO N N IIIII CCCC
//==============================================================================
#define PANASONIC_BITS 48
#define PANASONIC_HDR_MARK 3502
#define PANASONIC_HDR_SPACE 1750
#define PANASONIC_BIT_MARK 502
#define PANASONIC_ONE_SPACE 1244
#define PANASONIC_ZERO_SPACE 400
#define PANASONIC_BITS 48
#define PANASONIC_HDR_MARK 3502
#define PANASONIC_HDR_SPACE 1750
#define PANASONIC_BIT_MARK 502
#define PANASONIC_ONE_SPACE 1244
#define PANASONIC_ZERO_SPACE 400
//+=============================================================================
#ifdef SEND_PANASONIC
#if SEND_PANASONIC
void IRsend::sendPanasonic (unsigned int address, unsigned long data)
{
// Set IR carrier frequency
@@ -48,16 +48,14 @@ void IRsend::sendPanasonic (unsigned int address, unsigned long data)
#endif
//+=============================================================================
#ifdef DECODE_PANASONIC
long IRrecv::decodePanasonic (decode_results *results)
#if DECODE_PANASONIC
bool IRrecv::decodePanasonic (decode_results *results)
{
unsigned long long data = 0;
int offset = 1;
unsigned long long data = 0;
int offset = 1;
if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_MARK )) return false ;
if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_SPACE)) return false ;
// decode address
for (int i = 0; i < PANASONIC_BITS; i++) {

View File

@@ -12,25 +12,30 @@
//
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 = results->rawbuf[*offset];
int val = ((*offset) % 2) ? MARK : SPACE;
int correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS;
int width;
int val;
int correction;
int avail;
int avail;
if (MATCH(width, t1 + correction)) avail = 1 ;
else if (MATCH(width, 2*t1 + correction)) avail = 2 ;
else if (MATCH(width, 3*t1 + correction)) avail = 3 ;
else return -1 ;
if (*offset >= results->rawlen) return SPACE ; // After end of recorded buffer, assume SPACE.
width = results->rawbuf[*offset];
val = ((*offset) % 2) ? MARK : SPACE;
correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS;
(*used)++;
if (*used >= avail) {
*used = 0;
(*offset)++;
}
if (MATCH(width, ( t1) + correction)) avail = 1 ;
else if (MATCH(width, (2*t1) + correction)) avail = 2 ;
else if (MATCH(width, (3*t1) + correction)) avail = 3 ;
else return -1 ;
DBG_PRINTLN( (val == MARK) ? "MARK" : "SPACE" );
return val;
(*used)++;
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)
//
#define MIN_RC5_SAMPLES 11
#define RC5_T1 889
#define RC5_RPT_LENGTH 46000
#define MIN_RC5_SAMPLES 11
#define RC5_T1 889
#define RC5_RPT_LENGTH 46000
//+=============================================================================
#ifdef SEND_RC5
#if SEND_RC5
void IRsend::sendRC5 (unsigned long data, int nbits)
{
// Set IR carrier frequency
@@ -74,25 +79,28 @@ void IRsend::sendRC5 (unsigned long data, int nbits)
#endif
//+=============================================================================
#ifdef DECODE_RC5
long IRrecv::decodeRC5 (decode_results *results)
#if DECODE_RC5
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 ;
int offset = 1; // Skip gap space
long data = 0;
int used = 0;
// Get start bits
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) != 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
else if (levelA == MARK && levelB == SPACE) data <<= 1 ; // zero bit
else return false ;
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 ;
else if ((levelA == MARK ) && (levelB == SPACE)) data = (data << 1) | 0 ;
else return false ;
}
// Success
@@ -112,13 +120,13 @@ long IRrecv::decodeRC5 (decode_results *results)
//
// NB : Caller needs to take care of flipping the toggle bit
//
#define MIN_RC6_SAMPLES 1
#define RC6_HDR_MARK 2666
#define RC6_HDR_SPACE 889
#define RC6_T1 444
#define RC6_RPT_LENGTH 46000
#define MIN_RC6_SAMPLES 1
#define RC6_HDR_MARK 2666
#define RC6_HDR_SPACE 889
#define RC6_T1 444
#define RC6_RPT_LENGTH 46000
#ifdef SEND_RC6
#if SEND_RC6
void IRsend::sendRC6 (unsigned long data, int nbits)
{
// Set IR carrier frequency
@@ -150,46 +158,47 @@ void IRsend::sendRC6 (unsigned long data, int nbits)
#endif
//+=============================================================================
#ifdef DECODE_RC6
long IRrecv::decodeRC6 (decode_results *results)
#if DECODE_RC6
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 ;
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) return false ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) return false ;
offset++;
long data = 0;
int used = 0;
if (!MATCH_MARK(results->rawbuf[offset++], RC6_HDR_MARK)) return false ;
if (!MATCH_SPACE(results->rawbuf[offset++], RC6_HDR_SPACE)) return false ;
// Get start bit (1)
if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return false ;
if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return false ;
int 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);
if (nbits == 3) {
// T bit is double wide; make sure second half matches
if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return false;
}
levelB = getRClevel(results, &offset, &used, RC6_T1);
if (nbits == 3) {
// T bit is double wide; make sure second half matches
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
else return false ; // Error
if ((levelA == MARK ) && (levelB == SPACE)) data = (data << 1) | 1 ; // inverted compared to RC5
else if ((levelA == SPACE) && (levelB == MARK )) data = (data << 1) | 0 ; // ...
else return false ; // Error
}
// Success
results->bits = nbits;
results->value = data;
results->bits = nbits;
results->value = data;
results->decode_type = RC6;
return true;
}

View File

@@ -18,7 +18,7 @@
#define SAMSUNG_RPT_SPACE 2250
//+=============================================================================
#ifdef SEND_SAMSUNG
#if SEND_SAMSUNG
void IRsend::sendSAMSUNG (unsigned long data, int nbits)
{
// Set IR carrier frequency
@@ -48,38 +48,36 @@ void IRsend::sendSAMSUNG (unsigned long data, int nbits)
//+=============================================================================
// SAMSUNGs have a repeat only 4 items long
//
#ifdef DECODE_SAMSUNG
long IRrecv::decodeSAMSUNG (decode_results *results)
#if DECODE_SAMSUNG
bool IRrecv::decodeSAMSUNG (decode_results *results)
{
long data = 0;
int offset = 1; // Skip first space
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) return false ;
offset++;
// Check for repeat
if (irparams.rawlen == 4 &&
MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE) &&
MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)) {
results->bits = 0;
results->value = REPEAT;
if ( (irparams.rawlen == 4)
&& MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE)
&& MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)
) {
results->bits = 0;
results->value = REPEAT;
results->decode_type = SAMSUNG;
return true;
}
if (irparams.rawlen < 2 * SAMSUNG_BITS + 4) return false ;
if (irparams.rawlen < (2 * SAMSUNG_BITS) + 4) return false ;
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) return false ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset++], SAMSUNG_HDR_SPACE)) return false ;
for (int i = 0; i < SAMSUNG_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], SAMSUNG_BIT_MARK)) return false ;
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 ;
offset++;
}

View File

@@ -12,68 +12,65 @@
// I think this is a Sanyo decoder: Serial = SA 8650B
// Looks like Sony except for timings, 48 chars of data and time/space different
#define SANYO_BITS 12
#define SANYO_HDR_MARK 3500 // seen range 3500
#define SANYO_HDR_SPACE 950 // seen 950
#define SANYO_ONE_MARK 2400 // seen 2400
#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_RPT_LENGTH 45000
#define SANYO_BITS 12
#define SANYO_HDR_MARK 3500 // seen range 3500
#define SANYO_HDR_SPACE 950 // seen 950
#define SANYO_ONE_MARK 2400 // seen 2400
#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_RPT_LENGTH 45000
//+=============================================================================
#ifdef DECODE_SANYO
long IRrecv::decodeSanyo (decode_results *results)
#if DECODE_SANYO
bool IRrecv::decodeSanyo (decode_results *results)
{
long data = 0;
if (irparams.rawlen < 2 * SANYO_BITS + 2) return false ;
int offset = 0; // Skip first space
// Initial space
long data = 0;
int offset = 0; // Skip first space <-- CHECK THIS!
if (irparams.rawlen < (2 * SANYO_BITS) + 2) return false ;
#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
Serial.print("IR Gap: ");
Serial.println( results->rawbuf[offset]);
Serial.println( "test against:");
Serial.println(results->rawbuf[offset]);
// 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.println( results->rawbuf[offset]);
Serial.println( "test against:");
Serial.println(results->rawbuf[offset]);
#endif
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
// Serial.print("IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
results->decode_type = SANYO;
return true;
}
offset++;
// Initial space
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
//Serial.print("IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
results->decode_type = SANYO;
return true;
}
offset++;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) return false ;
offset++;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
// Skip Second Mark
if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) return false ;
offset++;
// Skip Second Mark
if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
while (offset + 1 < irparams.rawlen) {
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++;
}
while (offset + 1 < irparams.rawlen) {
if (!MATCH_SPACE(results->rawbuf[offset++], SANYO_HDR_SPACE)) break ;
// Success
results->bits = (offset - 1) / 2;
if (results->bits < 12) {
results->bits = 0;
return false;
}
if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ;
else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data = (data << 1) | 0 ;
else return false ;
offset++;
}
results->value = data;
results->decode_type = SANYO;
return true;
// Success
results->bits = (offset - 1) / 2;
if (results->bits < 12) {
results->bits = 0;
return false;
}
results->value = data;
results->decode_type = SANYO;
return true;
}
#endif

View File

@@ -9,63 +9,63 @@
// 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
// invert the signal.
//
// 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
// oscilloscope:
// Sharp LCD TV:
// 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_ONE_SPACE 1805
#define SHARP_ZERO_SPACE 795
#define SHARP_GAP 600000
#define SHARP_TOGGLE_MASK 0x3FF
#define SHARP_RPT_SPACE 3000
#define SHARP_TOGGLE_MASK 0x3FF
//+=============================================================================
#ifdef SEND_SHARP
#if SEND_SHARP
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
// much more reliable. That's the exact behaviour of CD-S6470 remote control.
for (int n = 0; n < 3; n++) {
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
if (data & mask) {
mark(SHARP_BIT_MARK);
space(SHARP_ONE_SPACE);
} else {
mark(SHARP_BIT_MARK);
space(SHARP_ZERO_SPACE);
}
}
// Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
// much more reliable. That's the exact behaviour of CD-S6470 remote control.
for (int n = 0; n < 3; n++) {
for (unsigned long mask = 1 << (nbits - 1); mask; mask >>= 1) {
if (data & mask) {
mark(SHARP_BIT_MARK);
space(SHARP_ONE_SPACE);
} else {
mark(SHARP_BIT_MARK);
space(SHARP_ZERO_SPACE);
}
}
mark(SHARP_BIT_MARK);
space(SHARP_ZERO_SPACE);
delay(40);
mark(SHARP_BIT_MARK);
space(SHARP_ZERO_SPACE);
delay(40);
data = data ^ SHARP_TOGGLE_MASK;
}
data = data ^ SHARP_TOGGLE_MASK;
}
}
#endif
//+=============================================================================
// Sharp send compatible with data obtained through decodeSharp()
// ^^^^^^^^^^^^^ FUNCTION MISSING!
//
#if SEND_SHARP
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

View File

@@ -18,7 +18,7 @@
#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)
{
// Set IR carrier frequency
@@ -44,12 +44,13 @@ void IRsend::sendSony (unsigned long data, int nbits)
#endif
//+=============================================================================
#ifdef DECODE_SONY
long IRrecv::decodeSony (decode_results *results)
#if DECODE_SONY
bool IRrecv::decodeSony (decode_results *results)
{
long data = 0;
if (irparams.rawlen < 2 * SONY_BITS + 2) return false ;
int offset = 0; // Dont skip first space, check its size
long data = 0;
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
// unfortunately can't spot difference from of repeat from two fast clicks
@@ -69,14 +70,13 @@ long IRrecv::decodeSony (decode_results *results)
offset++;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], SONY_HDR_MARK)) return false ;
while (offset + 1 < irparams.rawlen) {
if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) break ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset++], SONY_HDR_SPACE)) break ;
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 ;
offset++;
}

View File

@@ -19,7 +19,7 @@
#define WHYNTER_ZERO_SPACE 750
//+=============================================================================
#ifdef SEND_WHYNTER
#if SEND_WHYNTER
void IRsend::sendWhynter (unsigned long data, int nbits)
{
// Set IR carrier frequency
@@ -51,35 +51,30 @@ void IRsend::sendWhynter (unsigned long data, int nbits)
#endif
//+=============================================================================
#ifdef DECODE_WHYNTER
long IRrecv::decodeWhynter (decode_results *results)
#if DECODE_WHYNTER
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 ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) return false ;
offset++;
// Sequence begins with a bit mark and a zero space
if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_BIT_MARK )) return false ;
if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_ZERO_SPACE)) return false ;
// header mark and space
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) return false ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) return false ;
offset++;
if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_HDR_MARK )) return false ;
if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_HDR_SPACE)) return false ;
// data bits
for (int i = 0; i < WHYNTER_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) return false ;
offset++;
if (!MATCH_MARK(results->rawbuf[offset++], WHYNTER_BIT_MARK)) return false ;
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 return false ;
if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE )) data = (data << 1) | 1 ;
else if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) data = (data << 1) | 0 ;
else return false ;
offset++;
}