本文整理汇总了C++中MATCH_SPACE函数的典型用法代码示例。如果您正苦于以下问题:C++ MATCH_SPACE函数的具体用法?C++ MATCH_SPACE怎么用?C++ MATCH_SPACE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MATCH_SPACE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MATCH_SPACE
long IRrecv::decodeNEC(decode_results *results) {
long data = 0;
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) {
return ERR;
}
offset++;
// Check for repeat
if (irparams.rawlen == 4 &&
MATCH_SPACE(results->rawbuf[offset], NEC_RPT_SPACE) &&
MATCH_MARK(results->rawbuf[offset+1], NEC_BIT_MARK)) {
results->bits = 0;
results->value = REPEAT;
results->decode_type = NEC;
return DECODED;
}
if (irparams.rawlen < 2 * NEC_BITS + 4) {
return ERR;
}
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) {
return ERR;
}
offset++;
for (int i = 0; i < NEC_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) {
return ERR;
}
offset++;
if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) {
data = (data << 1) | 1;
}
else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) {
data <<= 1;
}
else {
return ERR;
}
offset++;
}
// Success
results->bits = NEC_BITS;
results->value = data;
results->decode_type = NEC;
return DECODED;
}
示例2: MATCH_SPACE
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!?
// Check header "mark"
if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) return false ;
offset++;
// Check for repeat
if ( (irparams.rawlen == 4)
&& MATCH_SPACE(results->rawbuf[offset ], NEC_RPT_SPACE)
&& MATCH_MARK (results->rawbuf[offset+1], NEC_BIT_MARK )
) {
results->bits = 0;
results->value = REPEAT;
results->decode_type = NEC;
return true;
}
// Check we have enough data
if (irparams.rawlen < (2 * NEC_BITS) + 4) return false ;
// Check header "space"
if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) return false ;
offset++;
// Build the data
for (int i = 0; i < NEC_BITS; i++) {
// Check data "mark"
if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) return false ;
offset++;
// Suppend this bit
if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE )) data = (data << 1) | 1 ;
else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) data = (data << 1) | 0 ;
else return false ;
offset++;
}
// Success
results->bits = NEC_BITS;
results->value = data;
results->decode_type = NEC;
return true;
}
示例3: while
/*
* Again we use a generic routine because most protocols have the same basic structure. However we need to
* indicate whether or not the protocol varies the length of the mark or the space to indicate a "0" or "1".
* If "Mark_One" is zero. We assume that the length of the space varies. If "Mark_One" is not zero then
* we assume that the length of Mark varies and the value passed as "Space_Zero" is ignored.
* When using variable length Mark, assumes Head_Space==Space_One. If it doesn't, you need a specialized decoder.
*/
bool IRdecodeBase::decodeGeneric(int Raw_Count, int Head_Mark,int Head_Space, int Mark_One, int Mark_Zero, int Space_One,int Space_Zero) {
// If raw samples count or head mark are zero then don't perform these tests.
// Some protocols need to do custom header work.
long data = 0; int Max; int offset;
if (Raw_Count) {if (rawlen != Raw_Count) return RAW_COUNT_ERROR;}
if (Head_Mark) {if (!MATCH_MARK(rawbuf[1],Head_Mark)) return HEADER_MARK_ERROR;}
if (Head_Space) {if (!MATCH_SPACE(rawbuf[2],Head_Space)) return HEADER_SPACE_ERROR;}
if (Mark_One) {//Length of a mark indicates data "0" or "1". Space_Zero is ignored.
offset=2;//skip initial gap plus header Mark.
Max=rawlen;
while (offset < Max) {
if (!MATCH_SPACE(rawbuf[offset], Space_One)) return DATA_SPACE_ERROR;
offset++;
if (MATCH_MARK(rawbuf[offset], Mark_One)) {
data = (data << 1) | 1;
}
else if (MATCH_MARK(rawbuf[offset], Mark_Zero)) {
data <<= 1;
}
else return DATA_MARK_ERROR;
offset++;
}
bits = (offset - 1) / 2;
}
else {//Mark_One was 0 therefore length of a space indicates data "0" or "1".
Max=rawlen-1; //ignore stop bit
offset=3;//skip initial gap plus two header items
while (offset < Max) {
if (!MATCH_MARK (rawbuf[offset],Mark_Zero)) return DATA_MARK_ERROR;
offset++;
if (MATCH_SPACE(rawbuf[offset],Space_One)) {
data = (data << 1) | 1;
}
else if (MATCH_SPACE (rawbuf[offset],Space_Zero)) {
data <<= 1;
}
else return DATA_SPACE_ERROR;
offset++;
}
bits = (offset - 1) / 2 -1;//didn't encode stop bit
}
// Success
value = data;
return true;
}
示例4: while
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;
if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) return false ;
int offset = 0; // Skip first space
// Initial space
#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]);
#endif
#if 0
// Not seeing double keys from Mitsubishi
if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
// Serial.print("IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
results->decode_type = MITSUBISHI;
return true;
}
#endif
offset++;
// Typical
// 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
// Initial Space
if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) return false ;
offset++;
while (offset + 1 < irparams.rawlen) {
if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) data = (data << 1) | 1 ;
else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) data <<= 1 ;
else return false ;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) break ;
offset++;
}
// Success
results->bits = (offset - 1) / 2;
if (results->bits < MITSUBISHI_BITS) {
results->bits = 0;
return false;
}
results->value = data;
results->decode_type = MITSUBISHI;
return true;
}
示例5: if
long IRrecv::decodeSamsung(decode_results *results) {
long data = 0;
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) {
return ERR;
}
offset++;
// Check bits
if (irparams.rawlen < 2 * SAMSUNG_BITS + 4) {
return ERR;
}
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) {
return ERR;
}
offset++;
Serial.println("OFFSET");
Serial.println(offset);
for (int i = 0; i < SAMSUNG_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) {
return ERR;
}
offset++;
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 {
return ERR;
}
offset++;
}
// Success
results->bits = SAMSUNG_BITS;
results->value = data;
results->decode_type = SAMSUNG;
return DECODED;
}
示例6: if
long 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 ERR;
}
offset++;
if (irparams.rawlen < 2 * LG_BITS + 1 ) {
return ERR;
}
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) {
return ERR;
}
offset++;
for (int i = 0; i < LG_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) {
return ERR;
}
offset++;
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 {
return ERR;
}
offset++;
}
//Stop bit
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){
return ERR;
}
// Success
results->bits = LG_BITS;
results->value = data;
results->decode_type = LG;
return DECODED;
}
示例7: while
long IRrecv::decodeSony(decode_results *results) {
long data = 0;
if (irparams.rawlen < 2 * SONY_BITS + 2) {
return ERR;
}
int offset = 0; // Dont skip first space, check its size
// Some Sony's deliver repeats fast after first
// unfortunately can't spot difference from of repeat from two fast clicks
if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) {
// Serial.print("IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
#ifdef SANYO
results->decode_type = SANYO;
#else
results->decode_type = UNKNOWN;
#endif
return DECODED;
}
offset++;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) {
return ERR;
}
offset++;
while (offset + 1 < irparams.rawlen) {
if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) {
break;
}
offset++;
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 {
return ERR;
}
offset++;
}
// Success
results->bits = (offset - 1) / 2;
if (results->bits < 12) {
results->bits = 0;
return ERR;
}
results->value = data;
results->decode_type = SONY;
return DECODED;
}
示例8: IRrecv_decodeRC6
u32 IRrecv_decodeRC6(decode_results *results)
{
u16 offset = 1; // Skip first space
u32 data = 0;
u16 used = 0;
u16 nbits;
u16 levelA, levelB; // Next two levels
if (results->rawlen < MIN_RC6_SAMPLES) return ERR;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) return ERR;
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) return ERR;
offset++;
// Get start bit (1)
if (IRrecv_getRClevel(results, &offset, &used, RC6_T1) != MARK) return ERR;
if (IRrecv_getRClevel(results, &offset, &used, RC6_T1) != SPACE) return ERR;
for (nbits = 0; offset < results->rawlen; nbits++)
{
levelA = IRrecv_getRClevel(results, &offset, &used, RC6_T1);
if (nbits == 3)
{
// T bit is double wide; make sure second half matches
if (levelA != IRrecv_getRClevel(results, &offset, &used, RC6_T1)) return ERR;
}
levelB = IRrecv_getRClevel(results, &offset, &used, RC6_T1);
if (nbits == 3)
{
// T bit is double wide; make sure second half matches
if (levelB != IRrecv_getRClevel(results, &offset, &used, RC6_T1)) return ERR;
}
if (levelA == MARK && levelB == SPACE)
{
// reversed compared to RC5
// 1 bit
data = (data << 1) | 1;
}
else if (levelA == SPACE && levelB == MARK)
{
// zero bit
data <<= 1;
}
else
{
return ERR; // Error
}
}
// Success
results->bits = nbits;
results->value = data;
results->decode_type = RC6;
return DECODED;
}
示例9: MATCH_SPACE
bool IRrecv::decodeSAMSUNG (decode_results *results)
{
long data = 0;
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;
results->decode_type = SAMSUNG;
return true;
}
if (irparams.rawlen < (2 * SAMSUNG_BITS) + 4) return false ;
// Initial space
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 ;
if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) data = (data << 1) | 1 ;
else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) data = (data << 1) | 0 ;
else return false ;
offset++;
}
// Success
results->bits = SAMSUNG_BITS;
results->value = data;
results->decode_type = SAMSUNG;
return true;
}
示例10: ATTEMPT_MESSAGE
bool IRdecodeNEC::decode(void) {
ATTEMPT_MESSAGE(F("NEC"));
// Check for repeat
if (rawlen == 4 && MATCH_SPACE(rawbuf[2], NEC_RPT_SPACE) &&
MATCH_MARK(rawbuf[3],564)) {
bits = 0;
value = REPEAT;
decode_type = NEC;
return true;
}
if(!decodeGeneric(68, 564*16, 564*8, 0, 564, 564*3, 564)) return false;
decode_type = NEC;
return true;
}
示例11: while
long IRrecv::decodeSony(decode_results *results) {
unsigned long data = 0;
if (irparams.rawlen < 2 * SONY_BITS + 2) {
return ERR;
}
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) {
return ERR;
}
offset++;
while (offset + 1 < irparams.rawlen) {
if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) {
break;
}
offset++;
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 {
return ERR;
}
offset++;
}
// Success
results->bits = (offset - 1) / 2;
if (results->bits < 12) {
results->bits = 0;
return ERR;
}
results->value = data;
results->decode_type = SONY;
/*
for ( debugPos = 0; debugPos < 32; debugPos ++ ) {
if ( (results->value >> (32 - debugPos) ) & 0x1 == 0x1 ) {
results->debugBuffer[debugPos] = 0xff;
}
else {
results->debugBuffer[debugPos] = 0x1;
}
}
*/
return DECODED;
}
示例12: IRrecv_decodePanasonic
u32 IRrecv_decodePanasonic(decode_results *results)
{
//u32 long data = 0; // PIC18F don't have 64-bit type
u32 data = 0;
u16 offset = 1;
u16 i;
if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) {
return ERR;
}
offset++;
if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) {
return ERR;
}
offset++;
// decode address
for (i = 0; i < PANASONIC_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_BIT_MARK)) {
return ERR;
}
if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ONE_SPACE)) {
data = (data << 1) | 1;
} else if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) {
data <<= 1;
} else {
return ERR;
}
offset++;
}
results->value = (u32)data;
results->panasonicAddress = (u16)(data >> 32);
results->decode_type = PANASONIC;
results->bits = PANASONIC_BITS;
return DECODED;
}
示例13: if
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 ;
// Initial mark
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 ;
for (nbits = 0; offset < results->rawlen; nbits++) {
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 ; // 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->decode_type = RC6;
return true;
}
示例14: decodeSony
static long decodeSony(decode_results *results)
{
long data = 0;
if (irparams.rawlen < 2 * SONY_BITS + 2) {
return ERR;
}
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) {
return ERR;
}
offset++;
while (offset + 1 < irparams.rawlen) {
if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) {
break;
}
offset++;
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 {
return ERR;
}
offset++;
}
// Success
results->bits = (offset - 1) / 2;
if (results->bits < 12) {
results->bits = 0;
return ERR;
}
results->value = data;
results->decode_type = SONY;
return DECODED;
}
示例15: IRrecv_decodeMitsubishi
// Looks like Sony except for timings, 48 chars of data and time/space different
u32 IRrecv_decodeMitsubishi(decode_results *results)
{
// SerialPrint(UART,"?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
u32 data = 0;
u16 offset = 0; // Skip first space
if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) {
return ERR;
}
// Initial space
/* 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
SerialPrint(UART,"IR Gap: ");
SerialPrintln( results->rawbuf[offset]);
SerialPrintln( "test against:");
SerialPrintln(results->rawbuf[offset]);
*/
/* Not seeing double keys from Mitsubishi
if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
// SerialPrint(UART,"IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
results->decode_type = MITSUBISHI;
return DECODED;
}
*/
offset++;
// Typical
// 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
// Initial Space
if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) {
return ERR;
}
offset++;
while (offset + 1 < irparams.rawlen) {
if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) {
data = (data << 1) | 1;
}
else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) {
data <<= 1;
}
else {
// SerialPrintln("A"); Serial.println(offset); SerialPrintln(results->rawbuf[offset]);
return ERR;
}
offset++;
if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) {
// SerialPrintln("B"); Serial.println(offset); SerialPrintln(results->rawbuf[offset]);
break;
}
offset++;
}
// Success
results->bits = (offset - 1) / 2;
if (results->bits < MITSUBISHI_BITS) {
results->bits = 0;
return ERR;
}
results->value = data;
results->decode_type = MITSUBISHI;
return DECODED;
}