• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MATCH_SPACE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MATCH_SPACE函数的典型用法代码示例。如果您正苦于以下问题:C++ MATCH_SPACE函数的具体用法?C++ MATCH_SPACE怎么用?C++ MATCH_SPACE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MATCH_SPACE函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:toddtreece,项目名称:Arduino-IRremote,代码行数:47,代码来源:IRremote.cpp


示例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;
}
开发者ID:1OOSUR,项目名称:Arduino-IRremote,代码行数:46,代码来源:ir_NEC.cpp


示例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;
}
开发者ID:radiojam11,项目名称:IRLib,代码行数:53,代码来源:IRLib.cpp


示例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;
}
开发者ID:1OOSUR,项目名称:Arduino-IRremote,代码行数:57,代码来源:ir_Mitsubishi.cpp


示例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;
}
开发者ID:beothorn,项目名称:arduino_sketchbook,代码行数:44,代码来源:IRremote.cpp


示例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;
}
开发者ID:mdillmann,项目名称:goDMD,代码行数:43,代码来源:IRremote.cpp


示例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;
}
开发者ID:sstefanov,项目名称:Arduino-IRremote,代码行数:55,代码来源:IRremote.cpp


示例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;
}
开发者ID:jimgregory,项目名称:pinguino-libraries,代码行数:54,代码来源:IRremote.c


示例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;
}
开发者ID:1OOSUR,项目名称:Arduino-IRremote,代码行数:39,代码来源:ir_Samsung.cpp


示例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;
}
开发者ID:radiojam11,项目名称:IRLib,代码行数:14,代码来源:IRLib.cpp


示例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;
}
开发者ID:billbsing,项目名称:tv-monitor,代码行数:49,代码来源:IRremote.cpp


示例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;
}
开发者ID:jimgregory,项目名称:pinguino-libraries,代码行数:36,代码来源:IRremote.c


示例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;
}
开发者ID:soif,项目名称:MySensors_HSV_RGB_IR,代码行数:43,代码来源:ir_RC5_RC6.cpp


示例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;
}
开发者ID:Mpic,项目名称:avr,代码行数:40,代码来源:irrecv.c


示例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;
}
开发者ID:jimgregory,项目名称:pinguino-libraries,代码行数:65,代码来源:IRremote.c


示例16: while

bool IRRemote::decodeSony(int rawlen)
{
    long data = 0;
    if (rawlen < 2 * SONY_BITS + 2)
    {
        return false;
    }
    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 (_rawbuf[offset] < SONY_DOUBLE_SPACE_USECS)
    {
        // Serial.print("IR Gap found: ");
        _bits = 0;
        _value = REPEAT;
        _decode_type = SANYO;
        return true;
    }
    offset++;

    // Initial mark
    if (!MATCH_MARK(_rawbuf[offset], SONY_HDR_MARK))
    {
        return false;
    }
    offset++;

    while (offset + 1 < rawlen)
    {
        if (!MATCH_SPACE(_rawbuf[offset], SONY_HDR_SPACE))
        {
            break;
        }
        offset++;
        if (MATCH_MARK(_rawbuf[offset], SONY_ONE_MARK))
        {
            data = (data << 1) | 1;
        }
        else if (MATCH_MARK(_rawbuf[offset], SONY_ZERO_MARK))
        {
            data <<= 1;
        }
        else
        {
            return false;
        }
        offset++;
    }

    // Success
    _bits = (offset - 1) / 2;
    if (_bits < 12)
    {
        _bits = 0;
        return false;
    }
    _value = data;
    _decode_type = SONY;
    return true;
}
开发者ID:nihuyaka,项目名称:libarmpit-cortex,代码行数:61,代码来源:IRremote.cpp


示例17: if

/**
* Decodes Samsung air conditioner.
**/
long IRrecv::decodeSamsung(decode_results *results) {
    long data = 0;
    int offset = 0; // Skip first space
// Initial mark
    if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) {
#ifdef DEBUG
        Serial.println("hdr mark fallito");
#endif
        return ERR;
    }
    offset++;

// Check bits
    if (irparams.rawlen < 2 * SAMSUNG_BITS + 2) {
#ifdef DEBUG
        Serial.println("rawlen (irparams.rawlen) troppo corto:");
        Serial.println(irparams.rawlen);
#endif
        return ERR;
    }

// Initial space, coincide con hdrspace quindi non sposto cursore
    if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) {
#ifdef DEBUG
        Serial.println("not match hdr space");
#endif
        return ERR;
    }
//offset++;
    Serial.println("SAMSUNG OFFSET");
    Serial.println(offset);

    for (int i = 0; i < SAMSUNG_BITS; i++) {
        if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) {
#ifdef DEBUG
            Serial.print("ERROR, was at:");
            Serial.println(offset);
#endif
            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 {
#ifdef DEBUG
            Serial.print("ERROR, was at:");
            Serial.println(offset);
#endif
            return ERR;
        }
        offset++;
    }
// Success
    results->bits = SAMSUNG_BITS;
    results->value = data;
    results->decode_type = SAMSUNG;
    return DECODED;
}
开发者ID:shineangelic,项目名称:Domino,代码行数:65,代码来源:IRremote.cpp


示例18: while

// I think this is a Sanyo decoder - serial = SA 8650B
// Looks like Sony except for timings, 48 chars of data and time/space different
long IRrecvSF::decodeSanyo(decode_resultsSF *results) {
  long data = 0;
  if (irparamsSF.rawlen < 2 * SANYO_BITS + 2) {
    return ERR;
  }
  int offset = 0; // Skip first space
  // 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
  Serial.print("IR Gap: ");
  Serial.println( results->rawbuf[offset]);
  Serial.println( "test against:");
  Serial.println(results->rawbuf[offset]);
  */
  if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
    // Serial.print("IR Gap found: ");
    results->bits = 0;
    results->value = REPEAT;
    results->decode_type = SANYO;
    return DECODED;
  }
  offset++;

  // Initial mark
  if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) {
    return ERR;
  }
  offset++;

  // Skip Second Mark
  if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) {
    return ERR;
  }
  offset++;

  while (offset + 1 < irparamsSF.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 ERR;
    }
    offset++;
  }

  // Success
  results->bits = (offset - 1) / 2;
  if (results->bits < 12) {
    results->bits = 0;
    return ERR;
  }
  results->value = data;
  results->decode_type = SANYO;
  return DECODED;
}
开发者ID:Eih3,项目名称:v0.83,代码行数:63,代码来源:IRremoteSF.cpp


示例19: gpio_intr

static void ICACHE_FLASH_ATTR gpio_intr(void *arg) {
    uint32_t gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status);

    static uint32_t start = 0;
    uint32_t now = system_get_time();
    uint32_t delta=(now - start) / USECPERTICK + 1;
    switch(irparams.rcvstate){
    case STATE_IDLE: //check if val =1
    	if(0==(gpio_status&(1<<irparams.recvpin)))goto l_Error;
    	irparams.rcvstate = STATE_MARK;
    	break;
    case STATE_MARK:
//l_Error://check if new cmd come
       	if (MATCH_MARK(delta, NEC_HDR_MARK)){ // Initial mark
   	   	irparams.rcvstate = STATE_SPACE;
   	    break;
    	}
    l_Error:
		irparams.rcvstate = STATE_IDLE;
		os_timer_disarm(&timer);
		return;
    case STATE_SPACE:
    	 // Initial space
    	  if (MATCH_SPACE(delta, NEC_HDR_SPACE)) {
    		  irparams.rcvstate = STATE_DATA_MARK;
    		  irparams.BitExpected=NEC_BITS;
    		  irparams.isRepeat=false;
    		  break;
    	  }
    	  if (MATCH_SPACE(delta, NEC_RPT_SPACE)) {
    		  irparams.rcvstate = STATE_REPEAT;
    		  break;
    	  }
    	  goto l_Error;
    case STATE_REPEAT:
  	  if (MATCH_SPACE(delta, NEC_BIT_MARK)) {
  		  //repeat previous command need check time out
  		  if((irparams.Rpt_TimeOut-now)>((NEC_RPT_TIMEOUT-1)*USECPERTICK))return;
  		  irparams.isRepeat=true;
  		  irparams.buffer=irparams.PrevValue;
  		  goto l_CMD_RETURN;
  	  }
  	  goto l_Error;
    case STATE_DATA_MARK:
    	if (MATCH_SPACE(delta, NEC_BIT_MARK)) {
    		irparams.rcvstate = STATE_DATA;
    		break;
    	}
    	goto l_Error;
    case STATE_DATA:
    	irparams.rcvstate = STATE_DATA_MARK;
    	irparams.buffer<<=1;
    	irparams.BitExpected--;
    	if(0==irparams.BitExpected)irparams.rcvstate = STATE_END_OF_MSG;
    	if (MATCH_SPACE(delta, NEC_ONE_SPACE)) {
    		irparams.buffer|=1;
    	    break;
    	   }
    	if (MATCH_SPACE(delta, NEC_ZERO_SPACE)) {
    	    break;
    	   }
    	goto l_Error;
    case STATE_END_OF_MSG:
     	if (MATCH_SPACE(delta, NEC_BIT_MARK)) {
    l_CMD_RETURN:
     			if(false==irparams.isValueReady)// skip if previous was not readet
     				irparams.Value=irparams.buffer;
        		irparams.rcvstate = STATE_IDLE;
        		irparams.isValueReady=true;
        		irparams.Rpt_TimeOut=now;
        		irparams.PrevValue=irparams.buffer;
        		return;
     	}
     	goto l_Error;
    }

    start = now;

    os_timer_disarm(&timer);
    os_timer_arm(&timer, 15, 0);
}
开发者ID:amin7,项目名称:libpack,代码行数:82,代码来源:IRremoteESP8266_nec.cpp



注:本文中的MATCH_SPACE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MATRIX_SCAN_CODE函数代码示例发布时间:2022-05-30
下一篇:
C++ MATCH_MARK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap