void IRsend::sendVOLTAS(unsigned long address,unsigned long data)
{
    enableIROut(38);
    mark(VOLTAS_HDR_MARK);
    space(VOLTAS_HDR_SPACE); 

    address <<= 12;
    for (int i = 0; i < 20; i++) {
        if (address & TOPBIT) {
            mark(VOLTAS_BIT_MARK);
            space(VOLTAS_ONE_SPACE); 
        } 
        else {
            mark(VOLTAS_BIT_MARK);
            space(VOLTAS_ZERO_SPACE); 
        }
        address <<= 1;
    }

    for (int i = 0; i < 32; i++) {
        if (data & TOPBIT) {
            mark(VOLTAS_BIT_MARK);
            space(VOLTAS_ONE_SPACE); 
        } 
        else {
            mark(VOLTAS_BIT_MARK);
            space(VOLTAS_ZERO_SPACE); 
        }
        data <<= 1;
    }
    mark(VOLTAS_BIT_MARK);
    space(VOLTAS_HDR_SPACE); 
    mark(VOLTAS_BIT_MARK);
    space(0);
}
Example #2
0
/*
 * Most of the protocols have a header consisting of a mark/space of a particular length followed by 
 * a series of variable length mark/space signals.  Depending on the protocol they very the lengths of the 
 * mark or the space to indicate a data bit of "0" or "1". Most also end with a stop bit of "1".
 * The basic structure of the sending and decoding these protocols led to lots of redundant code. 
 * Therefore I have implemented generic sending and decoding routines. You just need to pass a bunch of customized 
 * parameters and it does the work. This reduces compiled code size with only minor speed degradation. 
 * You may be able to implement additional protocols by simply passing the proper values to these generic routines.
 * The decoding routines do not encode stop bits. So you have to tell this routine whether or not to send one.
 */
void IRsendBase::sendGeneric(unsigned long data, unsigned char Num_Bits, unsigned int Head_Mark, unsigned int Head_Space, 
                             unsigned int Mark_One, unsigned int Mark_Zero, unsigned int Space_One, unsigned int Space_Zero, 
							 unsigned char kHz, bool Use_Stop, unsigned long Max_Extent) {
  Extent=0;
  data = data << (32 - Num_Bits);
  enableIROut(kHz);
//Some protocols do not send a header when sending repeat codes. So we pass a zero value to indicate skipping this.
  if(Head_Mark) mark(Head_Mark); 
  if(Head_Space) space(Head_Space);
  for (int i = 0; i <Num_Bits; i++) {
    if (data & TOPBIT) {
      mark(Mark_One);  space(Space_One);
    } 
    else {
      mark(Mark_Zero);  space(Space_Zero);
    }
    data <<= 1;
  }
  if(Use_Stop) mark(Mark_One);   //stop bit of "1"
  if(Max_Extent) {
#ifdef IRLIB_TRACE
    Serial.print("Max_Extent="); Serial.println(Max_Extent);
	Serial.print("Extent="); Serial.println(Extent);
	Serial.print("Difference="); Serial.println(Max_Extent-Extent);
#endif
	space(Max_Extent-Extent); 
	}
	else space(Space_One);
};
Example #3
0
void  IRsend::sendRC6 (unsigned long data,  int nbits)
{
	// Set IR carrier frequency
	enableIROut(36);

	// Header
	mark(RC6_HDR_MARK);
	space(RC6_HDR_SPACE);

	// Start bit
	mark(RC6_T1);
	space(RC6_T1);

	// Data
	for (unsigned long  i = 1, mask = 1UL << (nbits - 1);  mask;  i++, mask >>= 1) {
		// The fourth bit we send is a "double width trailer bit"
		int  t = (i == 4) ? (RC6_T1 * 2) : (RC6_T1) ;
		if (data & mask) {
			mark(t);
			space(t);
		} else {
			space(t);
			mark(t);
		}
	}

	space(0);  // Always end with the LED off
}
Example #4
0
void IRsendRC6::send(unsigned long data, unsigned char nbits)
{
  enableIROut(36);
  data = data << (32 - nbits);
  Extent=0;
  mark(RC6_HDR_MARK); space(RC6_HDR_SPACE);
  mark(RC6_T1);  space(RC6_T1);// start bit "1"
  int t;
  for (int i = 0; i < nbits; i++) {
    if (i == 3) {
      t = 2 * RC6_T1;       // double-wide trailer bit
    } 
    else {
      t = RC6_T1;
    }
    if (data & TOPBIT) {
      mark(t); space(t);//"1" is a Mark/space
    } 
    else {
      space(t); mark(t);//"0" is a space/Mark
    }
    data <<= 1;
  }
  space(107000-Extent); // Turn off at end
}
void setup() {

	DDRD  |= 0b01000000;	// ������� ��������� 
	PORTD &= 0b10111111;	// ������� ���������

	DDRD  |= 0b00100000;	// ����� �������
	PORTD &= 0b11011111;	// ����� �������

	DDRD  |= 0b00010000;	// ��������� ��
	PORTD &= 0b11101111;	// ��������� ��


	DDRD  &= 0b11111011;	// ������
	PORTD |= 0b00000100;	// ������
  
	enableIROut(56);	
	enableIRIn();

	//���������� ��� ���� ISCxx
	//����������� �� ������������ INT0 �� ������� ������
	MCUCR &= ~( (1<<ISC11)|(1<<ISC10)|(1<<ISC01)|(1<<ISC00) );

	//��������� ������� ���������� INT0
	GICR |= (1<<INT0);
	//���������� ���� ����������� ���������� ����������

	PT_INIT(&ptIRReceive);
	PT_INIT(&ptWaitForTrigger);
	PT_INIT(&ptExplode);
	PT_INIT(&ptFinder);
	set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  
  
} 
//Modified Samsung TV send code found in comments on http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
void IRsend::sendSamsung(unsigned long data, int nbits)
{
	enableIROut(38);
	mark(SAMSUNG_HDR_MARK);
	space(SAMSUNG_HDR_SPACE);
	if (data == REPEAT)
	{
		mark(SAMSUNG_BIT_MARK);
		space(SAMSUNG_ZERO_SPACE);
	}
	else
	{
		for (int i = 0; i < nbits; i++)
		{
			if (data & TOPBIT) {
				mark(SAMSUNG_BIT_MARK);
				space(SAMSUNG_ONE_SPACE);
			} 
			else {
				mark(SAMSUNG_BIT_MARK);
				space(SAMSUNG_ZERO_SPACE);
			}
				data <<= 1;
		}		
	}
	mark(SAMSUNG_BIT_MARK);
	space(0);
}
void  IRsend::sendPanasonic (unsigned int address,  unsigned long data)
{
	// Set IR carrier frequency
	enableIROut(35);

	// Header
	mark(PANASONIC_HDR_MARK);
	space(PANASONIC_HDR_SPACE);

	// Address
	for (unsigned long  mask = 1UL << (16 - 1);  mask;  mask >>= 1) {
		mark(PANASONIC_BIT_MARK);
		if (address & mask)  space(PANASONIC_ONE_SPACE) ;
		else                 space(PANASONIC_ZERO_SPACE) ;
    }

	// Data
	for (unsigned long  mask = 1UL << (32 - 1);  mask;  mask >>= 1) {
        mark(PANASONIC_BIT_MARK);
        if (data & mask)  space(PANASONIC_ONE_SPACE) ;
        else              space(PANASONIC_ZERO_SPACE) ;
    }

	// Footer
    mark(PANASONIC_BIT_MARK);
    space(0);  // Always end with the LED off
}
Example #8
0
// Send a Gree Heat Pump message.
//
// Args:
//   data: The raw message to be sent.
//   nbits: Nr. of bits of data in the message. (Default is GREE_BITS)
//   repeat: Nr. of times the message is to be repeated. (Default = 0).
//
// Status: ALPHA / Untested.
//
// Ref:
//   https://github.com/ToniA/arduino-heatpumpir/blob/master/GreeHeatpumpIR.cpp
void IRsend::sendGree(uint64_t data, uint16_t nbits, uint16_t repeat) {
  if (nbits != GREE_BITS)
    return;  // Wrong nr. of bits to send a proper message.
  // Set IR carrier frequency
  enableIROut(38);

  for (uint16_t r = 0; r <= repeat; r++) {
    // Header
    mark(GREE_HDR_MARK);
    space(GREE_HDR_SPACE);

    // Data
    for (int16_t i = 8; i <= nbits; i += 8) {
      sendData(GREE_BIT_MARK, GREE_ONE_SPACE, GREE_BIT_MARK, GREE_ZERO_SPACE,
               (data >> (nbits - i)) & 0xFF, 8, false);
      if (i == nbits / 2) {
        // Send the mid-message Footer.
        sendData(GREE_BIT_MARK, GREE_ONE_SPACE, GREE_BIT_MARK, GREE_ZERO_SPACE,
                 0b010, 3);
        mark(GREE_BIT_MARK);
        space(GREE_MSG_SPACE);
      }
    }
    // Footer
    mark(GREE_BIT_MARK);
    space(GREE_MSG_SPACE);
  }
}
Example #9
0
// Calculate & set any offsets to account for execution times.
//
// Args:
//   hz: The frequency to calibrate at >= 1000Hz. Default is 38000Hz.
//
// Status:  ALPHA / Untested.
//
// NOTE:
//   This will generate an 65535us mark() IR LED signal.
//   This only needs to be called once, if at all.
void IRsend::calibrate(uint16_t hz) {
  if (hz < 1000)  // Were we given kHz? Supports the old call usage.
    hz *= 1000;
  periodOffset = 0;  // Turn off any existing offset while we calibrate.
  enableIROut(hz);
  IRtimer usecTimer = IRtimer();  // Start a timer *just* before we do the call.
  uint16_t pulses = mark(UINT16_MAX);  // Generate a PWM of 65,535 us. (Max.)
  uint32_t timeTaken = usecTimer.elapsed();  // Record the time it took.
  // While it shouldn't be neccesary, assume at least 1 pulse, to avoid a
  // divide by 0 situation.
  pulses = std::max(pulses, (uint16_t) 1U);
  uint32_t calcPeriod = calcUSecPeriod(hz);  // e.g. @38kHz it should be 26us.
  // Assuming 38kHz for the example calculations:
  // In a 65535us pulse, we should have 2520.5769 pulses @ 26us periods.
  // e.g. 65535.0us / 26us = 2520.5769
  // This should have caused approx 2520 loops through the main loop in mark().
  // The average over that many interations should give us a reasonable
  // approximation at what offset we need to use to account for instruction
  // execution times.
  //
  // Calculate the actual period from the actual time & the actual pulses
  // generated.
  double_t actualPeriod = (double_t) timeTaken / (double_t) pulses;
  // Store the difference between the actual time per period vs. calculated.
  periodOffset = (int8_t) ((double_t) calcPeriod - actualPeriod);
}
Example #10
0
void IRsend::sendSharp(unsigned long data, int nbits) {
  unsigned long invertdata = data ^ SHARP_TOGGLE_MASK;
  enableIROut(38);
  for (int i = 0; i < nbits; i++) {
    if (data & 0x4000) {
      mark(SHARP_BIT_MARK);
      space(SHARP_ONE_SPACE);
    }
    else {
      mark(SHARP_BIT_MARK);
      space(SHARP_ZERO_SPACE);
    }
    data <<= 1;
  }
  
  mark(SHARP_BIT_MARK);
  space(SHARP_ZERO_SPACE);
  delay(46);
  for (int i = 0; i < nbits; i++) {
    if (invertdata & 0x4000) {
      mark(SHARP_BIT_MARK);
      space(SHARP_ONE_SPACE);
    }
    else {
      mark(SHARP_BIT_MARK);
      space(SHARP_ZERO_SPACE);
    }
    invertdata <<= 1;
  }
  mark(SHARP_BIT_MARK);
  space(SHARP_ZERO_SPACE);
  delay(46);
}
Example #11
0
// Send a Philips RC-MM packet.
//
// Args:
//   data: The data we want to send. MSB first.
//   nbits: The number of bits of data to send. (Typically 12, 24, or 32[Nokia])
//   repeat: The nr. of times the message should be sent.
//
// Status:  BETA / Should be working.
//
// Ref:
//   http://www.sbprojects.com/knowledge/ir/rcmm.php
void IRsend::sendRCMM(uint64_t data, uint16_t nbits, uint16_t repeat) {
  // Set 36kHz IR carrier frequency & a 1/3 (33%) duty cycle.
  enableIROut(36, 33);
  IRtimer usecs = IRtimer();

  for (uint16_t r = 0; r <= repeat; r++) {
    usecs.reset();
    // Header
    mark(RCMM_HDR_MARK);
    space(RCMM_HDR_SPACE);
    // Data
    uint64_t mask = 0b11ULL << (nbits - 2);
    // RC-MM sends data 2 bits at a time.
    for (int32_t i = nbits; i > 0; i -= 2) {
      mark(RCMM_BIT_MARK);
      // Grab the next Most Significant Bits to send.
      switch ((data & mask) >> (i - 2)) {
        case 0b00: space(RCMM_BIT_SPACE_0); break;
        case 0b01: space(RCMM_BIT_SPACE_1); break;
        case 0b10: space(RCMM_BIT_SPACE_2); break;
        case 0b11: space(RCMM_BIT_SPACE_3); break;
      }
      mask >>= 2;
    }
    // Footer
    mark(RCMM_BIT_MARK);
    // Protocol requires us to wait at least RCMM_RPT_LENGTH usecs from the
    // start or RCMM_MIN_GAP usecs.
    space(std::max(RCMM_RPT_LENGTH - usecs.elapsed(), RCMM_MIN_GAP));
  }
}
Example #12
0
// Caller needs to take care of flipping the toggle bit
void IRsend::sendRC6(unsigned long data, int nbits)
{
  enableIROut(36);
  data = data << (32 - nbits);
  mark(RC6_HDR_MARK);
  space(RC6_HDR_SPACE);
  mark(RC6_T1); // start bit
  space(RC6_T1);
  int t;
  for (int i = 0; i < nbits; i++) {
    if (i == 3) {
      // double-wide trailer bit
      t = 2 * RC6_T1;
    } 
    else {
      t = RC6_T1;
    }
    if (data & TOPBIT) {
      mark(t);
      space(t);
    } 
    else {
      space(t);
      mark(t);
    }

    data <<= 1;
  }
  space(0); // Turn off at end
}
void IRsend::sendSamsung2(unsigned int address, unsigned long data) {
	enableIROut(38);    
	mark(SAMSUNG2_HDR_MARK);
    space(SAMSUNG2_HDR_SPACE);
    
    for(int i=0;i<16;i++)
    {
        mark(SAMSUNG2_BIT_MARK);		
        if (address & 0x8000) {
            space(SAMSUNG2_ONE_SPACE);
        } else {
            space(SAMSUNG2_ZERO_SPACE);
        }
        address <<= 1;        
    }    
	mark(SAMSUNG2_BIT_MARK);
	space(SAMSUNG2_HDR_SPACE);

    for (int i=0; i < (20); i++) {
        mark(SAMSUNG2_BIT_MARK);
        if (data & TOPBIT) {
            space(SAMSUNG2_ONE_SPACE);
        } else {
            space(SAMSUNG2_ZERO_SPACE);
        }
        data <<= 1;
    }

    mark(SAMSUNG2_BIT_MARK);
    space(0);
}
Example #14
0
void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
    enableIROut(35);
    mark(PANASONIC_HDR_MARK);
    space(PANASONIC_HDR_SPACE);
    
    for(int i=0;i<16;i++)
    {
        mark(PANASONIC_BIT_MARK);
        if (address & 0x8000) {
            space(PANASONIC_ONE_SPACE);
        } else {
            space(PANASONIC_ZERO_SPACE);
        }
        address <<= 1;        
    }    
    for (int i=0; i < 32; i++) {
        mark(PANASONIC_BIT_MARK);
        if (data & TOPBIT) {
            space(PANASONIC_ONE_SPACE);
        } else {
            space(PANASONIC_ZERO_SPACE);
        }
        data <<= 1;
    }
    mark(PANASONIC_BIT_MARK);
    space(0);
}
Example #15
0
void IRsend::sendApple(unsigned long data, int nbits,int repeat){
  enableIROut(38);

  if (repeat == 0) {
    mark(APPLE_HDR_MARK);
    space(APPLE_HDR_SPACE);
  }  else {
    mark(APPLE_REPEAT_MARK);
    space(APPLE_REPEAT_SPACE);  
  }
  
  //PRE DATA
  unsigned long pre_data = 0x77E1;
  pre_data <<= 16;
  for (int i = 0; i < 16; i++) {
    if (pre_data & TOPBIT) {
      mark(APPLE_ONE_MARK);
      space(APPLE_ONE_SPACE);
    } 
    else {
      mark(APPLE_ONE_MARK);
      space(APPLE_ZERO_SPACE);
    }
    pre_data <<= 1;
  }
  
  //BODY
  data <<= nbits;
  for (int i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      mark(APPLE_ONE_MARK);
      space(APPLE_ONE_SPACE);
    } 
    else {
      mark(APPLE_ONE_MARK);
      space(APPLE_ZERO_SPACE);
    }
    data <<= 1;
  }

  //POST DATA
  unsigned long post_data = 0x49;
  post_data <<= 8;
  for (int i = 0; i < 8; i++) {
    if (post_data & TOPBIT) {
      mark(APPLE_ONE_MARK);
      space(APPLE_ONE_SPACE);
    } 
    else {
      mark(APPLE_ONE_MARK);
      space(APPLE_ZERO_SPACE);
    }
    post_data <<= 1;
  }

  mark(APPLE_PTRAIL);
  space(APPLE_GAP);  //gap
}
Example #16
0
void IRsendNEC::send(unsigned long data)
{
  if (data==REPEAT) {
    enableIROut(38);
    mark (564* 16); space(564*4); mark(564);space(56*173);
  }
  else {
    sendGeneric(data,32, 564*16, 564*8, 564, 564, 564*3, 564, 38, true);
  }
};
Example #17
0
void IRsend::sendRaw(unsigned int buf[], int len, int hz){
  enableIROut(hz);
  for (int i = 0; i < len; i++) {
    if (i & 1) {
      space(buf[i]);
    } 
    else {
      mark(buf[i]);
    }
  }
  space(0); // Just to be sure
}
Example #18
0
//+=============================================================================
void  IRsend::sendRaw (unsigned int buf[],  int len,  int hz)
{
	// Set IR carrier frequency
	enableIROut(hz);

	for (int i = 0;  i < len;  i++) {
		if (i & 1)  space(buf[i]) ;
		else        mark (buf[i]) ;
	}

	space(0);  // Always end with the LED off
}
Example #19
0
void IRsend::sendRaw(const uint16_t *buf, int len, int hz)
{
  enableIROut(hz);
  for (int i = 0; i < len; i++) {
    if (i & 1) {
      space(buf[i]);
    } 
    else {
      mark(buf[i]);
    }
  }
  space(0); // Just to be sure
}
Example #20
0
/*
 * The remaining protocols require special treatment. They were in the original IRremote library.
 */
void IRsendRaw::send(unsigned int buf[], unsigned char len, unsigned char hz)
{
  enableIROut(hz);
  for (unsigned char i = 0; i < len; i++) {
    if (i & 1) {
      space(buf[i]);
    } 
    else {
      mark(buf[i]);
    }
  }
  space(0); // Just to be sure
}
Example #21
0
// Send a Pronto Code formatted message.
//
// Args:
//   data: An array of uint16_t containing the pronto codes.
//   len: Nr. of entries in the data[] array.
//   repeat: Nr. of times to repeat the message.
//
// Status: ALPHA / Not tested in the real world.
//
// Note:
//   Pronto codes are typically represented in hexadecimal.
//   You will need to convert the code to an array of integers, and calculate
//   it's length.
//   e.g.
//      A Sony 20 bit DVD remote command.
//      "0000 0067 0000 0015 0060 0018 0018 0018 0030 0018 0030 0018 0030 0018
//       0018 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0030 0018
//       0030 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018
//       0030 0018 0018 03f6"
//
//   converts to:
//
//       uint16_t prontoCode[46] = {
//           0x0000, 0x0067, 0x0000, 0x0015,
//           0x0060, 0x0018, 0x0018, 0x0018, 0x0030, 0x0018, 0x0030, 0x0018,
//           0x0030, 0x0018, 0x0018, 0x0018, 0x0030, 0x0018, 0x0018, 0x0018,
//           0x0018, 0x0018, 0x0030, 0x0018, 0x0018, 0x0018, 0x0030, 0x0018,
//           0x0030, 0x0018, 0x0030, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018,
//           0x0030, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0030, 0x0018,
//           0x0018, 0x03f6};
//       // Send the Pronto(Sony) code. Repeat twice as Sony's require that.
//       sendPronto(prontoCode, 46, SONY_MIN_REPEAT);
//
// Ref:
//   http://www.etcwiki.org/wiki/Pronto_Infrared_Format
//   http://www.remotecentral.com/features/irdisp2.htm
void IRsend::sendPronto(uint16_t data[], uint16_t len, uint16_t repeat) {
  // Check we have enough data to work out what to send.
  if (len < PRONTO_MIN_LENGTH) return;

  // We only know how to deal with 'raw' pronto codes types. Reject all others.
  if (data[PRONTO_TYPE_OFFSET] != 0) return;

  // Pronto frequency is in Hz.
  uint16_t hz = (uint16_t) (1000000U / (data[PRONTO_FREQ_OFFSET] *
                                        PRONTO_FREQ_FACTOR));
  enableIROut(hz);

  // Grab the length of the two sequences.
  uint16_t seq_1_len = data[PRONTO_SEQ_1_LEN_OFFSET] * 2;
  uint16_t seq_2_len = data[PRONTO_SEQ_2_LEN_OFFSET] * 2;
  // Calculate where each sequence starts in the buffer.
  uint16_t seq_1_start = PRONTO_DATA_OFFSET;
  uint16_t seq_2_start = PRONTO_DATA_OFFSET + seq_1_len;

  uint32_t periodic_time = calcUSecPeriod(hz, false);

  // Normal (1st sequence) case.
  // Is there a first (normal) sequence to send?
  if (seq_1_len > 0) {
    // Check we have enough data to send the complete first sequence.
    if (seq_1_len + seq_1_start > len) return;
    // Send the contents of the 1st sequence.
    for (uint16_t i = seq_1_start; i < seq_1_start + seq_1_len; i += 2) {
      mark(data[i] * periodic_time);
      space(data[i + 1] * periodic_time);
    }
  } else {
    // There was no first sequence to send, it is implied that we have to send
    // the 2nd/repeat sequence an additional time. i.e. At least once.
    repeat++;
  }

  // Repeat (2nd sequence) case.
  // Is there a second (repeat) sequence to be sent?
  if (seq_2_len > 0) {
    // Check we have enough data to send the complete second sequence.
    if (seq_2_len + seq_2_start > len) return;

    // Send the contents of the 2nd sequence.
    for (uint16_t r = 0; r < repeat; r++)
      for (uint16_t i = seq_2_start; i < seq_2_start + seq_2_len; i += 2) {
        mark(data[i] * periodic_time);
        space(data[i + 1] * periodic_time);
      }
  }
}
// Caller needs to take care of flipping the toggle bit
void IRsend::sendRCMM(unsigned long data, int nbits)
{
	enableIROut(36);
    data = data << (32 - nbits);
	mark(RCMM_HDR_MARK);
	space(RCMM_SPACE);
	for (int i = 0; i < nbits; i += 2) {
		mark(RCMM_MARK);
		space(RCMM_SPACE+(data >> 30)*RCMM_INCREMENT);
		data <<= 2;
	}
	mark(RCMM_MARK);
	space(0);
}
////////////////////////
//IRsend::sendRaw
////////////////////////
void ICACHE_FLASH_ATTR sendRaw(unsigned int buf[], int len, int hz)
{
  int i;
  enableIROut(hz);
  for (i = 0; i < len; i++) {
    if (i & 1) {
      space(buf[i]);
    }
    else {
      mark(buf[i]);
    }
  }
  space(1); // Just to be sure
}
Example #24
0
void SLifiSender::send(unsigned long data, int nbits)
{
#if 0
	enableIROut(38);
	mark(SAMSUNG_HDR_MARK);  // 5000microSec MARK
	space(SAMSUNG_HDR_SPACE); // 5000microSec SPACE
	for (int i = 0; i < nbits; i++) {
		if (data & TOPBIT) { // 10000000000000000000000000000000 bit
			mark(SAMSUNG_BIT_MARK); // 560microSec MARK
			space(SAMSUNG_ONE_SPACE); // 1600microSec SPACE
		}
		else {
			mark(SAMSUNG_BIT_MARK); // 560microSec MARK
			space(SAMSUNG_ZERO_SPACE); // 560microSec SPACE
		}
		data <<= 1;
	}
	mark(SAMSUNG_BIT_MARK);
	space(0);
#else
	enableIROut(40);
	mark(HEADER_MARK);
	space(SONY_HDR_SPACE);
	data = data << (32 - nbits);
	for (int i = 0; i < nbits; i++) {
		if (data & TOPBIT) {
			mark(SONY_ONE_MARK);
			space(SONY_HDR_SPACE);
		}
		else {
			mark(SONY_ZERO_MARK);
			space(SONY_HDR_SPACE);
		}
		data <<= 1;
	}
#endif
}
Example #25
0
void IRsend::sendDISH(unsigned long data, int nbits) {
  enableIROut(56);
  mark(DISH_HDR_MARK);
  space(DISH_HDR_SPACE);
  for (int i = 0; i < nbits; i++) {
    if (data & DISH_TOP_BIT) {
      mark(DISH_BIT_MARK);
      space(DISH_ONE_SPACE);
    }
    else {
      mark(DISH_BIT_MARK);
      space(DISH_ZERO_SPACE);
    }
    data <<= 1;
  }
}
Example #26
0
// Send a Whynter message.
//
// Args:
//   data: message to be sent.
//   nbits: Nr. of bits of the message to be sent.
//   repeat: Nr. of additional times the message is to be sent.
//
// Status: STABLE
//
// Ref:
//   https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Whynter.cpp
void IRsend::sendWhynter(uint64_t data, uint16_t nbits, uint16_t repeat) {
  // Set IR carrier frequency
  enableIROut(38);

  for (uint16_t i = 0; i <= repeat; i++) {
    // (Pre-)Header
    mark(kWhynterBitMark);
    space(kWhynterZeroSpace);
    sendGeneric(
        kWhynterHdrMark, kWhynterHdrSpace, kWhynterBitMark, kWhynterOneSpace,
        kWhynterBitMark, kWhynterZeroSpace, kWhynterBitMark, kWhynterMinGap,
        kWhynterMinCommandLength - (kWhynterBitMark + kWhynterZeroSpace), data,
        nbits, 38, true, 0,  // Repeats are already handled.
        50);
  }
}
Example #27
0
void IRsend::sendMedia(unsigned char *data, int length)
{
  enableIROut(38);
  mark(4400);
  space(4400);
  for(int i = 0; i < length; i++){
	for(int j = 0; j < 8; j++){
		if((*(data+i))&(0x80>>j)){
			mark(540);
			space(1620);
		}
		else{
			mark(540);
			space(540);
		}
	}
  }
Example #28
0
void IRsend::sendSony(unsigned long data, int nbits) {
  enableIROut(40);
  mark(SONY_HDR_MARK);
  space(SONY_HDR_SPACE);
  data = data << (32 - nbits);
  for (int i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      mark(SONY_ONE_MARK);
      space(SONY_HDR_SPACE);
    } 
    else {
      mark(SONY_ZERO_MARK);
      space(SONY_HDR_SPACE);
    }
    data <<= 1;
  }
}
Example #29
0
void IRsendBase::sendGeneric(unsigned long data, int Num_Bits, int Head_Mark, int Head_Space, int Mark_One, int Mark_Zero, int Space_One, int Space_Zero, int mHz, bool Use_Stop) {
  data = data << (32 - Num_Bits);
  enableIROut(mHz);
//Some protocols do not send a header when sending repeat codes. So we pass a zero value to indicate skipping this.
  if(Head_Mark) mark(Head_Mark); 
  if(Head_Space) space(Head_Space);
  for (int i = 0; i <Num_Bits; i++) {
    if (data & TOPBIT) {
      mark(Mark_One);  space(Space_One);
    } 
    else {
      mark(Mark_Zero);  space(Space_Zero);
    }
    data <<= 1;
  }
  if (Use_Stop) mark(Mark_One);  space(0) ; //stop bit of "1"
};
Example #30
0
//Used to reduce read time by using 50us ticks so we can use bytes instead of int.
//The calculations are done as we read the ticks array.
void IRsend::sendRawCompact(uint8_t *buf, int len, int hz)
{
  unsigned int compCalc;
  enableIROut(hz);
  for (int i = 0; i < len; i++) {
	compCalc = (unsigned int)buf[i] * USECPERTICK;
    if (i & 1) {
      space(compCalc); 
	  //space(buf[i]);
    } 
    else {
      mark(compCalc);
	  //mark(buf[i]);
    }
  }
  space(0); // Just to be sure
}