예제 #1
0
void IRsend_sendJVC(u32 data, u16 nbits, u16 repeat)
{
	u16 i;
	
    PWM_setFrequency(38000);
    data = data << (32 - nbits);
    if (!repeat){
        IRsend_mark(JVC_HDR_MARK);
        IRsend_space(JVC_HDR_SPACE); 
    }
	
    for (i = 0; i < nbits; i++) {
        if (data & TOPBIT) {
            IRsend_mark(JVC_BIT_MARK);
            IRsend_space(JVC_ONE_SPACE); 
        } 
        else {
            IRsend_mark(JVC_BIT_MARK);
            IRsend_space(JVC_ZERO_SPACE); 
        }
        data <<= 1;
    }
    IRsend_mark(JVC_BIT_MARK);
    IRsend_space(0);
}
예제 #2
0
// Caller needs to take care of flipping the toggle bit
void IRsend_sendRC6(u32 data, u16 nbits)
{
  u16 t;
  u16 i;
  
  PWM_setFrequency(36000);
  data = data << (32 - nbits);
  IRsend_mark(RC6_HDR_MARK);
  IRsend_space(RC6_HDR_SPACE);
  IRsend_mark(RC6_T1); // start bit
  IRsend_space(RC6_T1);
  
  for (i = 0; i < nbits; i++) {
    if (i == 3) {
      // double-wide trailer bit
      t = 2 * RC6_T1;
    } 
    else {
      t = RC6_T1;
    }
    if (data & TOPBIT) {
      IRsend_mark(t);
      IRsend_space(t);
    } 
    else {
      IRsend_space(t);
      IRsend_mark(t);
    }

    data <<= 1;
  }
  IRsend_space(0); // Turn off at end
}
예제 #3
0
void IRsend_sendPanasonic(u16 address, u32 data) {
    u16 i;
	
	PWM_setFrequency(35000);
    IRsend_mark(PANASONIC_HDR_MARK);
    IRsend_space(PANASONIC_HDR_SPACE);
    
    for(i = 0; i<16; i++)
    {
        IRsend_mark(PANASONIC_BIT_MARK);
        if (address & 0x8000) {
            IRsend_space(PANASONIC_ONE_SPACE);
        } else {
            IRsend_space(PANASONIC_ZERO_SPACE);
        }
        address <<= 1;        
    }    
    for (i = 0; i < 32; i++) {
        IRsend_mark(PANASONIC_BIT_MARK);
        if (data & TOPBIT) {
            IRsend_space(PANASONIC_ONE_SPACE);
        } else {
            IRsend_space(PANASONIC_ZERO_SPACE);
        }
        data <<= 1;
    }
    IRsend_mark(PANASONIC_BIT_MARK);
    IRsend_space(0);
}
예제 #4
0
	void Tone(u8 pin, u16 freq, u16 duration)
	{
		PWM_setFrequency(freq);
		PWM_setPercentDutyCycle(pin, 50);
		Delayms(duration);						// length of sound in ms 
		noTone(pin);
	}
예제 #5
0
// Note: first bit must be a one (start bit)
void IRsend_sendRC5(u32 data, u16 nbits)
{ 
    u16 i;

    PWM_setFrequency(36000);
    PWM_setPercentDutyCycle(irparams.outpin, 50);
    data = data << (32 - nbits);

    IRsend_mark(RC5_T1); // First start bit
    IRsend_space(RC5_T1); // Second start bit
    IRsend_mark(RC5_T1); // Second start bit

    for (i = 0; i < nbits; i++)
    {
        if (data & TOPBIT)
        {
            IRsend_space(RC5_T1); // 1 is space, then mark
            IRsend_mark(RC5_T1);
        } 
        else
        {
            IRsend_mark(RC5_T1);
            IRsend_space(RC5_T1);
        }
        data <<= 1;
    }

    IRsend_space(0); // Turn off at end
}
예제 #6
0
	void noTone(u8 pin)
	{
		PWM_setFrequency(0);					// note (range 1..14)
		PWM_setPercentDutyCycle(pin, 0);		// silence
		//pinmode(pin, INPUT);
		//CCP1CON = 0;							// stop sound = stop pwm
		//T2CONbits.TMR2ON = OFF;				// disable Timer2 = stop pwm = stop sound
	}
예제 #7
0
void IRsend_sendRaw(u16 buf[], u16 len, u16 hz)
{
    u16 i;

    PWM_setFrequency(hz);

    for (i = 0; i < len; i++) {
    if (i & 1) {
      IRsend_space(buf[i]);
    } 
    else {
      IRsend_mark(buf[i]);
    }
    }
    IRsend_space(0); // Just to be sure
}
예제 #8
0
void IRsend_sendDISH(u32 data, u16 nbits)
{
  u16 i;
  PWM_setFrequency(56000);
  IRsend_mark(DISH_HDR_MARK);
  IRsend_space(DISH_HDR_SPACE);
  
  for (i = 0; i < nbits; i++) {
    if (data & DISH_TOP_BIT) {
      IRsend_mark(DISH_BIT_MARK);
      IRsend_space(DISH_ONE_SPACE);
    }
    else {
      IRsend_mark(DISH_BIT_MARK);
      IRsend_space(DISH_ZERO_SPACE);
    }
    data <<= 1;
  }
}
예제 #9
0
void IRsend_sendSony(u32 data, u16 nbits) {
  u16 i; 
  
  PWM_setFrequency(40000);
  IRsend_mark(SONY_HDR_MARK);
  IRsend_space(SONY_HDR_SPACE);
  data = data << (32 - nbits);

  for (i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      IRsend_mark(SONY_ONE_MARK);
      IRsend_space(SONY_HDR_SPACE);
    } 
    else {
      IRsend_mark(SONY_ZERO_MARK);
      IRsend_space(SONY_HDR_SPACE);
    }
    data <<= 1;
  }
}
예제 #10
0
void IRsend_sendNEC(u32 data, u16 nbits)
{
  u16 i;
  
  PWM_setFrequency(38000);
  IRsend_mark(NEC_HDR_MARK);
  IRsend_space(NEC_HDR_SPACE);
  
  for (i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      IRsend_mark(NEC_BIT_MARK);
      IRsend_space(NEC_ONE_SPACE);
    } 
    else {
      IRsend_mark(NEC_BIT_MARK);
      IRsend_space(NEC_ZERO_SPACE);
    }
    data <<= 1;
  }
  IRsend_mark(NEC_BIT_MARK);
  IRsend_space(0);
}
예제 #11
0
void IRsend_sendSharp(u32 data, u16 nbits)
{
  u32 invertdata = data ^ SHARP_TOGGLE_MASK;
  u16 i;
  PWM_setFrequency(38000);
  
  for (i = 0; i < nbits; i++) {
    if (data & 0x4000) {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ONE_SPACE);
    }
    else {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ZERO_SPACE);
    }
    data <<= 1;
  }
  
  IRsend_mark(SHARP_BIT_MARK);
  IRsend_space(SHARP_ZERO_SPACE);
  Delayms(46);
  
  for (i = 0; i < nbits; i++) {
    if (invertdata & 0x4000) {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ONE_SPACE);
    }
    else {
      IRsend_mark(SHARP_BIT_MARK);
      IRsend_space(SHARP_ZERO_SPACE);
    }
    invertdata <<= 1;
  }
  IRsend_mark(SHARP_BIT_MARK);
  IRsend_space(SHARP_ZERO_SPACE);
  Delayms(46);
}