added sendRaw to UnitTest etc.
This commit is contained in:
parent
82fff9c34c
commit
e6b39b72df
|
@ -127,6 +127,17 @@ void loop() {
|
|||
"0019 0013 0019 003C 0017 0015 0017 003F 0017 003E 0017 003F 0017 0015 0017 003E " /* inverted command byte */
|
||||
"0017 0806"), 0); //stop bit, no repeat possible, because of missing repeat pattern
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
|
||||
Serial.flush();
|
||||
const uint16_t irSignal[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
|
||||
560/*0010 0x4 of 16 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690, 560,
|
||||
560, 560, 1690/*1101 0xB*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111*/, 560, 560, 560, 560, 560, 560, 560,
|
||||
1690/*0001 0x08 of command LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000 0x00*/, 560, 1690, 560, 1690, 560,
|
||||
1690, 560, 560/*1110 Inverted 8 of command*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111 inverted 0 of command*/,
|
||||
560 /*stop bit*/}; // Using exact NEC timing
|
||||
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.
|
||||
delay(DELAY_AFTER_SEND);
|
||||
#endif
|
||||
/*
|
||||
* With sendNECRaw() you can send 32 bit combined codes
|
||||
|
|
|
@ -81,26 +81,27 @@ void setup() {
|
|||
* you better use the timing generation functions e.g. sendNEC() directly.
|
||||
*/
|
||||
const uint8_t irSignalP[] PROGMEM
|
||||
= { 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 34/*0011 0xC of address LSB first*/, 11, 11, 11, 11, 11, 11, 11, 11/*0000*/,
|
||||
11, 34, 11, 34, 11, 11, 11, 34/*1101 0xB*/, 11, 34, 11, 34, 11, 34, 11, 34/*1111*/, 11, 11, 11, 11, 11, 11, 11,
|
||||
= { 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 34/*0011 0xC of 16 bit address LSB first*/, 11, 11, 11, 11, 11, 11, 11,
|
||||
11/*0000*/, 11, 34, 11, 34, 11, 11, 11, 34/*1101 0xB*/, 11, 34, 11, 34, 11, 34, 11, 34/*1111*/, 11, 11, 11, 11, 11, 11, 11,
|
||||
34/*0001 0x08 of command LSB first*/, 11, 34, 11, 11, 11, 11, 11, 11/*1000 0x01*/, 11, 34, 11, 34, 11, 34, 11,
|
||||
11/*1110 Inverted 8 of command*/, 11, 11, 11, 34, 11, 34, 11, 34/*0111 inverted 1 of command*/, 11 /*stop bit*/};
|
||||
|
||||
void loop() {
|
||||
const uint8_t NEC_KHZ = 38; // 38kHz carrier frequency for the NEC protocol
|
||||
|
||||
#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__))
|
||||
/*
|
||||
* Send hand crafted data from RAM
|
||||
* The values are NOT multiple of 50, but are taken from the NEC timing definitions
|
||||
*/
|
||||
Serial.println(F("Send NEC 8 bit address 0xFB04, 0x08 with exact timing (16 bit array format)"));
|
||||
Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
|
||||
Serial.flush();
|
||||
|
||||
const uint16_t irSignal[] = { 9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560,
|
||||
1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560,
|
||||
1690, 560, 1690, 560 }; // Using exact NEC timing
|
||||
const uint16_t irSignal[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
|
||||
560/*0010 0x4 of 16 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690, 560,
|
||||
560, 560, 1690/*1101 0xB*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111*/, 560, 560, 560, 560, 560, 560, 560,
|
||||
1690/*0001 0x08 of command LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000 0x00*/, 560, 1690, 560, 1690, 560,
|
||||
1690, 560, 560/*1110 Inverted 8 of command*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111 inverted 0 of command*/,
|
||||
560 /*stop bit*/}; // Using exact NEC timing
|
||||
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.
|
||||
|
||||
delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||
|
@ -110,7 +111,7 @@ void loop() {
|
|||
* Send byte data direct from FLASH
|
||||
* Note the approach used to automatically calculate the size of the array.
|
||||
*/
|
||||
Serial.println(F("Send NEC 16 bit address 0xFB0C, 0x18 with (50 us) tick resolution timing (8 bit array format) "));
|
||||
Serial.println(F("Send NEC 16 bit address 0xFB0C and data 0x18 with (50 us) tick resolution timing (8 bit array format) "));
|
||||
Serial.flush();
|
||||
IrSender.sendRaw_P(irSignalP, sizeof(irSignalP) / sizeof(irSignalP[0]), NEC_KHZ);
|
||||
|
||||
|
|
|
@ -239,6 +239,22 @@ void loop() {
|
|||
"0017 0806"), 0); //stop bit, no repeat possible, because of missing repeat pattern
|
||||
checkReceive(0x80, 0x45);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
|
||||
# if FLASHEND >= 0x7FFF // For 32k flash or more, like UNO. Code does not fit in program space of ATtiny1604 etc.
|
||||
|
||||
Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
|
||||
Serial.flush();
|
||||
const uint16_t irSignal[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
|
||||
560/*0010 0x4 of 16 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690, 560,
|
||||
560, 560, 1690/*1101 0xB*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111*/, 560, 560, 560, 560, 560, 560, 560,
|
||||
1690/*0001 0x08 of command LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000 0x00*/, 560, 1690, 560, 1690, 560,
|
||||
1690, 560, 560/*1110 Inverted 8 of command*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111 inverted 0 of command*/,
|
||||
560 /*stop bit*/}; // Using exact NEC timing
|
||||
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.
|
||||
checkReceive(0xFB04, 0x08);
|
||||
delay(DELAY_AFTER_SEND);
|
||||
# endif
|
||||
|
||||
/*
|
||||
* With sendNECRaw() you can send 32 bit combined codes
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
{
|
||||
"name":"Rafi Khan",
|
||||
"email":"zetoslab@gmail.com"
|
||||
"email":"rafi@rafikhan.io"
|
||||
},
|
||||
{
|
||||
"name":"Ken Shirriff",
|
||||
|
|
|
@ -70,6 +70,8 @@ const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
|
|||
#define PROTOCOL_IS_LSB_FIRST false
|
||||
#define PROTOCOL_IS_MSB_FIRST true
|
||||
|
||||
#define NEC_KHZ 38 // 38kHz carrier frequency for the NEC protocol
|
||||
|
||||
/*
|
||||
* Constants for some protocols
|
||||
*/
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
* Repeat commands should be sent in a 110 ms raster.
|
||||
*/
|
||||
void IRsend::sendNECRepeat() {
|
||||
enableIROut(38);
|
||||
enableIROut(NEC_KHZ); // 38 kHz
|
||||
mark(NEC_HEADER_MARK);
|
||||
space(NEC_REPEAT_HEADER_SPACE);
|
||||
mark(NEC_BIT_MARK);
|
||||
|
@ -153,7 +153,7 @@ void IRsend::sendNECRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats, bool a
|
|||
return;
|
||||
}
|
||||
// Set IR carrier frequency
|
||||
enableIROut(38);
|
||||
enableIROut(NEC_KHZ);
|
||||
|
||||
// Header
|
||||
mark(NEC_HEADER_MARK);
|
||||
|
@ -354,7 +354,7 @@ bool IRrecv::decodeNECMSB(decode_results *aResults) {
|
|||
*/
|
||||
void IRsend::sendNECMSB(uint32_t data, uint8_t nbits, bool repeat) {
|
||||
// Set IR carrier frequency
|
||||
enableIROut(38);
|
||||
enableIROut(NEC_KHZ);
|
||||
|
||||
if (data == 0xFFFFFFFF || repeat) {
|
||||
sendNECRepeat();
|
||||
|
|
Loading…
Reference in New Issue