Version 4.0

This commit is contained in:
Armin 2022-08-31 13:25:29 +02:00
parent 1eb7ff24b1
commit 72f7c75b3e
31 changed files with 1426 additions and 1438 deletions

View File

@ -25,7 +25,7 @@ The **durations** you receive are likely to be longer for marks and shorter for
but this depends on the receiver circuit in use. Most protocols use multiples of one time-unit for marks and spaces like e.g. [NEC](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L62). It's easy to be off-by-one with the last bit, since the last space is not recorded by IRremote.
Try to make use of the template functions `decodePulseDistanceData()` and `sendPulseDistanceData()`.
If your protocol supports address and code fields, try to reflect this in your api like it is done in [`sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aIsRepeat)`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L96)
If your protocol supports address and code fields, try to reflect this in your api like it is done in [`sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aIsRepeat)`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L96)
and [`decodeNEC()`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.hpp#L194).<br/>
### Integration

View File

@ -309,10 +309,15 @@ Check out the [MinimalReceiver](https://github.com/Arduino-IRremote/Arduino-IRre
# Sending IR codes
Please do not use the old send*Raw() functions for sending like e.g. `IrSender.sendNECRaw(0xE61957A8,2)`,
even if this functions are used in a lot of **(old)** tutorials. They are only kept for backward compatibility and unsupported as well as error prone.<br/>
**It is recommended** to use the **new structured functions** with address and command parameters like e.g. `IrSender.sendNEC(0xA8, 0x19, 2)`.
**It is recommended** to use the **new structured functions** with address, command and repeat count parameters like e.g. `IrSender.sendNEC(0xA8, 0x19, 2)`.
Especially if you are able to receive these remote codes and get the address and command values.
You will discover that **the address is a constant** and the commands sometimes are sensibly grouped.
**All sending functions support the sending of repeats** (if sensible).
Repeat frames are sent at a fixed period determined by the protocol. e.g. 110 ms from start to start for NEC.<br/>
Keep in mind, that **there is no delay after the last sent mark**.
If you handle the sending of repeat frames by your own, you must insert sensible delays before the repeat frames to enable correct decoding.
### List of public IR code databases
http://www.harctoolbox.org/IR-resources.html
@ -703,7 +708,7 @@ It is dated from **24.06.2022**. If you have complains about the data or request
# Useful links
- [List of public IR code databases](http://www.harctoolbox.org/IR-resources.html)
- [LIRC database](http://lirc-remotes.sourceforge.net/remotes-table.html)
- [IRMP list of IR protocols](https://www.mikrocontroller.net/articles/IRMP_-_english#IR_Protocols]
- [IRMP list of IR protocols](https://www.mikrocontroller.net/articles/IRMP_-_english#IR_Protocols)
- [IR Remote Control Theory and some protocols (upper right hamburger icon)](https://www.sbprojects.net/knowledge/ir/)
- [Interpreting Decoded IR Signals (v2.45)](http://www.hifi-remote.com/johnsfine/DecodeIR.html)
- ["Recording long Infrared Remote control signals with Arduino"](https://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino)

View File

@ -2,6 +2,12 @@
The latest version may not be released!
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
## 4.0.0
- Introduced PulsePauseWidthProtocolConstants.
- Where possible, converted all send and decode functions to use PulsePauseWidthProtocolConstants.
- Improved MSB/LSB handling
- New convenience fuctions bitreverse32Bit() and bitreverseOneByte().
## 3.9.0
- Improved documentation with the help of [ElectronicsArchiver}(https://github.com/ElectronicsArchiver).
- Added NEC2 protocol.

View File

@ -34,8 +34,8 @@
*/
// Digispark ATMEL ATTINY85
// Piezo speaker must have a 270 Ohm resistor in series for USB programming and running at the Samsung TV.
// IR LED has a 270 Ohm resistor in series.
// Piezo speaker must have a 270 ohm resistor in series for USB programming and running at the Samsung TV.
// IR LED has a 270 ohm resistor in series.
// +-\/-+
// !RESET (5) PB5 1| |8 Vcc
// USB+ 3.6V Z-Diode, 1.5kOhm to VCC Piezo (3) PB3 2| |7 PB2 (2) TX Debug output

View File

@ -144,7 +144,7 @@ void loop() {
/*
* With sendNECRaw() you can send 32 bit combined codes
*/
Serial.println(F("Send NEC / ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
Serial.flush();
IrSender.sendNECRaw(0x03040102, sRepeats);
delay(DELAY_AFTER_SEND);
@ -169,21 +169,28 @@ void loop() {
IrSender.sendNECMSB(0x40802CD3, 32, false);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants"));
Serial.flush();
uint32_t tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
IrSender.sendPulseDistanceWidthFromArray(&KaseikyoProtocolConstants, &tRawData[0], 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
delay(DELAY_AFTER_SEND);
/*
* Send 2 Panasonic 48 bit codes as generic Pulse Distance data, once with LSB and once with MSB first
*/
Serial.println(F("Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance"));
Serial.println(F(" LSB first"));
Serial.flush();
uint32_t tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, false, 0, 0);
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_LSB_FIRST,
SEND_STOP_BIT, 0, NO_REPEATS);
delay(DELAY_AFTER_SEND);
// The same with MSB first. Use bit reversed raw data of LSB first part
Serial.println(F(" MSB first"));
tRawData[0] = 0x40040D00; // MSB of tRawData[0] is sent first
tRawData[1] = 0x805;
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, true, 0, 0);
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_MSB_FIRST,
SEND_STOP_BIT, 0, NO_REPEATS);
delay(DELAY_AFTER_SEND);
}

View File

@ -4,7 +4,7 @@
* Demonstrates sending IR codes in standard format with address and command
* An extended example for sending can be found as SendDemo.
*
* Copyright (C) 2020-2021 Armin Joachimsmeyer
* Copyright (C) 2020-2022 Armin Joachimsmeyer
* armin.joachimsmeyer@gmail.com
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
@ -62,11 +62,11 @@ void loop() {
Serial.println(F("Send NEC with 16 bit address"));
Serial.flush();
// Results for the first loop to: Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 (32 bits)
// Receiver output for the first loop must be: Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 (32 bits)
IrSender.sendNEC(sAddress, sCommand, sRepeats);
/*
* If you cannot avoid to send a raw value directly like e.g. 0xCB340102 you must use sendNECRaw()
* If you must send a raw value directly like e.g. 0xCB340102, you have to use sendNECRaw()
*/
// Serial.println(F("Send NECRaw 0xCB340102"));
// IrSender.sendNECRaw(0xCB340102, sRepeats);

View File

@ -73,9 +73,9 @@
#define DECODE_LG
#define DECODE_BOSEWAVE
#define DECODE_LEGO_PF
//#define DECODE_LEGO_PF
#define DECODE_MAGIQUEST
#define DECODE_WHYNTER
//#define DECODE_WHYNTER
#endif
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
@ -166,24 +166,28 @@ void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
IrReceiver.printIRResultRawFormatted(&Serial, true);
}
#endif
if (IrReceiver.decodedIRData.protocol != UNKNOWN && IrReceiver.decodedIRData.protocol != PULSE_DISTANCE) {
/*
* Check address
*/
if (IrReceiver.decodedIRData.address != aSentAddress) {
Serial.print(F("ERROR: Received address=0x"));
Serial.print(IrReceiver.decodedIRData.address, HEX);
Serial.print(F(" != sent address=0x"));
Serial.println(aSentAddress, HEX);
}
/*
* Check command
*/
if (IrReceiver.decodedIRData.command != aSentCommand) {
Serial.print(F("ERROR: Received command=0x"));
Serial.print(IrReceiver.decodedIRData.command, HEX);
Serial.print(F(" != sent command=0x"));
Serial.println(aSentCommand, HEX);
if (IrReceiver.decodedIRData.protocol != PULSE_DISTANCE) {
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("ERROR: Unknown protocol"));
} else {
/*
* Check address
*/
if (IrReceiver.decodedIRData.address != aSentAddress) {
Serial.print(F("ERROR: Received address=0x"));
Serial.print(IrReceiver.decodedIRData.address, HEX);
Serial.print(F(" != sent address=0x"));
Serial.println(aSentAddress, HEX);
}
/*
* Check command
*/
if (IrReceiver.decodedIRData.command != aSentCommand) {
Serial.print(F("ERROR: Received command=0x"));
Serial.print(IrReceiver.decodedIRData.command, HEX);
Serial.print(F(" != sent command=0x"));
Serial.println(aSentCommand, HEX);
}
}
}
}
@ -236,7 +240,7 @@ void loop() {
/*
* Send constant values only once in this demo
*/
Serial.println(F("Sending NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats"));
Serial.println(F("Send NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats"));
Serial.flush();
IrSender.sendPronto(F("0000 006D 0022 0000 015E 00AB " /* Pronto header + start bit */
"0017 0015 0017 0015 0017 0017 0015 0017 0017 0015 0017 0015 0017 0015 0017 003F " /* Lower address byte */
@ -247,8 +251,8 @@ void loop() {
checkReceive(0x80, 0x45);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
Serial.println(
F("Send NEC sendRaw data with 8 bit address=0xFB04 and command 0x08 and 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,
@ -262,9 +266,9 @@ void loop() {
# endif
/*
* With sendNECRaw() you can send 32 bit combined codes
* With sendNECRaw() you can send 32 bit codes directly, i.e. without parity etc.
*/
Serial.println(F("Send NEC / ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
Serial.flush();
IrSender.sendNECRaw(0x03040102, sRepeats);
checkReceive(0x0102, 0x304);
@ -276,20 +280,27 @@ void loop() {
* Example:
* 0xCB340102 byte reverse -> 0x020134CB bit reverse-> 40802CD3
*/
Serial.println(F("Send NEC with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first"));
Serial.println(F("Send NEC with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first (0x40802CD3)"));
Serial.flush();
IrSender.sendNECMSB(0x40802CD3, 32, false);
checkReceive(0x0102, 0x34);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants"));
Serial.flush();
uint32_t tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
IrSender.sendPulseDistanceWidthFromArray(&KaseikyoProtocolConstants, &tRawData[0], 48, NO_REPEATS); // Panasonic is a Kaseikyo variant
checkReceive(0x0B, 0x10);
delay(DELAY_AFTER_SEND);
/*
* Send 2 Panasonic 48 bit codes as generic Pulse Distance data, once with LSB and once with MSB first
*/
Serial.println(F("Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance"));
Serial.println(F(" LSB first"));
Serial.flush();
uint32_t tRawData[] = { 0xB02002, 0xA010 }; // LSB of tRawData[0] is sent first
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_LSB_FIRST, 0, 0);
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT,
0, NO_REPEATS);
checkReceive(0x0B, 0x10);
delay(DELAY_AFTER_SEND);
@ -297,7 +308,8 @@ void loop() {
Serial.println(F(" MSB first"));
tRawData[0] = 0x40040D00; // MSB of tRawData[0] is sent first
tRawData[1] = 0x805;
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_MSB_FIRST, 0, 0);
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT,
0, NO_REPEATS);
checkReceive(0x0B, 0x10);
delay(DELAY_AFTER_SEND);
@ -305,7 +317,8 @@ void loop() {
Serial.flush();
tRawData[0] = 0x43D8613C;
tRawData[1] = 0x3BC3BC;
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 56, PROTOCOL_IS_LSB_FIRST, 0, 0);
IrSender.sendPulseDistanceWidthFromArray(38, 8900, 4450, 550, 1700, 550, 600, &tRawData[0], 56, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT,
0, NO_REPEATS);
checkReceive(0x0, 0x0); // No real check, only printing of received result
delay(DELAY_AFTER_SEND);
}

View File

@ -1,5 +1,5 @@
START ../src/UnitTest.cpp from Aug 27 2022
Using library version 3.8.0
START ../src/UnitTest.cpp from Aug 30 2022
Using library version 3.9.0
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, Whynter, Lego Power Functions, Bosewave , MagiQuest, Pulse Distance, Hash at pin 2
Ready to send IR signals at pin 3
Send signal mark duration for 38kHz is 8 us, pulse correction is 3000 ns, total period is 26 us
@ -12,244 +12,265 @@ Send NEC with 8 bit address
Protocol=NEC Address=0xF1 Command=0x76 Raw-Data=0x89760EF1 32 bits LSB first
Send with: IrSender.sendNEC(0xF1, 0x76, <numberOfRepeats>);
rawData[68]:
-1038100
+8850,-4450
+ 600,-1650 + 550,- 550 + 600,- 500 + 600,- 550
+ 600,-1650 + 550,-1650 + 600,-1650 + 600,-1650
+ 550,- 550 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,- 550
+ 600,- 550 + 550,-1650 + 600,-1650 + 600,- 500
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,- 550
+ 550,-1650 + 650,- 500 + 550,- 550 + 600,-1650
+ 600,- 500 + 600,- 550 + 550,- 550 + 600,-1650
-1038150
+8850,-4400
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,-1650 + 600,-1600
+ 600,- 550 + 600,- 500 + 600,- 600 + 550,- 500
+ 600,- 550 + 600,-1600 + 650,-1600 + 600,- 500
+ 650,-1600 + 600,-1650 + 600,-1600 + 650,- 500
+ 600,-1650 + 600,- 500 + 600,- 500 + 650,-1650
+ 550,- 550 + 600,- 500 + 600,- 550 + 600,-1600
+ 600
Sum: 67600
Sum: 67550
Send NEC with 16 bit address
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
rawData[68]:
-1045100
+8900,-4450
+ 550,-1650 + 600,- 550 + 550,- 550 + 600,- 550
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1650
+ 550,-1650 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,- 500
+ 550,-1700 + 600,- 500 + 600,- 550 + 550,-1650
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
+ 650
Sum: 73250
-1046100
+8900,-4400
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,-1650 + 600,-1600 + 550,-1700 + 600,-1650
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1600
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,-1650
+ 600,- 500 + 650,-1600 + 600,-1600 + 650,- 500
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
+ 600,-1600 + 600,- 550 + 600,- 500 + 600,-1650
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
+ 600
Sum: 73150
Sending NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats
Send NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats
Protocol=NEC Address=0x80 Command=0x45 Raw-Data=0xBA457F80 32 bits LSB first
Send with: IrSender.sendNEC(0x80, 0x45, <numberOfRepeats>);
rawData[68]:
-1054350
+9050,-4400
+ 600,- 550 + 600,- 550 + 600,- 600 + 550,- 550
+ 650,- 500 + 650,- 550 + 600,- 550 + 600,-1600
+ 600,-1650 + 600,-1600 + 600,-1600 + 550,-1650
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,- 550
-1055150
+9050,-4350
+ 650,- 550 + 600,- 550 + 600,- 600 + 550,- 600
+ 600,- 550 + 600,- 550 + 600,- 550 + 600,-1600
+ 650,-1600 + 600,-1600 + 600,-1600 + 600,-1600
+ 600,-1600 + 600,-1600 + 650,-1550 + 650,- 500
+ 600,-1600 + 600,- 550 + 600,-1600 + 600,- 550
+ 600,- 500 + 650,- 500 + 650,-1600 + 600,- 550
+ 650,- 500 + 650,-1550 + 600,- 550 + 600,-1600
+ 600,-1600 + 600,-1650 + 600,- 500 + 650,-1600
+ 650,- 500 + 600,- 550 + 600,-1600 + 600,- 550
+ 700,- 450 + 700,-1500 + 600,- 550 + 600,-1600
+ 650,-1550 + 650,-1600 + 600,- 550 + 600,-1600
+ 600
Sum: 67800
Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)
Send NEC sendRaw data with 8 bit address=0xFB04 and command 0x08 and exact timing (16 bit array format)
Protocol=NEC Address=0x4 Command=0x8 Raw-Data=0xF708FB04 32 bits LSB first
Send with: IrSender.sendNEC(0x4, 0x8, <numberOfRepeats>);
rawData[68]:
-1050150
+8950,-4400
+ 600,- 550 + 600,- 500 + 600,-1700 + 550,- 550
+ 600,- 500 + 600,- 550 + 600,- 550 + 550,- 550
+ 600,-1650 + 600,-1650 + 600,- 550 + 550,-1700
+ 550,-1650 + 600,-1650 + 600,-1700 + 550,-1700
+ 550,- 550 + 600,- 500 + 600,- 550 + 600,-1650
+ 550,- 550 + 600,- 550 + 600,- 500 + 600,- 550
+ 600,-1650 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,-1650 + 600,-1650 + 600,-1700 + 550,-1650
+ 600
Sum: 67950
-1052400
+8950,-4450
+ 600,- 500 + 650,- 500 + 600,-1650 + 600,- 550
+ 600,- 500 + 600,- 500 + 650,- 500 + 600,- 500
+ 650,-1650 + 600,-1600 + 650,- 500 + 600,-1650
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,-1600
+ 650,- 500 + 600,- 550 + 600,- 500 + 600,-1650
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,- 550
+ 600,-1650 + 600,-1650 + 600,-1650 + 600,-1600
+ 650
Sum: 68000
Send NEC / ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)
Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)
Protocol=Onkyo Address=0x102 Command=0x304 Raw-Data=0x3040102 32 bits LSB first
Send with: IrSender.sendOnkyo(0x102, 0x304, <numberOfRepeats>);
rawData[68]:
-1050250
+8900,-4450
+ 550,- 550 + 600,-1600 + 600,- 550 + 600,- 500
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,- 550
+ 600,-1650 + 550,- 550 + 600,- 550 + 550,- 550
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,- 550
+ 600,- 550 + 550,- 550 + 600,-1650 + 550,- 550
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,- 550
+ 600,-1650 + 600,-1600 + 600,- 550 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 550
+ 550
-1050700
+8850,-4400
+ 600,- 550 + 600,-1600 + 650,- 500 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,-1650 + 600,- 500
+ 650,- 500 + 600,- 500 + 650,- 500 + 600,- 500
+ 650,-1600 + 600,-1650 + 600,- 500 + 650,- 500
+ 600,- 500 + 650,- 500 + 600,- 500 + 650,- 500
+ 600
Sum: 55400
Send NEC with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first
Send NEC with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first (0x40802CD3)
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
rawData[68]:
-1050700
+8850,-4450
+ 600,- 550 + 600,-1650 + 550,- 550 + 600,- 550
+ 550,- 550 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,- 550 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,- 550 + 600,- 500 + 600,-1650 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,- 500 + 600,- 550
+ 600,-1650 + 550,-1650 + 600,- 550 + 550,-1650
+ 600,- 550 + 600,- 550 + 550,-1650 + 650,-1650
+ 550
Sum: 61000
-1052700
+8900,-4450
+ 600,- 500 + 650,-1600 + 600,- 500 + 650,- 500
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
+ 650,- 500 + 600,- 500 + 600,- 550 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,-1650 + 600,- 500
+ 650,-1600 + 600,-1650 + 600,- 500 + 600,- 500
+ 650,-1600 + 600,-1650 + 600,- 500 + 650,-1600
+ 600,- 550 + 600,- 500 + 600,-1650 + 600,-1650
+ 600
Sum: 61050
Send Panasonic 0xB, 0x10 as generic PulseDistance
Send Panasonic 0xB, 0x10 as 48 bit PulseDistance using ProtocolConstants
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
rawData[100]:
-1050000
+3450,-1700
+ 450,- 400 + 500,-1250 + 450,- 400 + 450,- 400
+ 500,- 350 + 500,- 400 + 450,- 400 + 450,- 400
+ 500,- 400 + 450,- 400 + 450,- 400 + 500,- 400
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,- 400
+ 450,- 450 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,-1300 + 450,-1250 + 500,- 350 + 500,-1250
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,- 450
+ 450,- 400 + 450,- 400 + 450,- 450 + 450,- 400
+ 450,-1300 + 400,- 450 + 450,- 400 + 500,- 400
+ 450,- 400 + 450,- 400 + 450,- 450 + 450,- 400
+ 450,- 450 + 400,-1300 + 450,- 400 + 450,-1300
+ 400
Sum: 54000
Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance
LSB first
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
rawData[100]:
-1048150
+3450,-1650
+ 450,- 400 + 450,-1250 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 350
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,-1200 + 450,-1300 + 450,- 400 + 450,-1250
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 350
+ 450,-1250 + 500,- 400 + 450,- 400 + 400,- 400
-1068700
+3450,-1700
+ 450,- 400 + 450,-1200 + 500,- 400 + 350,- 450
+ 450,- 400 + 450,- 450 + 450,- 400 + 450,- 350
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,-1250
+ 450,- 450 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 350 + 450,-1300 + 450,- 400 + 450,- 400
+ 400,- 450 + 400,- 400 + 500,- 400 + 450,- 400
+ 450,-1250 + 450,-1200 + 500,- 350 + 450,-1300
+ 400,- 450 + 450,- 400 + 450,- 400 + 450,- 350
+ 450,- 450 + 450,- 400 + 400,- 450 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,-1200 + 500,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 300,- 500 + 450,- 450 + 450,- 400
+ 450,- 400 + 450,-1250 + 450,- 400 + 450,-1250
+ 450
Sum: 53150
Sum: 53200
MSB first
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
rawData[100]:
-1061400
+3450,-1700
+ 450,- 400 + 450,-1250 + 450,- 400 + 450,- 400
-1062900
+3450,-1650
+ 500,- 350 + 500,-1200 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 400,- 450 + 450,- 400
+ 450,- 400 + 450,-1200 + 450,- 450 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 350
+ 450,- 450 + 450,-1200 + 450,- 450 + 450,- 400
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 400,-1250 + 500,-1200 + 500,- 350 + 500,-1250
+ 400,-1300 + 450,-1250 + 450,- 400 + 450,-1250
+ 450,- 400 + 400,- 450 + 450,- 350 + 450,- 450
+ 450,- 400 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,- 400 + 400,- 450 + 450,- 450
+ 450,- 350 + 450,- 400 + 500,- 350 + 450,- 400
+ 450,-1250 + 450,- 400 + 450,- 400 + 450,- 400
+ 400,- 450 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,-1250 + 450,- 400 + 400,-1300
+ 500,- 350 + 450,- 400 + 450,- 400 + 450,- 400
+ 450,-1200 + 500,- 400 + 450,- 400 + 450,- 400
+ 350,- 500 + 400,- 450 + 450,- 400 + 450,- 400
+ 450,- 400 + 450,-1250 + 450,- 400 + 450,-1250
+ 450
Sum: 53200
Sum: 53150
Send generic 56 bit PulseDistance 0x43D8613C and 0x3BC3BC LSB first
Protocol=PulseDistance Raw-Data=0x3BC3BC 56 bits LSB first
Send with:
uint32_t tRawData[]={0x43D8613C, 0x3BC3BC};
IrSender.sendPulseDistanceWidthFromArray(38, 8800, 4400, 550, 1700, 550, 600, &tRawData[0], 56, PROTOCOL_IS_LSB_FIRST, <millisofRepeatPeriod>, <numberOfRepeats>);
IrSender.sendPulseDistanceWidthFromArray(38, 8850, 4450, 600, 1650, 600, 600, &tRawData[0], 56, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, <millisofRepeatPeriod>, <numberOfRepeats>);
rawData[116]:
-1067200
+8800,-4400
+ 550,- 600 + 550,- 600 + 550,-1650 + 550,-1700
+ 550,-1700 + 550,-1650 + 550,- 600 + 550,- 600
+ 550,-1700 + 550,- 600 + 550,- 600 + 550,- 600
+ 550,- 600 + 550,-1650 + 550,-1700 + 550,- 600
+ 550,- 600 + 550,- 600 + 550,- 600 + 550,-1650
+ 550,-1700 + 550,- 600 + 550,-1700 + 550,-1650
+ 550,-1700 + 550,-1700 + 550,- 600 + 550,- 600
+ 550,- 600 + 550,- 600 + 550,-1650 + 550,- 600
+ 550,- 600 + 550,- 600 + 550,-1700 + 550,-1650
+ 550,-1700 + 550,-1700 + 550,- 600 + 550,-1650
+ 600,-1650 + 550,-1700 + 550,- 600 + 550,- 650
+ 500,- 600 + 550,- 600 + 550,-1650 + 550,-1700
+ 550,-1700 + 550,-1650 + 600,- 600 + 550,-1650
+ 550,-1700 + 550,-1700 + 550,- 600 + 550,- 600
-1068600
+8850,-4450
+ 500,- 600 + 550,- 600 + 550,-1650 + 600,-1650
+ 550,-1650 + 600,-1650 + 600,- 550 + 600,- 550
+ 600,-1650 + 550,- 600 + 550,- 600 + 550,- 600
+ 550,- 600 + 550,-1650 + 550,-1700 + 600,- 550
+ 600,- 550 + 600,- 550 + 600,- 550 + 550,-1650
+ 600,-1650 + 600,- 550 + 600,-1650 + 550,-1650
+ 600,-1650 + 600,-1650 + 550,- 600 + 550,- 550
+ 600,- 600 + 550,- 600 + 550,-1650 + 600,- 550
+ 550,- 600 + 600,- 600 + 550,-1650 + 600,-1650
+ 550,-1700 + 600,-1650 + 550,- 600 + 550,-1650
+ 550,-1700 + 600,-1600 + 600,- 550 + 600,- 600
+ 550,- 550 + 600,- 600 + 550,-1650 + 550,-1700
+ 600,-1600 + 600,-1650 + 550,- 600 + 600,-1650
+ 600,-1650 + 600,-1650 + 600,- 550 + 550,- 600
+ 550
Sum: 108450
Sum: 108550
Send Onkyo (NEC with 16 bit command)
Protocol=Onkyo Address=0xFFF1 Command=0x7676 Raw-Data=0x7676FFF1 32 bits LSB first
Send with: IrSender.sendOnkyo(0xFFF1, 0x7676, <numberOfRepeats>);
rawData[68]:
-1064500
+8900,-4500
+ 500,-1650 + 600,- 550 + 600,- 500 + 600,- 550
+ 550,-1700 + 550,-1650 + 600,-1650 + 600,-1650
+ 550,-1650 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,-1650 + 550,-1650 + 600,-1650 + 600,- 550
+ 550,- 550 + 600,-1650 + 600,-1600 + 650,- 500
+ 600,-1650 + 600,-1600 + 600,-1650 + 550,- 550
+ 600
-1088350
+8900,-4400
+ 650,-1600 + 600,- 550 + 600,- 500 + 600,- 550
+ 600,-1600 + 600,-1650 + 600,-1600 + 650,-1600
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,-1600
+ 650,-1600 + 600,-1650 + 600,-1650 + 600,-1600
+ 600,- 500 + 650,-1600 + 600,-1650 + 600,- 500
+ 650,-1600 + 600,-1600 + 650,-1600 + 600,- 550
+ 600,- 500 + 600,-1650 + 600,-1600 + 600,- 550
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,- 500
+ 650
Sum: 75400
Send Apple
Protocol=Apple Address=0xF1 Command=0x76 Raw-Data=0xF17687EE 32 bits LSB first
Send with: IrSender.sendApple(0xF1, 0x76, <numberOfRepeats>);
rawData[68]:
-1044500
+8900,-4500
+ 500,- 550 + 600,-1650 + 550,-1650 + 600,-1650
+ 550,- 550 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,- 550
+ 600,- 500 + 600,- 550 + 550,- 550 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,- 550
+ 550,-1650 + 600,- 550 + 550,- 550 + 550,- 600
+ 550,-1650 + 600,-1650 + 600,-1650 + 550,-1700
+ 550
Sum: 72050
-1045400
+8900,-4450
+ 600,- 500 + 600,-1650 + 600,-1600 + 650,-1600
+ 600,- 550 + 600,-1600 + 600,-1650 + 550,-1700
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,- 500
+ 600,- 550 + 550,- 550 + 600,- 500 + 650,-1600
+ 600,- 550 + 600,-1600 + 600,-1650 + 600,- 500
+ 600,-1650 + 600,-1650 + 600,-1600 + 650,- 500
+ 600,-1600 + 650,- 500 + 600,- 500 + 650,- 500
+ 600,-1600 + 650,-1600 + 600,-1650 + 600,-1600
+ 650
Sum: 72100
Send Panasonic
Protocol=Panasonic Address=0xFF1 Command=0x76 Raw-Data=0x9976FF10 48 bits LSB first
Send with: IrSender.sendPanasonic(0xFF1, 0x76, <numberOfRepeats>);
rawData[100]:
-1044250
+3500,-1650
+ 450,- 400 + 450,-1250 + 450,- 450 + 450,- 400
+ 450,- 450 + 400,- 450 + 450,- 400 + 450,- 450
+ 400,- 450 + 450,- 400 + 450,- 450 + 400,- 450
+ 450,- 400 + 450,-1300 + 400,- 450 + 450,- 400
+ 450,- 450 + 400,- 450 + 450,- 400 + 450,- 450
+ 400,-1300 + 450,- 400 + 450,- 450 + 400,- 450
+ 450,-1300 + 400,-1300 + 450,-1250 + 450,-1300
+ 450,-1250 + 450,-1300 + 400,-1300 + 400,-1300
+ 450,- 450 + 400,-1300 + 450,-1250 + 450,- 450
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,- 400
+ 450,-1300 + 400,- 450 + 450,- 400 + 450,-1300
+ 400,-1300 + 450,- 400 + 450,- 450 + 400,-1300
-1045150
+3450,-1700
+ 450,- 400 + 500,-1250 + 450,- 400 + 500,- 400
+ 450,- 400 + 400,- 450 + 500,- 350 + 450,- 450
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,- 400 + 500,-1250 + 450,- 400 + 500,- 350
+ 500,- 400 + 450,- 400 + 450,- 450 + 450,- 400
+ 450,-1250 + 500,- 400 + 450,- 400 + 450,- 400
+ 450,-1300 + 450,-1250 + 450,-1300 + 400,-1300
+ 450,-1300 + 450,-1250 + 450,-1250 + 500,-1250
+ 450,- 450 + 450,-1250 + 450,-1250 + 500,- 400
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,- 450
+ 450,-1250 + 450,- 400 + 450,- 400 + 500,-1250
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,-1250
+ 450
Sum: 64250
Sum: 64300
Send Kaseikyo with 0x4711 as Vendor ID
Protocol=Kaseikyo Address=0xFF1 Command=0x76 Extra=0x4711 Raw-Data=0x9A76FF13 48 bits LSB first
Send with: IrSender.sendKaseikyo(0xFF1, 0x76, <numberOfRepeats>, 0x4711);
rawData[100]:
-1064850
-1066350
+3450,-1700
+ 400,-1300 + 450,- 400 + 450,- 450 + 400,- 450
+ 450,-1250 + 450,- 450 + 400,- 450 + 450,- 400
+ 450,-1300 + 450,-1250 + 450,-1300 + 450,- 400
+ 450,- 450 + 400,- 450 + 450,-1250 + 450,- 450
+ 400,-1300 + 450,-1300 + 400,- 450 + 450,- 400
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,- 400
+ 450,-1300 + 400,-1300 + 450,-1300 + 450,-1250
+ 450,-1250 + 450,-1300 + 400,-1300 + 450,-1300
+ 450,- 400 + 400,-1300 + 450,-1250 + 500,- 400
+ 400,-1300 + 450,-1300 + 400,-1300 + 450,- 400
+ 450,- 450 + 400,-1300 + 450,- 400 + 450,-1300
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,-1250 + 500,- 400 + 450,- 400 + 450,- 400
+ 500,-1250 + 450,-1250 + 450,-1300 + 450,- 400
+ 450,- 400 + 500,- 400 + 450,-1250 + 450,- 400
+ 500,-1250 + 450,-1250 + 500,- 350 + 500,- 400
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,-1250 + 500,-1250 + 450,-1250 + 450,-1250
+ 500,-1250 + 450,-1250 + 500,-1250 + 450,-1250
+ 500,- 400 + 450,-1250 + 450,-1300 + 450,- 400
+ 450,-1250 + 450,-1250 + 500,-1250 + 450,- 400
+ 500,- 350 + 500,-1250 + 450,- 400 + 450,-1300
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,-1250
+ 450
Sum: 69350
@ -258,20 +279,20 @@ Send Kaseikyo_Denon variant
Protocol=Kaseikyo_Denon Address=0xFF1 Command=0x76 Raw-Data=0x9976FF10 48 bits LSB first
Send with: IrSender.sendKaseikyo_Denon(0xFF1, 0x76, <numberOfRepeats>);
rawData[100]:
-1065400
+3450,-1700
+ 450,- 400 + 450,- 450 + 400,-1300 + 450,- 400
+ 450,-1300 + 400,- 450 + 450,-1300 + 450,- 400
+ 450,- 400 + 450,-1250 + 450,- 450 + 450,- 400
+ 450,-1300 + 450,-1250 + 450,- 400 + 450,- 450
+ 450,- 400 + 450,- 450 + 400,- 450 + 450,- 400
+ 450,-1300 + 400,- 450 + 450,- 400 + 450,- 450
+ 400,-1300 + 450,-1250 + 450,-1300 + 450,-1250
+ 450,-1300 + 400,-1300 + 450,-1250 + 450,-1300
+ 400,- 450 + 450,-1250 + 500,-1250 + 400,- 450
+ 450,-1300 + 450,-1250 + 450,-1300 + 400,- 450
+ 450,-1250 + 500,- 400 + 450,- 400 + 450,-1250
+ 500,-1250 + 400,- 450 + 450,- 400 + 450,-1300
-1066900
+3500,-1650
+ 500,- 400 + 450,- 400 + 450,-1250 + 500,- 400
+ 450,-1250 + 450,- 400 + 500,-1250 + 450,- 400
+ 450,- 400 + 500,-1250 + 450,- 400 + 450,- 400
+ 500,-1250 + 450,-1250 + 450,- 400 + 500,- 400
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,-1250 + 500,- 400 + 450,- 400 + 450,- 400
+ 500,-1250 + 450,-1250 + 450,-1250 + 500,-1250
+ 450,-1250 + 450,-1250 + 500,-1250 + 400,-1350
+ 450,- 400 + 450,-1250 + 450,-1300 + 450,- 400
+ 450,-1250 + 500,-1250 + 450,-1250 + 450,- 450
+ 450,-1250 + 450,- 400 + 500,- 400 + 450,-1250
+ 500,-1250 + 450,- 400 + 450,- 400 + 500,-1250
+ 450
Sum: 67700
@ -279,32 +300,32 @@ Send Denon
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0x45D8 15 bits MSB first
Send with: IrSender.sendDenon(0x11, 0x76, <numberOfRepeats>);
rawData[32]:
-1063250
+ 250,-1800 + 300,- 750 + 250,- 800 + 250,- 800
+ 300,-1750 + 300,- 750 + 250,-1800 + 300,-1800
+ 300,-1750 + 250,- 800 + 300,-1750 + 300,-1800
+ 250,- 800 + 250,- 750 + 300,- 750 + 300
-1064700
+ 300,-1800 + 250,- 800 + 250,- 750 + 350,- 700
+ 300,-1800 + 250,- 800 + 250,-1800 + 300,-1750
+ 350,-1750 + 300,- 750 + 250,-1800 + 300,-1750
+ 300,- 750 + 300,- 750 + 250,- 800 + 250
Sum: 23100
Send Denon/Sharp variant
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x45DA 15 bits MSB first
Send with: IrSender.sendSharp(0x11, 0x76, <numberOfRepeats>);
rawData[32]:
-1024950
+ 350,-1750 + 300,- 750 + 250,- 750 + 350,- 700
+ 300,-1800 + 250,- 750 + 350,-1750 + 300,-1750
+ 300,-1800 + 250,- 750 + 300,-1800 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,- 750 + 300
-1025400
+ 300,-1750 + 300,- 750 + 300,- 750 + 300,- 750
+ 250,-1800 + 300,- 750 + 300,-1750 + 300,-1750
+ 300,-1800 + 300,- 700 + 350,-1750 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,- 750 + 350
Sum: 24150
Send Sony/SIRCS with 7 command and 5 address bits
Protocol=Sony Address=0x11 Command=0x76 Raw-Data=0x8F6 12 bits LSB first
Send with: IrSender.sendSony(0x11, 0x76, <numberOfRepeats>);
rawData[26]:
-1027050
+2400,- 650
+ 600,- 550 +1200,- 550 +1250,- 550 + 650,- 550
+1250,- 550 +1250,- 550 +1250,- 550 +1200,- 600
-1027500
+2400,- 550
+ 650,- 550 +1250,- 550 +1250,- 550 + 650,- 550
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
+ 650,- 550 + 650,- 550 + 650,- 550 +1250
Sum: 21000
@ -313,34 +334,34 @@ Protocol=Sony Address=0xF1 Command=0x76 Raw-Data=0x78F6 15 bits LSB first
Send with: IrSender.sendSony(0xF1, 0x76, <numberOfRepeats>);
rawData[32]:
-1023750
+2350,- 600
+ 600,- 600 +1200,- 550 +1250,- 550 + 650,- 550
+1250,- 550 +1200,- 600 +1200,- 600 +1200,- 600
+ 650,- 600 + 600,- 600 + 600,- 550 +1250,- 600
+1200,- 550 +1250,- 550 +1250
Sum: 26350
+2450,- 600
+ 600,- 550 +1200,- 550 +1250,- 550 + 650,- 550
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
+ 650,- 550 + 650,- 550 + 650,- 600 +1200,- 550
+1250,- 550 +1250,- 550 +1250
Sum: 26400
Send Sony/SIRCS with 7 command and 13 address bits
Protocol=Sony Address=0x1FF1 Command=0x76 Raw-Data=0xFF8F6 20 bits LSB first
Send with: IrSender.sendSony(0x1FF1, 0x76, <numberOfRepeats>);
rawData[42]:
-1027100
+2450,- 550
+ 600,- 600 +1200,- 600 +1200,- 550 + 650,- 550
-1027150
+2450,- 600
+ 600,- 550 +1250,- 550 +1250,- 550 + 600,- 550
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
+ 650,- 550 + 650,- 550 + 650,- 550 +1250,- 550
+1250,- 550 +1200,- 600 +1250,- 550 +1200,- 600
+1200,- 600 +1200,- 550 +1250,- 550 +1250
Sum: 35350
+1250,- 550 +1250,- 550 +1250,- 550 +1250,- 550
+1250,- 550 +1250,- 550 +1250,- 550 +1250
Sum: 35400
Send RC5
Protocol=RC5 Address=0x11 Command=0x36 Raw-Data=0x1476 13 bits MSB first
Send with: IrSender.sendRC5(0x11, 0x36, <numberOfRepeats>);
rawData[20]:
-1030100
+ 900,- 850
+1800,-1800 +1750,- 900 + 900,- 850 + 900,-1800
+ 850,- 900 + 900,- 850 +1800,-1750 + 900,- 900
-1030150
+ 900,- 900
+1800,-1750 +1800,- 850 + 900,- 850 + 900,-1750
+ 950,- 850 + 900,- 850 +1800,-1750 + 950,- 850
+1800
Sum: 23100
@ -350,108 +371,108 @@ Send with: IrSender.sendRC5(0x11, 0x76, <numberOfRepeats>);
rawData[20]:
-1021700
+1800,-1750
+ 900,- 900 +1750,- 900 + 900,- 850 + 900,-1800
+ 850,- 900 + 900,- 900 +1750,-1800 + 850,- 900
+ 850,- 900 +1800,- 850 + 950,- 850 + 900,-1750
+ 900,- 850 + 950,- 850 +1800,-1750 + 900,- 850
+1800
Sum: 23100
Sum: 23050
Send RC6
Protocol=RC6 Address=0xF1 Command=0x76 Raw-Data=0xF176 20 bits MSB first
Send with: IrSender.sendRC6(0xF1, 0x76, <numberOfRepeats>);
rawData[36]:
-1018950
+2650,- 900
+ 450,- 900 + 450,- 450 + 450,- 450 + 450,- 850
+1350,- 450 + 450,- 450 + 450,- 450 + 450,- 900
+ 450,- 450 + 450,- 400 + 900,- 900 + 900,- 450
+ 450,- 450 + 450,- 900 + 900,- 400 + 450,- 900
-1019050
+2650,- 850
+ 500,- 850 + 500,- 400 + 450,- 450 + 450,- 850
+1400,- 400 + 450,- 450 + 450,- 450 + 450,- 900
+ 450,- 450 + 450,- 400 + 950,- 850 + 900,- 450
+ 450,- 450 + 450,- 850 + 950,- 400 + 450,- 900
+ 450
Sum: 23200
Sum: 23150
Send Samsung
Protocol=Samsung Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
Send with: IrSender.sendSamsung(0xFFF1, 0x76, <numberOfRepeats>);
rawData[68]:
-1027000
+4400,-4450
+ 550,-1650 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 600,-1650
+ 550,-1650 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,- 550
+ 550,-1650 + 600,- 550 + 600,- 500 + 600,-1650
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,-1650
+4500,-4400
+ 600,-1600 + 650,- 500 + 600,- 500 + 650,- 500
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,-1650
+ 600,-1600 + 600,-1650 + 600,-1650 + 600,-1600
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,-1650
+ 600,- 500 + 650,-1600 + 600,-1650 + 600,- 500
+ 650,-1600 + 600,-1650 + 600,-1650 + 600,- 500
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,-1600
+ 600,- 550 + 600,- 550 + 550,- 550 + 600,-1650
+ 550
Sum: 68650
Sum: 68750
Send JVC
Protocol=JVC Address=0xF1 Command=0x76 Raw-Data=0x76F1 16 bits LSB first
Send with: IrSender.sendJVC(0xF1, 0x76, <numberOfRepeats>);
rawData[36]:
-1044550
+8350,-4150
-1045500
+8400,-4150
+ 550,-1550 + 550,- 500 + 550,- 500 + 550,- 500
+ 550,-1550 + 550,-1550 + 500,-1600 + 550,-1550
+ 500,- 550 + 500,-1600 + 500,-1600 + 500,- 550
+ 500,-1550 + 550,-1550 + 550,-1550 + 550,- 500
+ 550,-1500 + 600,-1500 + 600,-1500 + 550,-1550
+ 550,- 500 + 550,-1550 + 550,-1550 + 550,- 500
+ 500,-1600 + 550,-1550 + 550,-1500 + 600,- 500
+ 550
Sum: 40300
Sum: 40350
Send LG
Protocol=LG Address=0xF1 Command=0x7676 Raw-Data=0xF17676A 28 bits MSB first
Send with: IrSender.sendLG(0xF1, 0x7676, <numberOfRepeats>);
rawData[60]:
-1025600
+8950,-4150
+ 500,-1600 + 500,-1550 + 500,-1600 + 500,-1550
+ 500,- 550 + 500,- 550 + 500,- 550 + 500,-1550
+ 550,- 550 + 500,-1550 + 500,-1550 + 550,-1550
+ 500,- 550 + 500,-1550 + 500,-1600 + 500,- 550
+ 500,- 550 + 500,-1550 + 500,-1550 + 550,-1550
+ 500,- 550 + 500,-1550 + 500,-1550 + 550,- 550
+ 500,-1550 + 500,- 550 + 500,-1550 + 500,- 550
-1026150
+8950,-4200
+ 400,-1600 + 500,-1550 + 550,-1550 + 500,-1550
+ 550,- 500 + 550,- 500 + 500,- 550 + 550,-1500
+ 550,- 550 + 500,-1550 + 550,-1500 + 500,-1600
+ 500,- 550 + 500,-1550 + 500,-1550 + 500,- 550
+ 550,- 500 + 550,-1550 + 500,-1550 + 500,-1550
+ 500,- 550 + 500,-1600 + 550,-1500 + 500,- 550
+ 500,-1600 + 500,- 550 + 450,-1600 + 550,- 500
+ 500
Sum: 60350
Sum: 60300
Send MagiQuest
Protocol=MagiQuest Address=0xFFF1 Command=0x7676 Raw-Data=0xFFF17676 56 bits MSB first
Protocol=MagiQuest Address=0xFFF1 Command=0x7676 Raw-Data=0xFFF1 56 bits MSB first
Send with: IrSender.sendMagiQuest(0xFFF1, 0x7676, <numberOfRepeats>);
rawData[112]:
-1039800
+ 350,- 800 + 350,- 800 + 300,- 850 + 300,- 850
-1040650
+ 300,- 850 + 300,- 850 + 300,- 850 + 300,- 850
+ 250,- 900 + 300,- 850 + 300,- 850 + 300,- 850
+ 350,- 800 + 300,- 850 + 300,- 850 + 300,- 850
+ 300,- 900 + 250,- 900 + 250,- 850 + 300,- 850
+ 300,- 850 + 250,- 900 + 250,- 900 + 300,- 850
+ 300,- 850 + 300,- 850 + 300,- 850 + 300,- 850
+ 300,- 850 + 300,- 850 + 300,- 850 + 250,- 900
+ 250,- 900 + 250,- 900 + 300,- 800 + 350,- 800
+ 600,- 550 + 650,- 500 + 600,- 550 + 600,- 550
+ 600,- 550 + 600,- 550 + 600,- 550 + 600,- 550
+ 550,- 600 + 600,- 550 + 600,- 550 + 600,- 550
+ 300,- 850 + 300,- 850 + 300,- 850 + 600,- 550
+ 300,- 850 + 550,- 600 + 550,- 600 + 600,- 550
+ 250,- 900 + 600,- 550 + 600,- 550 + 300,- 850
+ 300,- 850 + 600,- 550 + 550,- 600 + 600,- 550
+ 250,- 900 + 550,- 550 + 650,- 500 + 350
+ 600,- 550 + 550,- 550 + 600,- 600 + 600,- 500
+ 650,- 500 + 650,- 500 + 650,- 500 + 650,- 500
+ 650,- 550 + 600,- 500 + 650,- 500 + 600,- 550
+ 300,- 850 + 300,- 850 + 300,- 850 + 650,- 550
+ 300,- 850 + 600,- 550 + 600,- 550 + 600,- 550
+ 300,- 850 + 600,- 550 + 600,- 550 + 250,- 900
+ 300,- 800 + 600,- 550 + 600,- 550 + 600,- 550
+ 300,- 850 + 600,- 550 + 600,- 550 + 300
Sum: 63500
Send Bosewave with no address and 8 command bits
Protocol=BoseWave Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
Send with: IrSender.sendBoseWave(0x0, 0x76, <numberOfRepeats>);
rawData[36]:
-1071300
+1000,-1450
+ 550,- 500 + 500,-1450 + 500,-1450 + 550,- 450
+ 500,-1450 + 550,-1450 + 550,-1450 + 550,- 400
+ 550,-1450 + 550,- 450 + 500,- 500 + 550,-1400
+ 550,- 450 + 550,- 450 + 550,- 450 + 550,-1400
-1071050
+1050,-1450
+ 550,- 400 + 600,-1400 + 550,-1400 + 550,- 600
+ 400,-1500 + 500,-1400 + 550,-1450 + 550,- 450
+ 550,-1400 + 550,- 450 + 550,- 450 + 550,-1400
+ 550,- 450 + 550,- 450 + 500,- 500 + 550,-1400
+ 550
Sum: 26750
Force buffer overflow by sending 280 marks and spaces
Protocol=UNKNOWN Hash=0x0 0 bits (incl. gap and start) received
Overflow detected
Try to increase the "RAW_BUFFER_LENGTH" value of 112 in ../src/UnitTest.cpp
Try to increase the "RAW_BUFFER_LENGTH" value of 140 in ../src/UnitTest.cpp
address=0xF2 command=0x87
@ -461,15 +482,15 @@ Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
-3276750
+8900,-4500
+ 500,- 550 + 600,-1650 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,-1650 + 550,- 550 + 600,-1650 + 600,-1650
+ 600,- 500 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,-1650
+ 600,- 550 + 600,- 500 + 600,- 550 + 550,-1650
+ 600,-1650 + 600,-1650 + 600,-1650 + 550,- 550
+8950,-4400
+ 600,- 500 + 600,-1650 + 600,- 500 + 650,- 500
+ 600,-1600 + 650,-1600 + 600,-1650 + 600,-1600
+ 650,-1600 + 600,- 550 + 600,-1600 + 650,-1600
+ 600,- 500 + 550,- 600 + 600,- 500 + 650,- 500
+ 600,-1650 + 600,-1600 + 600,-1650 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
+ 600
Sum: 67650
@ -477,71 +498,71 @@ Send NEC with 16 bit address
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
-1045100
+8900,-4500
+ 500,- 550 + 600,-1650 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 600,-1600
+ 600,-1650 + 600,- 500 + 600,-1650 + 600,-1650
-1046050
+8900,-4400
+ 600,- 550 + 600,-1600 + 600,- 550 + 600,- 500
+ 600,-1600 + 650,-1600 + 600,-1650 + 600,-1600
+ 650,-1600 + 600,- 550 + 600,-1600 + 550,-1700
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 600,- 500
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,-1650
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,-1650
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
+ 600
Sum: 67650
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,- 500
+ 600,- 550 + 600,- 500 + 600,- 550 + 600,-1600
+ 650,- 500 + 600,- 550 + 600,- 500 + 600,-1650
+ 600,-1650 + 550,-1650 + 600,-1600 + 650,- 500
+ 550
Sum: 67550
Send Onkyo (NEC with 16 bit command)
Protocol=Onkyo Address=0xF2 Command=0x8787 Raw-Data=0x878700F2 32 bits LSB first
Send with: IrSender.sendOnkyo(0xF2, 0x8787, <numberOfRepeats>);
rawData[68]:
-1045800
+8900,-4400
+ 600,- 550 + 550,-1650 + 600,- 550 + 600,- 500
+ 550,-1700 + 600,-1650 + 550,-1650 + 600,-1650
+ 600,- 500 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,- 550 + 600,- 550 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 600,- 500
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,-1650
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,- 550
+ 550,- 550 + 600,- 550 + 550,- 550 + 600,-1650
-1046750
+8950,-4400
+ 600,- 550 + 600,-1600 + 600,- 550 + 600,- 500
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,-1650
+ 600,- 500 + 650,- 500 + 600,- 500 + 650,- 500
+ 600,- 500 + 550,- 600 + 600,- 500 + 600,- 550
+ 600,-1600 + 650,-1600 + 600,-1600 + 650,- 500
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
+ 600,-1650 + 600,-1600 + 650,-1600 + 600,- 550
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
+ 600
Sum: 64300
Sum: 64350
Send Apple
Protocol=Apple Address=0xF2 Command=0x87 Raw-Data=0xF28787EE 32 bits LSB first
Send with: IrSender.sendApple(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
-1044300
-1045250
+8900,-4400
+ 600,- 550 + 600,-1650 + 550,-1650 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,-1650 + 550,-1650
+ 600,-1650 + 600,-1650 + 600,-1650 + 550,- 550
+ 600,- 550 + 550,- 550 + 600,- 550 + 550,-1650
+ 600,-1650 + 600,-1650 + 550,-1650 + 600,- 550
+ 550,- 550 + 600,- 550 + 550,- 550 + 600,-1650
+ 600,- 500 + 600,-1650 + 550,- 550 + 600,- 550
+ 550,-1650 + 600,-1650 + 600,-1650 + 600,-1600
+ 600
Sum: 70950
+ 650,- 500 + 600,-1600 + 650,-1600 + 600,-1650
+ 600,- 500 + 650,-1600 + 600,-1650 + 600,-1600
+ 650,-1600 + 600,-1650 + 600,-1600 + 650,- 500
+ 600,- 500 + 650,- 500 + 600,- 500 + 650,-1600
+ 600,-1650 + 600,-1650 + 600,-1600 + 600,- 550
+ 600,- 500 + 600,- 550 + 600,- 500 + 600,-1650
+ 600,- 500 + 600,-1650 + 600,- 500 + 600,- 550
+ 600,-1600 + 650,-1600 + 600,-1650 + 600,-1700
+ 550
Sum: 71000
Send Panasonic
Protocol=Panasonic Address=0xF2 Command=0x87 Raw-Data=0xA8870F20 48 bits LSB first
Send with: IrSender.sendPanasonic(0xF2, 0x87, <numberOfRepeats>);
rawData[100]:
-1044250
-1045200
+3450,-1700
+ 450,- 400 + 450,-1300 + 450,- 400 + 450,- 400
+ 450,- 450 + 400,- 450 + 450,- 400 + 450,- 450
+ 400,- 450 + 450,- 400 + 450,- 450 + 400,- 450
+ 450,- 400 + 450,-1300 + 400,- 450 + 450,- 450
+ 400,- 450 + 450,- 400 + 450,- 450 + 400,- 450
+ 400,- 450 + 450,-1300 + 400,- 450 + 450,- 400
+ 450,-1300 + 450,-1250 + 450,-1300 + 400,-1300
+ 450,- 400 + 450,- 450 + 400,- 450 + 450,- 400
+ 450,-1300 + 450,-1250 + 450,-1300 + 400,- 450
+ 450,- 400 + 450,- 450 + 400,- 450 + 450,-1250
+ 450,- 450 + 400,- 450 + 400,- 450 + 450,-1300
+ 400,- 450 + 450,-1250 + 450,- 400 + 450,-1300
+ 450,- 400 + 450,-1250 + 450,- 400 + 500,- 400
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,- 400
+ 500,- 400 + 450,-1250 + 450,- 400 + 500,- 400
+ 450,- 400 + 450,- 400 + 500,- 400 + 450,- 400
+ 450,- 400 + 500,-1250 + 450,- 400 + 450,- 400
+ 500,-1250 + 450,-1250 + 450,-1300 + 450,-1250
+ 450,- 400 + 500,- 400 + 450,- 400 + 450,- 450
+ 450,-1250 + 450,-1300 + 450,-1250 + 450,- 400
+ 500,- 400 + 450,- 400 + 450,- 400 + 450,-1300
+ 450,- 400 + 450,- 400 + 450,- 450 + 450,-1250
+ 450,- 450 + 450,-1250 + 450,- 400 + 500,-1250
+ 450
Sum: 59150

View File

@ -1,5 +1,5 @@
name=IRremote
version=3.9.0
version=3.9.1
author=shirriff, z3t0, ArminJo
maintainer=Armin Joachimsmeyer <armin.arduino@gmail.com>
sentence=Send and receive infrared signals with multiple protocols

View File

@ -9,7 +9,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2009-2021 Ken Shirriff, Rafi Khan, Armin Joachimsmeyer
* Copyright (c) 2009-2022 Ken Shirriff, Rafi Khan, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -499,6 +499,25 @@ bool IRrecv::decodePulseWidthData(uint_fast8_t aNumberOfBits, uint_fast8_t aStar
return true;
}
/**
* Decode pulse distance protocols.
* The mark (pulse) has constant length, the length of the space determines the bit value.
* Each bit looks like: MARK + SPACE_1 -> 1
* or : MARK + SPACE_0 -> 0
*
* Input is IrReceiver.decodedIRData.rawDataPtr->rawbuf[]
* Output is IrReceiver.decodedIRData.decodedRawData
*
* @param aStartOffset must point to a mark
* @return true if decoding was successful
*/
bool IRrecv::decodePulseDistanceData(PulsePauseWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits,
uint_fast8_t aStartOffset) {
return decodePulseDistanceData(aNumberOfBits, aStartOffset, aProtocolConstants->OneMarkMicros,
aProtocolConstants->OneSpaceMicros, aProtocolConstants->ZeroSpaceMicros, aProtocolConstants->isMSBFirst);
}
/**
* Decode pulse distance protocols.
* The mark (pulse) has constant length, the length of the space determines the bit value.
@ -517,74 +536,49 @@ bool IRrecv::decodePulseDistanceData(uint_fast8_t aNumberOfBits, uint_fast8_t aS
unsigned int *tRawBufPointer = &decodedIRData.rawDataPtr->rawbuf[aStartOffset];
uint32_t tDecodedData = 0;
if (aMSBfirst) {
for (uint_fast8_t i = 0; i < aNumberOfBits; i++) {
// Check for constant length mark
if (!matchMark(*tRawBufPointer, aBitMarkMicros)) {
IR_DEBUG_PRINT(F("Mark="));
IR_DEBUG_PRINT(*tRawBufPointer * MICROS_PER_TICK);
IR_DEBUG_PRINT(F(" is not "));
IR_DEBUG_PRINT(aBitMarkMicros);
IR_DEBUG_PRINT(' ');
return false;
}
tRawBufPointer++;
// Check for variable length space indicating a 0 or 1
if (matchSpace(*tRawBufPointer, aOneSpaceMicros)) {
tDecodedData = (tDecodedData << 1) | 1;
IR_TRACE_PRINT('1');
} else if (matchSpace(*tRawBufPointer, aZeroSpaceMicros)) {
tDecodedData = (tDecodedData << 1) | 0;
IR_TRACE_PRINT('0');
} else {
IR_DEBUG_PRINT(F("Space="));
IR_DEBUG_PRINT(*tRawBufPointer * MICROS_PER_TICK);
IR_DEBUG_PRINT(F(" is not "));
IR_DEBUG_PRINT(aOneSpaceMicros);
IR_DEBUG_PRINT(F(" or "));
IR_DEBUG_PRINT(aZeroSpaceMicros);
IR_DEBUG_PRINT(' ');
return false;
}
tRawBufPointer++;
uint32_t tMask = 1UL;
for (uint_fast8_t i = aNumberOfBits; i > 0; i--) {
// Check for constant length mark
if (!matchMark(*tRawBufPointer, aBitMarkMicros)) {
IR_DEBUG_PRINT(F("Mark="));
IR_DEBUG_PRINT(*tRawBufPointer * MICROS_PER_TICK);
IR_DEBUG_PRINT(F(" is not "));
IR_DEBUG_PRINT(aBitMarkMicros);
IR_DEBUG_PRINT(' ');
return false;
}
IR_TRACE_PRINTLN(F(""));
tRawBufPointer++;
} else {
for (uint32_t tMask = 1UL; aNumberOfBits > 0; tMask <<= 1, aNumberOfBits--) {
// Check for constant length mark
if (!matchMark(*tRawBufPointer, aBitMarkMicros)) {
IR_DEBUG_PRINT(F("Mark="));
IR_DEBUG_PRINT(*tRawBufPointer * MICROS_PER_TICK);
IR_DEBUG_PRINT(F(" is not "));
IR_DEBUG_PRINT(aBitMarkMicros);
IR_DEBUG_PRINT(' ');
return false;
}
tRawBufPointer++;
// Check for variable length space indicating a 0 or 1
if (matchSpace(*tRawBufPointer, aOneSpaceMicros)) {
tDecodedData |= tMask; // set the bit
IR_TRACE_PRINT('1');
} else if (matchSpace(*tRawBufPointer, aZeroSpaceMicros)) {
// do not set the bit
IR_TRACE_PRINT('0');
} else {
IR_DEBUG_PRINT(F("Space="));
IR_DEBUG_PRINT(*tRawBufPointer * MICROS_PER_TICK);
IR_DEBUG_PRINT(F(" is not "));
IR_DEBUG_PRINT(aOneSpaceMicros);
IR_DEBUG_PRINT(F(" or "));
IR_DEBUG_PRINT(aZeroSpaceMicros);
IR_DEBUG_PRINT(' ');
return false;
}
tRawBufPointer++;
if (aMSBfirst) {
tDecodedData <<= 1;
}
IR_TRACE_PRINTLN(F(""));
// Check for variable length space indicating a 0 or 1
if (matchSpace(*tRawBufPointer, aOneSpaceMicros)) {
// set the bit
if (aMSBfirst) {
tDecodedData |= 1;
} else {
tDecodedData |= tMask;
}
IR_TRACE_PRINT('1');
} else if (matchSpace(*tRawBufPointer, aZeroSpaceMicros)) {
// do not set the bit
IR_TRACE_PRINT('0');
} else {
IR_DEBUG_PRINT(F("Space="));
IR_DEBUG_PRINT(*tRawBufPointer * MICROS_PER_TICK);
IR_DEBUG_PRINT(F(" is not "));
IR_DEBUG_PRINT(aOneSpaceMicros);
IR_DEBUG_PRINT(F(" or "));
IR_DEBUG_PRINT(aZeroSpaceMicros);
IR_DEBUG_PRINT(' ');
return false;
}
tRawBufPointer++;
tMask <<= 1;
}
IR_TRACE_PRINTLN(F(""));
decodedIRData.decodedRawData = tDecodedData;
return true;
}
@ -646,10 +640,10 @@ uint_fast8_t IRrecv::getBiphaselevel() {
}
}
// We use another interval from tCurrentTimingIntervals
// We use another interval from tCurrentTimingIntervals
sUsedTimingIntervals++;
// keep track of current timing offset
// keep track of current timing offset
if (sUsedTimingIntervals >= sCurrentTimingIntervals) {
// we have used all intervals of current timing, switch to next timing value
sUsedTimingIntervals = 0;
@ -752,6 +746,25 @@ bool IRrecv::decodeHashOld(decode_results *aResults) {
/**********************************************************************************************************************
* Match functions
**********************************************************************************************************************/
/*
* returns true if values do match
*/
bool IRrecv::checkHeader(PulsePauseWidthProtocolConstants *aProtocolConstants) {
// Check header "mark" and "space"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], aProtocolConstants->HeaderMarkMicros)) {
IR_DEBUG_PRINT(::getProtocolString(aProtocolConstants->ProtocolIndex));
IR_DEBUG_PRINTLN(F(": Header mark length is wrong"));
return false;
}
if (!matchSpace(decodedIRData.rawDataPtr->rawbuf[2], aProtocolConstants->HeaderSpaceMicros)) {
IR_DEBUG_PRINT(::getProtocolString(aProtocolConstants->ProtocolIndex));
IR_DEBUG_PRINTLN(F(": Header space length is wrong"));
return false;
}
return true;
}
/**
* Match function without compensating for marks exceeded or spaces shortened by demodulator hardware
* Currently not used
@ -796,7 +809,7 @@ bool matchMark(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros) {
Serial.print(F(" <= "));
Serial.print(TICKS_HIGH(aMatchValueMicros + MARK_EXCESS_MICROS) * MICROS_PER_TICK, DEC);
#endif
// compensate for marks exceeded by demodulator hardware
// compensate for marks exceeded by demodulator hardware
bool passed = ((aMeasuredTicks >= TICKS_LOW(aMatchValueMicros + MARK_EXCESS_MICROS))
&& (aMeasuredTicks <= TICKS_HIGH(aMatchValueMicros + MARK_EXCESS_MICROS)));
#if defined(TRACE)
@ -829,7 +842,7 @@ bool matchSpace(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros) {
Serial.print(F(" <= "));
Serial.print(TICKS_HIGH(aMatchValueMicros - MARK_EXCESS_MICROS) * MICROS_PER_TICK, DEC);
#endif
// compensate for spaces shortened by demodulator hardware
// compensate for spaces shortened by demodulator hardware
bool passed = ((aMeasuredTicks >= TICKS_LOW(aMatchValueMicros - MARK_EXCESS_MICROS))
&& (aMeasuredTicks <= TICKS_HIGH(aMatchValueMicros - MARK_EXCESS_MICROS)));
#if defined(TRACE)
@ -880,7 +893,7 @@ void CheckForRecordGapsMicros(Print *aSerial, IRData *aIRDataPtr) {
* Since a library should not allocate the "Serial" object, all functions require a pointer to a Print object.
**********************************************************************************************************************/
void IRrecv::printActiveIRProtocols(Print *aSerial) {
// call no class function with same name
// call no class function with same name
::printActiveIRProtocols(aSerial);
}
void printActiveIRProtocols(Print *aSerial) {
@ -948,7 +961,7 @@ void printActiveIRProtocols(Print *aSerial) {
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
*/
void IRrecv::printIRResultShort(Print *aSerial) {
// call no class function with same name
// call no class function with same name
::printIRResultShort(aSerial, &decodedIRData, true);
}
@ -1051,7 +1064,7 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
*/
void IRrecv::printIRSendUsage(Print *aSerial) {
// call no class function with same name
// call no class function with same name
::printIRSendUsage(aSerial, &decodedIRData);
}
@ -1080,21 +1093,21 @@ void printIRSendUsage(Print *aSerial, IRData *aIRDataPtr) {
#if defined(DECODE_DISTANCE)
if (aIRDataPtr->protocol != PULSE_DISTANCE) {
#endif
aSerial->print(getProtocolString(aIRDataPtr->protocol));
aSerial->print(F("(0x"));
/*
* New decoders have address and command
*/
aSerial->print(aIRDataPtr->address, HEX);
aSerial->print(getProtocolString(aIRDataPtr->protocol));
aSerial->print(F("(0x"));
/*
* New decoders have address and command
*/
aSerial->print(aIRDataPtr->address, HEX);
aSerial->print(F(", 0x"));
aSerial->print(aIRDataPtr->command, HEX);
aSerial->print(F(", <numberOfRepeats>"));
if (aIRDataPtr->flags & IRDATA_FLAGS_EXTRA_INFO) {
aSerial->print(F(", 0x"));
aSerial->print(aIRDataPtr->command, HEX);
aSerial->print(F(", <numberOfRepeats>"));
if (aIRDataPtr->flags & IRDATA_FLAGS_EXTRA_INFO) {
aSerial->print(F(", 0x"));
aSerial->print(aIRDataPtr->extra, HEX);
}
aSerial->print(aIRDataPtr->extra, HEX);
}
#if defined(DECODE_DISTANCE)
} else {
aSerial->print("PulseDistanceWidthFromArray(38, ");
@ -1116,6 +1129,7 @@ void printIRSendUsage(Print *aSerial, IRData *aIRDataPtr) {
#else
aSerial->print(F(", PROTOCOL_IS_LSB_FIRST"));
#endif
aSerial->print(F(", SEND_STOP_BIT"));
aSerial->print(F(", <millisofRepeatPeriod>, <numberOfRepeats>"));
}
#endif
@ -1166,7 +1180,7 @@ void IRrecv::printIRResultMinimal(Print *aSerial) {
* @param aOutputMicrosecondsInsteadOfTicks Output the (rawbuf_values * MICROS_PER_TICK) for better readability.
*/
void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks) {
// Print Raw data
// Print Raw data
aSerial->print(F("rawData["));
aSerial->print(decodedIRData.rawDataPtr->rawlen, DEC);
aSerial->println(F("]: "));
@ -1186,10 +1200,10 @@ void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsI
unsigned int i;
#endif
// Newline is printed every 8. value, if tCounterForNewline % 8 == 0
// Newline is printed every 8. value, if tCounterForNewline % 8 == 0
uint_fast8_t tCounterForNewline = 6; // first newline is after the 2 values of the start bit
// check if we have a protocol with no or 8 start bits
// check if we have a protocol with no or 8 start bits
#if defined(DECODE_DENON) || defined(DECODE_MAGIQUEST)
if (
#if defined(DECODE_DENON)
@ -1375,7 +1389,7 @@ void IRrecv::printIRResultAsCVariables(Print *aSerial) {
}
const __FlashStringHelper* IRrecv::getProtocolString() {
// call no class function with same name
// call no class function with same name
return ::getProtocolString(decodedIRData.protocol);
}
@ -1601,7 +1615,32 @@ ISR () // for functions definitions which are called by separate (board specific
}
/**********************************************************************************************************************
* The DEPRECATED decode function with parameter aResults ONLY for backwards compatibility!
* Function to bit reverse OLD MSB values of e.g. NEC.
**********************************************************************************************************************/
uint8_t bitreverseOneByte(uint8_t aValue) {
// uint8_t tReversedValue;
// return __builtin_avr_insert_bits(0x01234567, aValue, tReversedValue);
// 76543210
aValue = (aValue >> 4) | (aValue << 4); // Swap in groups of 4
// 32107654
aValue = ((aValue & 0xcc) >> 2) | ((aValue & 0x33) << 2); // Swap in groups of 2
// 10325476
aValue = ((aValue & 0xaa) >> 1) | ((aValue & 0x55) << 1); // Swap bit pairs
// 01234567
return aValue;
}
uint32_t bitreverse32Bit(uint32_t aInput) {
// __builtin_avr_insert_bits();
LongUnion tValue;
tValue.UByte.HighByte = bitreverseOneByte(aInput);
tValue.UByte.MidHighByte = bitreverseOneByte(aInput >> 8);
tValue.UByte.MidLowByte = bitreverseOneByte(aInput >> 16);
tValue.UByte.LowByte = bitreverseOneByte(aInput >> 24);
return tValue.ULong;
}
/**********************************************************************************************************************
* The OLD and DEPRECATED decode function with parameter aResults, kept for backward compatibility to old 2.0 tutorials
* This function calls the old MSB first decoders and fills only the 3 variables:
* aResults->value
* aResults->bits
@ -1622,7 +1661,7 @@ bool IRrecv::decode(decode_results *aResults) {
sDeprecationMessageSent = true;
}
// copy for usage by legacy programs
// copy for usage by legacy programs
aResults->rawbuf = irparams.rawbuf;
aResults->rawlen = irparams.rawlen;
if (irparams.OverflowFlag) {
@ -1650,11 +1689,6 @@ bool IRrecv::decode(decode_results *aResults) {
}
#endif
//#if defined(DECODE_MITSUBISHI)
// IR_DEBUG_PRINTLN(F("Attempting Mitsubishi decode"));
// if (decodeMitsubishi(results)) return true ;
//#endif
#if defined(DECODE_RC5)
IR_DEBUG_PRINTLN(F("Attempting RC5 decode"));
if (decodeRC5()) {
@ -1676,12 +1710,7 @@ bool IRrecv::decode(decode_results *aResults) {
}
#endif
#if defined( DECODE_PANASONIC)
IR_DEBUG_PRINTLN(F("Attempting old Panasonic decode"));
if (decodePanasonicMSB(aResults)) {
return true ;
}
#endif
// Removed bool IRrecv::decodePanasonicMSB(decode_results *aResults) since implementations was wrong (wrong length), and nobody recognized it
#if defined(DECODE_LG)
IR_DEBUG_PRINTLN(F("Attempting old LG decode"));
@ -1702,11 +1731,6 @@ bool IRrecv::decode(decode_results *aResults) {
}
#endif
//#if defined(DECODE_WHYNTER)
// IR_DEBUG_PRINTLN(F("Attempting Whynter decode"));
// if (decodeWhynter(results)) return true ;
//#endif
#if defined(DECODE_DENON)
IR_DEBUG_PRINTLN(F("Attempting old Denon decode"));
if (decodeDenonOld(aResults)) {
@ -1714,18 +1738,13 @@ bool IRrecv::decode(decode_results *aResults) {
}
#endif
//#if defined(DECODE_LEGO_PF)
// IR_DEBUG_PRINTLN(F("Attempting Lego Power Functions"));
// if (decodeLegoPowerFunctions(results)) return true ;
//#endif
// decodeHash returns a hash on any input.
// Thus, it needs to be last in the list.
// If you add any decodes, add them before this.
// decodeHash returns a hash on any input.
// Thus, it needs to be last in the list.
// If you add any decodes, add them before this.
if (decodeHashOld(aResults)) {
return true;
}
// Throw away and start over
// Throw away and start over
resume();
return false;
}

View File

@ -137,14 +137,17 @@ void IRsend::begin(uint_fast8_t aSendPin, bool aEnableLEDFeedback, uint_fast8_t
/**
* Interprets and sends a IRData structure.
* @param aIRSendData The values of protocol, address, command and repeat flag are taken for sending.
* @param aNumberOfRepeats Number of repeats to send after the initial data.
* @param aNumberOfRepeats Number of repeats to send after the initial data if data is no repeat.
*/
size_t IRsend::write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats) {
size_t IRsend::write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats) {
auto tProtocol = aIRSendData->protocol;
auto tAddress = aIRSendData->address;
auto tCommand = aIRSendData->command;
bool tIsRepeat = (aIRSendData->flags & IRDATA_FLAGS_IS_REPEAT);
if (tIsRepeat) {
aNumberOfRepeats = -1;
}
// switch (tProtocol) { // 26 bytes bigger than if, else if, else
// case NEC:
// sendNEC(tAddress, tCommand, aNumberOfRepeats, tSendRepeat);
@ -181,7 +184,7 @@ size_t IRsend::write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats) {
* Order of protocols is in guessed relevance :-)
*/
if (tProtocol == NEC) {
sendNEC(tAddress, tCommand, aNumberOfRepeats, tIsRepeat);
sendNEC(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == SAMSUNG) {
sendSamsung(tAddress, tCommand, aNumberOfRepeats);
@ -202,7 +205,7 @@ size_t IRsend::write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats) {
sendSharp(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == LG) {
sendLG(tAddress, tCommand, aNumberOfRepeats, tIsRepeat);
sendLG(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == JVC) {
sendJVC((uint8_t) tAddress, (uint8_t) tCommand, aNumberOfRepeats); // casts are required to specify the right function
@ -229,10 +232,10 @@ size_t IRsend::write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats) {
sendNEC2(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == ONKYO) {
sendOnkyo(tAddress, tCommand, aNumberOfRepeats, tIsRepeat);
sendOnkyo(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == APPLE) {
sendApple(tAddress, tCommand, aNumberOfRepeats, tIsRepeat);
sendApple(tAddress, tCommand, aNumberOfRepeats);
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS)
} else if (tProtocol == BOSEWAVE) {
@ -350,10 +353,10 @@ void IRsend::sendRaw_P(const uint8_t aBufferWithTicks[], uint_fast16_t aLengthOf
* The output always ends with a space
* Stop bit is always sent
*/
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros,
unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros, unsigned int aZeroSpaceMicros,
uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits, bool aMSBfirst, unsigned int aRepeatPeriodMillis,
uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros,
unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
unsigned int aZeroSpaceMicros, uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits, bool aMSBFirst,
bool aSendStopBit, unsigned int aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats) {
// Set IR carrier frequency
enableIROut(aFrequencyKHz);
@ -370,13 +373,24 @@ void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigne
for (uint_fast8_t i = 0; i < tNumberOf32BitChunks; ++i) {
uint8_t tNumberOfBitsForOneSend;
bool tSendStopBit;
if (aNumberOfBits > 32) {
tNumberOfBitsForOneSend = 32;
} else {
tNumberOfBitsForOneSend = aNumberOfBits;
}
if (i == (tNumberOf32BitChunks - 1)) {
// End of data
tNumberOfBitsForOneSend = aNumberOfBits;
tSendStopBit = aSendStopBit;
} else {
// intermediate data
tNumberOfBitsForOneSend = 32;
tSendStopBit = false;
}
sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aDecodedRawDataArray[i],
tNumberOfBitsForOneSend, aMSBfirst, (i == (tNumberOf32BitChunks - 1)));
tNumberOfBitsForOneSend, aMSBFirst, tSendStopBit);
aNumberOfBits -= 32;
}
@ -390,13 +404,111 @@ void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigne
IrReceiver.restartAfterSend();
}
/**
* Sends PulseDistance data from array
* For LSB First the LSB of array[0] is sent first then all bits until MSB of array[0]. Next is LSB of array[1] and so on.
* The output always ends with a space
* Stop bit is always sent
*/
void IRsend::sendPulseDistanceWidthFromArray(PulsePauseWidthProtocolConstants *aProtocolConstants, uint32_t *aDecodedRawDataArray,
unsigned int aNumberOfBits, int_fast8_t aNumberOfRepeats) {
// Set IR carrier frequency
enableIROut(aProtocolConstants->FrequencyKHz);
uint_fast8_t tNumberOf32BitChunks = ((aNumberOfBits - 1) / 32) + 1;
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
unsigned long tStartOfFrameMillis = millis();
// Header
mark(aProtocolConstants->HeaderMarkMicros);
space(aProtocolConstants->HeaderSpaceMicros);
bool tHasStopBit = aProtocolConstants->hasStopBit;
for (uint_fast8_t i = 0; i < tNumberOf32BitChunks; ++i) {
uint8_t tNumberOfBitsForOneSend;
if (i == (tNumberOf32BitChunks - 1)) {
// End of data
tNumberOfBitsForOneSend = aNumberOfBits;
aProtocolConstants->hasStopBit = tHasStopBit;
} else {
// intermediate data
tNumberOfBitsForOneSend = 32;
aProtocolConstants->hasStopBit = false;
}
sendPulseDistanceWidthData(aProtocolConstants, aDecodedRawDataArray[i], tNumberOfBitsForOneSend);
aNumberOfBits -= 32;
}
tNumberOfCommands--;
// skip last delay!
if (tNumberOfCommands > 0) {
delay(aProtocolConstants->RepeatPeriodMillis - (millis() - tStartOfFrameMillis));
}
}
IrReceiver.restartAfterSend();
}
/**
* Sends PulseDistance frames and repeats
* @param aNumberOfRepeats If < 0 then only a (special) repeat frame will be sent
*/
void IRsend::sendPulseDistanceWidth(PulsePauseWidthProtocolConstants *aProtocolConstants, uint32_t aData,
uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats) {
if (aNumberOfRepeats < 0) {
if (aProtocolConstants->SpecialSendRepeatFunction != NULL) {
aProtocolConstants->SpecialSendRepeatFunction();
return;
} else {
aNumberOfRepeats = 0; // send a plain frame as repeat
}
}
// Set IR carrier frequency
enableIROut(aProtocolConstants->FrequencyKHz);
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
unsigned long tStartOfFrameMillis = millis();
if (tNumberOfCommands < (aNumberOfRepeats + 1) && aProtocolConstants->SpecialSendRepeatFunction != NULL) {
// send special repeat
aProtocolConstants->SpecialSendRepeatFunction();
} else {
// Header and regular frame
mark(aProtocolConstants->HeaderMarkMicros);
space(aProtocolConstants->HeaderSpaceMicros);
sendPulseDistanceWidthData(aProtocolConstants, aData, aNumberOfBits);
}
tNumberOfCommands--;
// skip last delay!
if (tNumberOfCommands > 0) {
delay(aProtocolConstants->RepeatPeriodMillis - (millis() - tStartOfFrameMillis));
}
}
IrReceiver.restartAfterSend();
}
/**
* Sends PulseDistance frames and repeats
*/
void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros,
unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros, unsigned int aZeroSpaceMicros,
uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit, unsigned int aRepeatPeriodMillis,
uint_fast8_t aNumberOfRepeats) {
uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit, unsigned int aRepeatPeriodMillis,
int_fast8_t aNumberOfRepeats, void (*aSpecialSendRepeatFunction)()) {
if (aNumberOfRepeats < 0) {
if (aSpecialSendRepeatFunction != NULL) {
aSpecialSendRepeatFunction();
return;
} else {
aNumberOfRepeats = 0; // send a plain frame as repeat
}
}
// Set IR carrier frequency
enableIROut(aFrequencyKHz);
@ -405,12 +517,16 @@ void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, unsigned int aHe
while (tNumberOfCommands > 0) {
unsigned long tStartOfFrameMillis = millis();
// Header
mark(aHeaderMarkMicros);
space(aHeaderSpaceMicros);
sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aData, aNumberOfBits,
aMSBfirst, aSendStopBit);
if (tNumberOfCommands < (aNumberOfRepeats + 1) && aSpecialSendRepeatFunction != NULL) {
// send special repeat
aSpecialSendRepeatFunction();
} else {
// Header and regular frame
mark(aHeaderMarkMicros);
space(aHeaderSpaceMicros);
sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aData, aNumberOfBits,
aMSBFirst, aSendStopBit);
}
tNumberOfCommands--;
// skip last delay!
@ -421,37 +537,44 @@ void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, unsigned int aHe
IrReceiver.restartAfterSend();
}
/**
* Sends PulseDistance data
* The output always ends with a space
* Each additional call costs 16 bytes program space
*/
void IRsend::sendPulseDistanceWidthData(PulsePauseWidthProtocolConstants *aProtocolConstants, uint32_t aData,
uint_fast8_t aNumberOfBits) {
sendPulseDistanceWidthData(aProtocolConstants->OneMarkMicros, aProtocolConstants->OneSpaceMicros,
aProtocolConstants->ZeroMarkMicros, aProtocolConstants->ZeroSpaceMicros, aData, aNumberOfBits,
aProtocolConstants->isMSBFirst, aProtocolConstants->hasStopBit);
}
/**
* Sends PulseDistance data
* The output always ends with a space
*/
void IRsend::sendPulseDistanceWidthData(unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit) {
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit) {
if (aMSBfirst) { // Send the MSB first.
// send data from MSB to LSB until mask bit is shifted out
for (uint32_t tMask = 1UL << (aNumberOfBits - 1); tMask; tMask >>= 1) {
if (aData & tMask) {
IR_TRACE_PRINT('1');
mark(aOneMarkMicros);
space(aOneSpaceMicros);
} else {
IR_TRACE_PRINT('0');
mark(aZeroMarkMicros);
space(aZeroSpaceMicros);
}
// if (aMSBFirst) { // Send the MSB first.
// For MSBFirst, send data from MSB to LSB until mask bit is shifted out
uint32_t tMask = 1UL << (aNumberOfBits - 1);
for (uint_fast8_t i = aNumberOfBits; i > 0; i--) {
if ((aMSBFirst && (aData & tMask)) || (!aMSBFirst && (aData & 1))) {
IR_TRACE_PRINT('1');
mark(aOneMarkMicros);
space(aOneSpaceMicros);
} else {
IR_TRACE_PRINT('0');
mark(aZeroMarkMicros);
space(aZeroSpaceMicros);
}
if (aMSBFirst) {
tMask >>= 1;
} else {
aData >>= 1;
}
} else { // Send the Least Significant Bit (LSB) first / MSB last.
for (uint_fast8_t bit = 0; bit < aNumberOfBits; bit++, aData >>= 1)
if (aData & 1) { // Send a 1
IR_TRACE_PRINT('1');
mark(aOneMarkMicros);
space(aOneSpaceMicros);
} else { // Send a 0
IR_TRACE_PRINT('0');
mark(aZeroMarkMicros);
space(aZeroSpaceMicros);
}
}
if (aSendStopBit) {
IR_TRACE_PRINT('S');
@ -475,8 +598,8 @@ void IRsend::sendBiphaseData(unsigned int aBiphaseTimeUnit, uint32_t aData, uint
IR_TRACE_PRINT(F(" S"));
// Data - Biphase code MSB first
// prepare for start with sending the start bit, which is 1
// Data - Biphase code MSB first
// prepare for start with sending the start bit, which is 1
uint32_t tMask = 1UL << aNumberOfBits; // mask is now set for the virtual start bit
uint_fast8_t tLastBitValue = 1; // Start bit is a 1
bool tNextBitIsOne = 1; // Start bit is a 1
@ -696,7 +819,7 @@ void IRsend::customDelayMicroseconds(unsigned long aMicroseconds) {
#else
unsigned long start = micros();
#endif
// overflow invariant comparison :-)
// overflow invariant comparison :-)
while (micros() - start < aMicroseconds) {
}
}
@ -718,7 +841,7 @@ void IRsend::enableIROut(uint_fast8_t aFrequencyKHz) {
# if defined(IR_SEND_PIN)
periodOnTimeMicros = (((periodTimeMicros * IR_SEND_DUTY_CYCLE_PERCENT) + 50) / 100U); // +50 for rounding -> 830/100 for 30% and 16 MHz
# else
// Heuristics! We require a nanosecond correction for "slow" digitalWrite() functions
// Heuristics! We require a nanosecond correction for "slow" digitalWrite() functions
periodOnTimeMicros = (((periodTimeMicros * IR_SEND_DUTY_CYCLE_PERCENT) + 50 - (PULSE_CORRECTION_NANOS / 10)) / 100U); // +50 for rounding -> 530/100 for 30% and 16 MHz
# endif
#endif // defined(SEND_PWM_BY_TIMER)
@ -731,8 +854,8 @@ void IRsend::enableIROut(uint_fast8_t aFrequencyKHz) {
# endif
#else
// For Non AVR platforms pin mode for SEND_PWM_BY_TIMER must be handled by the timerConfigForSend() function
// because ESP 2.0.2 ledcWrite does not work if pin mode is set, and RP2040 requires gpio_set_function(IR_SEND_PIN, GPIO_FUNC_PWM);
// For Non AVR platforms pin mode for SEND_PWM_BY_TIMER must be handled by the timerConfigForSend() function
// because ESP 2.0.2 ledcWrite does not work if pin mode is set, and RP2040 requires gpio_set_function(IR_SEND_PIN, GPIO_FUNC_PWM);
# if defined(__AVR__) || !defined(SEND_PWM_BY_TIMER)
# if defined(IR_SEND_PIN)
pinModeFast(IR_SEND_PIN, OUTPUT);

View File

@ -65,10 +65,10 @@
#ifndef _IR_REMOTE_HPP
#define _IR_REMOTE_HPP
#define VERSION_IRREMOTE "3.9.0"
#define VERSION_IRREMOTE "3.9.1"
#define VERSION_IRREMOTE_MAJOR 3
#define VERSION_IRREMOTE_MINOR 9
#define VERSION_IRREMOTE_PATCH 0
#define VERSION_IRREMOTE_PATCH 1
/*
* Macro to convert 3 version parts into an integer
@ -213,7 +213,6 @@
* Define to disable carrier PWM generation in software and use (restricted) hardware PWM.
*/
//#define SEND_PWM_BY_TIMER // restricts send pin on many platforms to fixed pin numbers
#if (defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE)) || defined(ARDUINO_ARCH_MBED)
# if !defined(SEND_PWM_BY_TIMER)
#define SEND_PWM_BY_TIMER // the best and default method for ESP32 etc.
@ -297,6 +296,9 @@
# endif
#include "IRFeedbackLED.hpp"
# endif
#include "LongUnion.h" // used in most decoders
/*
* Include the sources here to enable compilation with macro values set by user program.
*/
@ -306,49 +308,23 @@
/*
* Include the sources of all decoders here to enable compilation with macro values set by user program.
*/
# if defined(DECODE_BOSEWAVE)
#include "ir_BoseWave.hpp"
# endif
# if defined(DECODE_DENON ) // Includes Sharp
#include "ir_Denon.hpp"
# endif
#include "ir_JVC.hpp"
#include "ir_Kaseikyo.hpp"
#include "ir_Lego.hpp"
#include "ir_LG.hpp"
#include "ir_MagiQuest.hpp"
#include "ir_NEC.hpp"
#include "ir_RC5_RC6.hpp"
#include "ir_Samsung.hpp"
#include "ir_Sony.hpp"
#include "ir_Others.hpp"
#include "ir_Pronto.hpp" // pronto is an universal decoder and encoder
# if defined(DECODE_DISTANCE) // universal decoder for pulse distance protocols - requires up to 750 bytes additional program memory
#include "ir_DistanceProtocol.hpp"
# endif
# if defined(DECODE_JVC)
#include "ir_JVC.hpp"
# endif
# if defined(DECODE_KASEIKYO) || defined(DECODE_PANASONIC)
#include "ir_Kaseikyo.hpp"
# endif
# if defined(DECODE_LEGO_PF)
#include "ir_Lego.hpp"
# endif
# if defined(DECODE_LG)
#include "ir_LG.hpp"
# endif
# if defined(DECODE_MAGIQUEST)
#include "ir_MagiQuest.hpp"
# endif
# if defined(DECODE_NEC) // Includes Apple and Onkyo
#include "ir_NEC.hpp"
# endif
# if defined(DECODE_RC5) || defined(DECODE_RC6)
#include "ir_RC5_RC6.hpp"
# endif
# if defined(DECODE_SAMSUNG)
#include "ir_Samsung.hpp"
# endif
# if defined(DECODE_SONY)
#include "ir_Sony.hpp"
# endif
# if defined(DECODE_WHYNTER)
#include "ir_Whynter.hpp"
# endif
#include "ir_Pronto.hpp" // pronto is an universal decoder and encoder
#include "ir_Dish.hpp" // contains only sendDISH(unsigned long data, int nbits)
#endif // #if !defined(USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE)
/**

View File

@ -150,8 +150,8 @@ struct IRData {
decode_type_t protocol; ///< UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
uint16_t address; ///< Decoded address, Distance protocol (OneMarkTicks << 8) | OneSpaceTicks
uint16_t command; ///< Decoded command, Distance protocol (ZeroMarkTicks << 8) | ZeroSpaceTicks
uint16_t extra; ///< Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMarkTicks << 8) | HeaderSpaceTicks.
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
uint16_t extra; ///< Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMarkTicks << 8) | HeaderSpaceTicks.
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
uint8_t flags; ///< See IRDATA_FLAGS_* definitions above
uint32_t decodedRawData; ///< Up to 32 bit decoded raw data, to be used for send functions.
#if defined(DECODE_DISTANCE)
@ -201,7 +201,7 @@ public:
bool available();
IRData* read(); // returns decoded data
// write is a method of class IRsend below
// size_t write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
// size_t write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void stop();
void disableIRIn(); // alias for stop
void end(); // alias for stop
@ -241,6 +241,9 @@ public:
/*
* The main decoding functions used by the individual decoders
*/
bool decodePulseDistanceData(PulsePauseWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits,
uint_fast8_t aStartOffset = 3);
bool decodePulseDistanceData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, unsigned int aBitMarkMicros,
unsigned int aOneSpaceMicros, unsigned int aZeroSpaceMicros, bool aMSBfirst);
@ -303,6 +306,8 @@ public:
*/
void initDecodedIRData();
uint_fast8_t compare(unsigned int oldval, unsigned int newval);
bool checkHeader(PulsePauseWidthProtocolConstants *aProtocolConstants);
bool checkHeader(unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros);
IRData decodedIRData; // New: decoded IR data for the application
@ -323,6 +328,12 @@ bool matchTicks(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros);
bool matchMark(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros);
bool matchSpace(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros);
/*
* Convenience functions to convert MSB to LSB values
*/
uint8_t bitreverseOneByte(uint8_t aValue);
uint32_t bitreverse32Bit(uint32_t aInput);
/*
* Old function names
*/
@ -423,23 +434,30 @@ public:
// Not guarded for backward compatibility
void begin(uint_fast8_t aSendPin, bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin = USE_DEFAULT_FEEDBACK_LED_PIN);
size_t write(IRData *aIRSendData, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
size_t write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void enableIROut(uint_fast8_t aFrequencyKHz);
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros,
unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros, unsigned int aZeroSpaceMicros,
uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits, bool aMSBfirst, unsigned int aRepeatPeriodMillis = 110,
uint_fast8_t aNumberOfRepeats = 0);
void sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit, unsigned int aRepeatPeriodMillis = 110,
uint_fast8_t aNumberOfRepeats = 0);
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros,
unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros,
unsigned int aZeroMarkMicros, unsigned int aZeroSpaceMicros, uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits,
bool aMSBfirst, bool aSendStopBit, unsigned int aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats);
void sendPulseDistanceWidthFromArray(PulsePauseWidthProtocolConstants *aProtocolConstants, uint32_t *aDecodedRawDataArray,
unsigned int aNumberOfBits, int_fast8_t aNumberOfRepeats);
void sendPulseDistanceWidth(PulsePauseWidthProtocolConstants *aProtocolConstants, uint32_t aData, uint_fast8_t aNumberOfBits,
int_fast8_t aNumberOfRepeats);
void sendPulseDistanceWidthData(PulsePauseWidthProtocolConstants *aProtocolConstants, uint32_t aData,
uint_fast8_t aNumberOfBits);
void sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, unsigned int aHeaderSpaceMicros,
unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros, unsigned int aZeroSpaceMicros,
uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit, unsigned int aRepeatPeriodMillis,
int_fast8_t aNumberOfRepeats, void (*aSpecialSendRepeatFunction)() = NULL);
void sendPulseDistanceWidthData(unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit = false);
unsigned int aZeroSpaceMicros, uint32_t aData, uint_fast8_t aNumberOfBits, bool aMSBfirst, bool aSendStopBit);
void sendBiphaseData(unsigned int aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits);
void mark(unsigned int aMarkMicros);
void space(unsigned int aSpaceMicros);
static void space(unsigned int aSpaceMicros);
void IRLedOff();
// 8 Bit array
@ -453,42 +471,44 @@ public:
/*
* New send functions
*/
void sendBoseWave(uint8_t aCommand, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendDenon(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendSharp = false);
void sendDenonRaw(uint16_t aRawData, uint_fast8_t aNumberOfRepeats = 0)
void sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendDenon(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aSendSharp = false);
void sendDenonRaw(uint16_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS)
#if !defined (DOXYGEN)
__attribute__ ((deprecated ("Please use sendDenon(aAddress, aCommand, aNumberOfRepeats).")));
#endif
void sendJVC(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats);
void sendJVC(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
void sendLGRepeat(bool aUseLG2Protocol = false);
void sendLG(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat = false, bool aUseLG2Protocol =
false);
void sendLG2(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat = false);
void sendLGRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats = 0, bool aSendOnlySpecialLGRepeat = false, bool aUseLG2Protocol = false);
void sendLGRepeat();
void sendLG2Repeat();
uint32_t computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand);
void sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendLG2(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendLGRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendNECRepeat();
void sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat = false);
void sendNEC2(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats);
void sendNECRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats = 0, bool aSendOnlySpecialNECRepeat = false);
uint32_t computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand);
void sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
void sendNEC2(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
void sendNECRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
// NEC variants
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat = false);
void sendApple(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat = false);
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendApple(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
void sendKaseikyo(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats, uint16_t aVendorCode); // LSB first
void sendPanasonic(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_Denon(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_Mitsubishi(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_Sharp(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_JVC(uint16_t aAddress, uint8_t aData, uint_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats, uint16_t aVendorCode); // LSB first
void sendPanasonic(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_Denon(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_Mitsubishi(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_Sharp(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
void sendKaseikyo_JVC(uint16_t aAddress, uint8_t aData, int_fast8_t aNumberOfRepeats); // LSB first
void sendRC5(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
void sendRC6(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
void sendRC5(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
void sendRC6(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
void sendSamsungLGRepeat();
void sendSamsung(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats);
void sendSamsungLG(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialSamsungRepeat = false);
void sendSharp(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats); // redirected to sendDenon
void sendSony(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, uint8_t numberOfBits = SIRCS_12_PROTOCOL);
void sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendSamsungLG(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendSharp(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats); // redirected to sendDenon
void sendSony(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, uint8_t numberOfBits = 12); // SIRCS_12_PROTOCOL
void sendLegoPowerFunctions(uint8_t aChannel, uint8_t tCommand, uint8_t aMode, bool aDoSend5Times = true);
void sendLegoPowerFunctions(uint16_t aRawData, bool aDoSend5Times = true);
@ -496,23 +516,23 @@ public:
void sendMagiQuest(uint32_t wand_id, uint16_t magnitude);
void sendPronto(const __FlashStringHelper *str, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto(const char *prontoHexString, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto(const uint16_t *data, unsigned int length, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto(const __FlashStringHelper *str, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto(const char *prontoHexString, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto(const uint16_t *data, unsigned int length, int_fast8_t aNumberOfRepeats = NO_REPEATS);
#if defined(__AVR__)
void sendPronto_PF(uint_farptr_t str, uint_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto_P(const char *str, uint_fast8_t aNumberOfRepeats);
void sendPronto_PF(uint_farptr_t str, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void sendPronto_P(const char *str, int_fast8_t aNumberOfRepeats);
#endif
// Template protocol :-)
void sendShuzu(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats);
void sendShuzu(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats);
/*
* OLD send functions
*/
void sendDenon(unsigned long data, int nbits);
void sendDISH(unsigned long data, int nbits);
void sendDish(uint16_t aData);
void sendJVC(unsigned long data, int nbits,
bool repeat)
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendJVC(aAddress, aCommand, aNumberOfRepeats)."))) {
@ -528,9 +548,6 @@ public:
sendNECMSB(aRawData, nbits);
}
void sendNECMSB(uint32_t data, uint8_t nbits, bool repeat = false);
void sendPanasonic(uint16_t aAddress,
uint32_t aData)
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendPanasonic(aAddress, aCommand, aNumberOfRepeats).")));
void sendRC5(uint32_t data, uint8_t nbits);
void sendRC5ext(uint8_t addr, uint8_t cmd, bool toggle);
void sendRC6(uint32_t data, uint8_t nbits);
@ -543,7 +560,7 @@ public:
int nbits)
__attribute__ ((deprecated ("This old function sends MSB first! Please use sendSony(aAddress, aCommand, aNumberOfRepeats).")));
;
void sendWhynter(unsigned long data, int nbits);
void sendWhynter(uint32_t aData, uint8_t aNumberOfBitsToSend);
#if !defined(IR_SEND_PIN)
uint8_t sendPin;
@ -552,7 +569,7 @@ public:
unsigned int periodOnTimeMicros; // compensated with PULSE_CORRECTION_NANOS for duration of digitalWrite. Around 8 microseconds for 38 kHz.
unsigned int getPulseCorrectionNanos();
void customDelayMicroseconds(unsigned long aMicroseconds);
static void customDelayMicroseconds(unsigned long aMicroseconds);
};
/*
@ -560,4 +577,8 @@ public:
*/
extern IRsend IrSender;
void sendNECSpecialRepeat();
void sendLG2SpecialRepeat();
void sendSamsungLGSpecialRepeat();
#endif // _IR_REMOTE_INT_H

View File

@ -258,7 +258,7 @@ void Aircondition_LG::sendIRCommand(uint16_t aCommand) {
Serial.println(aCommand, BIN);
#endif
IrSender.sendLG((uint8_t) LG_ADDRESS, aCommand, 0, false, useLG2Protocol);
IrSender.sendLG2((uint8_t) LG_ADDRESS, aCommand, 0);
}
/*

View File

@ -9,11 +9,6 @@
#ifndef _IR_BOSEWAVE_HPP
#define _IR_BOSEWAVE_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -44,23 +39,24 @@
#define BOSEWAVE_REPEAT_PERIOD 75000
#define BOSEWAVE_REPEAT_SPACE 50000
//+=============================================================================
struct PulsePauseWidthProtocolConstants BoseWaveProtocolConstants = { BOSEWAVE, BOSEWAVE_KHZ, BOSEWAVE_HEADER_MARK,
BOSEWAVE_HEADER_SPACE, BOSEWAVE_BIT_MARK, BOSEWAVE_ONE_SPACE, BOSEWAVE_BIT_MARK, BOSEWAVE_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST,
SEND_STOP_BIT, (BOSEWAVE_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
void IRsend::sendBoseWave(uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
/************************************
* Start of send and decode functions
************************************/
void IRsend::sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
// send 8 command bits and then 8 inverted command bits LSB first
uint16_t tData = ((~aCommand) << 8) | aCommand;
sendPulseDistanceWidth(BOSEWAVE_KHZ, BOSEWAVE_HEADER_MARK, BOSEWAVE_HEADER_SPACE, BOSEWAVE_BIT_MARK, BOSEWAVE_ONE_SPACE,
BOSEWAVE_BIT_MARK, BOSEWAVE_ZERO_SPACE, tData, BOSEWAVE_BITS, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT,
BOSEWAVE_REPEAT_PERIOD / MICROS_IN_ONE_MILLI, aNumberOfRepeats);
sendPulseDistanceWidth(&BoseWaveProtocolConstants, tData, BOSEWAVE_BITS, aNumberOfRepeats);
}
//+=============================================================================
bool IRrecv::decodeBoseWave() {
// Check header "mark"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], BOSEWAVE_HEADER_MARK)) {
// no debug output, since this check is mainly to determine the received protocol
if (!checkHeader(&BoseWaveProtocolConstants)) {
return false;
}
@ -72,15 +68,8 @@ bool IRrecv::decodeBoseWave() {
IR_DEBUG_PRINTLN(F(" is not 36"));
return false;
}
// Check header "space"
if (!matchSpace(decodedIRData.rawDataPtr->rawbuf[2], BOSEWAVE_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("Bose: "));
IR_DEBUG_PRINTLN(F("Header space length is wrong"));
return false;
}
if (!decodePulseDistanceData(BOSEWAVE_BITS, 3, BOSEWAVE_BIT_MARK, BOSEWAVE_ONE_SPACE, BOSEWAVE_ZERO_SPACE,
PROTOCOL_IS_LSB_FIRST)) {
if (!decodePulseDistanceData(&BoseWaveProtocolConstants, BOSEWAVE_BITS)) {
IR_DEBUG_PRINT(F("Bose: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2021 Armin Joachimsmeyer
* Copyright (c) 2020-2022 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,11 +32,6 @@
#ifndef _IR_DENON_HPP
#define _IR_DENON_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -80,20 +75,19 @@
#define DENON_HEADER_MARK DENON_UNIT // The length of the Header:Mark
#define DENON_HEADER_SPACE (3 * DENON_UNIT) // 780 // The length of the Header:Space
//+=============================================================================
void IRsend::sendSharp(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
struct PulsePauseWidthProtocolConstants DenonProtocolConstants = { DENON, DENON_KHZ, DENON_HEADER_MARK, DENON_HEADER_SPACE,
DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, (DENON_REPEAT_PERIOD
/ MICROS_IN_ONE_MILLI), NULL };
/************************************
* Start of send and decode functions
************************************/
void IRsend::sendSharp(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendDenon(aAddress, aCommand, aNumberOfRepeats, true);
}
/*
* Only for backwards compatibility
*/
void IRsend::sendDenonRaw(uint16_t aRawData, uint_fast8_t aNumberOfRepeats) {
sendDenon(aRawData >> (DENON_COMMAND_BITS + DENON_FRAME_BITS), (aRawData >> DENON_FRAME_BITS) & 0xFF, aNumberOfRepeats);
}
//+=============================================================================
void IRsend::sendDenon(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendSharp) {
void IRsend::sendDenon(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aSendSharp) {
// Set IR carrier frequency
enableIROut(DENON_KHZ); // 38 kHz
@ -109,13 +103,11 @@ void IRsend::sendDenon(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberO
while (tNumberOfCommands > 0) {
// Data
sendPulseDistanceWidthData(DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, tData, DENON_BITS,
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
sendPulseDistanceWidthData(&DenonProtocolConstants, tData, DENON_BITS);
// Inverted autorepeat frame
delay(DENON_AUTO_REPEAT_SPACE / MICROS_IN_ONE_MILLI);
sendPulseDistanceWidthData(DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, tInvertedData, DENON_BITS,
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
sendPulseDistanceWidthData(&DenonProtocolConstants, tInvertedData, DENON_BITS);
tNumberOfCommands--;
// skip last delay!
@ -127,12 +119,10 @@ void IRsend::sendDenon(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberO
IrReceiver.restartAfterSend();
}
//+=============================================================================
bool IRrecv::decodeSharp() {
return decodeDenon();
}
//+=============================================================================
bool IRrecv::decodeDenon() {
// we have no start bit, so check for the exact amount of data bits
@ -146,7 +136,7 @@ bool IRrecv::decodeDenon() {
}
// Read the bits in
if (!decodePulseDistanceData(DENON_BITS, 1, DENON_BIT_MARK, DENON_ONE_SPACE, DENON_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST)) {
if (!decodePulseDistanceData(&DenonProtocolConstants, DENON_BITS, 1)) {
IR_DEBUG_PRINT(F("Denon: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
@ -200,6 +190,44 @@ bool IRrecv::decodeDenon() {
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
/*
* Only for backwards compatibility
*/
void IRsend::sendDenonRaw(uint16_t aRawData, int_fast8_t aNumberOfRepeats) {
sendDenon(aRawData >> (DENON_COMMAND_BITS + DENON_FRAME_BITS), (aRawData >> DENON_FRAME_BITS) & 0xFF, aNumberOfRepeats);
}
/*
* Old function with parameter data
*/
void IRsend::sendDenon(unsigned long data, int nbits) {
// Set IR carrier frequency
enableIROut(DENON_KHZ);
#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
Serial.println(
"The function sendDenon(data, nbits) is deprecated and may not work as expected! Use sendDenonRaw(data, NumberOfRepeats) or better sendDenon(Address, Command, NumberOfRepeats).");
#endif
// Header
mark(DENON_HEADER_MARK);
space(DENON_HEADER_SPACE);
// Data
sendPulseDistanceWidthData(DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, data, nbits,
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
IrReceiver.restartAfterSend();
}
/*
* Old function without parameter aNumberOfRepeats
*/
void IRsend::sendSharp(unsigned int aAddress, unsigned int aCommand) {
sendDenon(aAddress, aCommand, true, 0);
}
bool IRrecv::decodeDenonOld(decode_results *aResults) {
// Check we have the right amount of data
@ -229,27 +257,5 @@ bool IRrecv::decodeDenonOld(decode_results *aResults) {
return true;
}
void IRsend::sendDenon(unsigned long data, int nbits) {
// Set IR carrier frequency
enableIROut(DENON_KHZ);
#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
Serial.println(
"The function sendDenon(data, nbits) is deprecated and may not work as expected! Use sendDenonRaw(data, NumberOfRepeats) or better sendDenon(Address, Command, NumberOfRepeats).");
#endif
// Header
mark(DENON_HEADER_MARK);
space(DENON_HEADER_SPACE);
// Data
sendPulseDistanceWidthData(DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, data, nbits,
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
IrReceiver.restartAfterSend();
}
void IRsend::sendSharp(unsigned int aAddress, unsigned int aCommand) {
sendDenon(aAddress, aCommand, true, 0);
}
/** @}*/
#endif // _IR_DENON_HPP

View File

@ -1,46 +0,0 @@
#include "IRremoteInt.h"
//==============================================================================
// DDDD IIIII SSSS H H
// D D I S H H
// D D I SSS HHHHH
// D D I S H H
// DDDD IIIII SSSS H H
//==============================================================================
// Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand )
//
// The send function needs to be repeated 4 times
//
// Only send the last for characters of the hex.
// I.E. Use 0x1C10 instead of 0x0000000000001C10 as listed in the LIRC file.
//
// Here is the LIRC file I found that seems to match the remote codes from the
// oscilloscope:
// DISH NETWORK (echostar 301):
// http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
#ifndef _IR_DISH_HPP
#define _IR_DISH_HPP
#define DISH_BITS 16
#define DISH_HEADER_MARK 400
#define DISH_HEADER_SPACE 6100
#define DISH_BIT_MARK 400
#define DISH_ONE_SPACE 1700
#define DISH_ZERO_SPACE 2800
#define DISH_REPEAT_SPACE 6200
//+=============================================================================
void IRsend::sendDISH(unsigned long data, int nbits) {
// Set IR carrier frequency
enableIROut(56);
mark(DISH_HEADER_MARK);
space(DISH_HEADER_SPACE);
sendPulseDistanceWidthData(DISH_BIT_MARK, DISH_ONE_SPACE, DISH_BIT_MARK, DISH_ZERO_SPACE, data, nbits, PROTOCOL_IS_MSB_FIRST, SEND_NO_STOP_BIT);
mark(DISH_HEADER_MARK); //added 26th March 2016, by AnalysIR ( https://www.AnalysIR.com )
IrReceiver.restartAfterSend();
}
#endif // _IR_DISH_HPP

View File

@ -1,10 +1,13 @@
/*
* ir_DistanceProtocol.hpp
*
* Contains only the decoder functions!
*
* This decoder tries to decode a pulse width or pulse distance protocol.
* 1. Analyze all space and mark length
* 2. Decide if we have an pulse width or distance protocol
* 3. Try to decode with the mark and space data found in step 1
* 4. Assume one start bit / header and one stop bit, since pulse distance data must have a stop bit!
* No data and address decoding, only raw data as result.
*
* Pulse distance data can be sent with the generic function:
@ -42,7 +45,6 @@
#ifndef _IR_DISTANCE_HPP
#define _IR_DISTANCE_HPP
#include <Arduino.h>
// accept durations up to 50 * 50 (MICROS_PER_TICK) 2500 microseconds
#define DURATION_ARRAY_SIZE 50
@ -50,16 +52,18 @@
// Switch the decoding according to your needs
//#define DISTANCE_DO_MSB_DECODING // If active, it resembles the JVC + Denon, otherwise LSB first as e.g. for NEC and Kaseikyo/Panasonic
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
//#include "LongUnion.h"
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
#define LOCAL_DEBUG
#else
//#define LOCAL_DEBUG // This enables debug output only for this file
#endif
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
// see: https://www.mikrocontroller.net/articles/IRMP_-_english#Codings
#if defined(DEBUG)
#if defined(LOCAL_DEBUG)
void printDurations(uint8_t aArray[], uint8_t aMaxIndex) {
for (uint_fast8_t i = 0; i <= aMaxIndex; i++) {
if (i % 10 == 0) {
@ -159,7 +163,7 @@ bool IRrecv::decodeDistance() {
uint8_t tMarkTicksShort = 0;
uint8_t tMarkTicksLong = 0;
bool tSuccess = aggregateArrayCounts(tDurationArray, tMaxDurationIndex, &tMarkTicksShort, &tMarkTicksLong);
#if defined(DEBUG)
#if defined(LOCAL_DEBUG)
Serial.println(F("Mark:"));
printDurations(tDurationArray, tMaxDurationIndex);
#endif
@ -192,7 +196,7 @@ bool IRrecv::decodeDistance() {
uint8_t tSpaceTicksShort = 0;
uint8_t tSpaceTicksLong = 0;
tSuccess = aggregateArrayCounts(tDurationArray, tMaxDurationIndex, &tSpaceTicksShort, &tSpaceTicksLong);
#if defined(DEBUG)
#if defined(LOCAL_DEBUG)
Serial.println(F("Space:"));
printDurations(tDurationArray, tMaxDurationIndex);
#endif
@ -203,7 +207,7 @@ bool IRrecv::decodeDistance() {
return false;
}
// skip leading start and trailing stop bit.
// skip leading start bit and trailing stop bit for decoding.
uint16_t tNumberOfBits = (decodedIRData.rawDataPtr->rawlen / 2) - 2;
// Store data to reproduce frame for sending
decodedIRData.numberOfBits = tNumberOfBits;
@ -222,21 +226,22 @@ bool IRrecv::decodeDistance() {
* Kaseikyo: 48. 69, 35, 9, 0, 9, 26
* Sony: 12|15|20, 48, 12, 12, 24, 12, 0 // the only known pulse width protocol
*/
IR_DEBUG_PRINT(F("Protocol characteristics for a " STR(MICROS_PER_TICK) " us tick: "));
IR_DEBUG_PRINT(decodedIRData.numberOfBits);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawbuf[1]);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawbuf[2]);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINT(tMarkTicksShort);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINT(tMarkTicksLong);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINT(tSpaceTicksShort);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINTLN(tSpaceTicksLong);
#if defined(LOCAL_DEBUG)
Serial.print(F("Protocol constants for a " STR(MICROS_PER_TICK) " us tick: "));
Serial.print(decodedIRData.numberOfBits);
Serial.print(F(" bits, "));
Serial.print(decodedIRData.rawDataPtr->rawbuf[1]);
Serial.print(F(", "));
Serial.print(decodedIRData.rawDataPtr->rawbuf[2]);
Serial.print(F(", "));
Serial.print(tMarkTicksLong);
Serial.print(F(", "));
Serial.println(tSpaceTicksLong);
Serial.print(F(", "));
Serial.print(tMarkTicksShort);
Serial.print(F(", "));
Serial.print(tSpaceTicksShort);
#endif
uint8_t tStartIndex = 3;
uint8_t tNumberOfAdditionalLong = (tNumberOfBits - 1) / 32;

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2017-2021 Kristian Lauszus, Armin Joachimsmeyer
* Copyright (c) 2017-2022 Kristian Lauszus, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,11 +32,6 @@
#ifndef _IR_JVC_HPP
#define _IR_JVC_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -68,28 +63,33 @@
#define JVC_REPEAT_SPACE (uint16_t)(45 * JVC_UNIT) // 23625 - Commands are repeated with a distance of 23 ms for as long as the key on the remote control is held down.
#define JVC_REPEAT_PERIOD 65000 // assume around 40 ms for a JVC frame
struct ProtocolConstants JVCProtocolConstants = { JVC, JVC_KHZ, JVC_HEADER_MARK, JVC_HEADER_SPACE, JVC_BIT_MARK, JVC_ONE_SPACE,
JVC_BIT_MARK, JVC_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (JVC_REPEAT_PERIOD / MICROS_IN_ONE_MILLI) };
struct PulsePauseWidthProtocolConstants JVCProtocolConstants = { JVC, JVC_KHZ, JVC_HEADER_MARK, JVC_HEADER_SPACE, JVC_BIT_MARK,
JVC_ONE_SPACE, JVC_BIT_MARK, JVC_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (JVC_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
//+=============================================================================
// JVC does NOT repeat by sending a separate code (like NEC does).
// The JVC protocol repeats by skipping the header.
//
/************************************
* Start of send and decode functions
************************************/
void IRsend::sendJVC(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
/**
* The JVC protocol repeats by skipping the header mark and space -> this leads to a poor repeat detection for JVC protocol.
*/
void IRsend::sendJVC(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
// Set IR carrier frequency
enableIROut(JVC_KHZ); // 38 kHz
// The JVC protocol repeats by skipping the header.
mark(JVC_HEADER_MARK);
space(JVC_HEADER_SPACE);
if (aNumberOfRepeats < 0) {
// The JVC protocol repeats by skipping the header.
aNumberOfRepeats = 0;
} else {
mark(JVC_HEADER_MARK);
space(JVC_HEADER_SPACE);
}
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
// Address + command
sendPulseDistanceWidthData(JVC_BIT_MARK, JVC_ONE_SPACE, JVC_BIT_MARK, JVC_ZERO_SPACE,
aAddress | (aCommand << JVC_ADDRESS_BITS), JVC_BITS, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT);
sendPulseDistanceWidthData(&JVCProtocolConstants, aAddress | (aCommand << JVC_ADDRESS_BITS), JVC_BITS);
tNumberOfCommands--;
// skip last delay!
@ -101,14 +101,11 @@ void IRsend::sendJVC(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfR
IrReceiver.restartAfterSend();
}
/*
* First check for right data length
* Next check start bit
* Next try the decode
*/
bool IRrecv::decodeJVC() {
// Check we have the right amount of data (36 or 34). The +4 is for initial gap, start bit mark and space + stop bit mark. +2 is for repeats
// uint_fast8_t tRawlen = decodedIRData.rawDataPtr->rawlen; // does not improve code size
// Check we have the right amount of data (36 or 34). The +4 is for initial gap, start bit mark and space + stop bit mark. +4 is for first frame, +2 is for repeats
if (decodedIRData.rawDataPtr->rawlen != ((2 * JVC_BITS) + 4) && decodedIRData.rawDataPtr->rawlen != ((2 * JVC_BITS) + 2)) {
IR_DEBUG_PRINT(F("JVC: "));
IR_DEBUG_PRINT(F("Data length="));
@ -135,15 +132,11 @@ bool IRrecv::decodeJVC() {
}
} else {
// Check header "mark" and "space"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], JVC_HEADER_MARK)
|| !matchSpace(decodedIRData.rawDataPtr->rawbuf[2], JVC_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("JVC: "));
IR_DEBUG_PRINTLN(F("Header mark or space length is wrong"));
if (!checkHeader(&JVCProtocolConstants)) {
return false;
}
if (!decodePulseDistanceData(JVC_BITS, 3, JVC_BIT_MARK, JVC_ONE_SPACE, JVC_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST)) {
if (!decodePulseDistanceData(&JVCProtocolConstants, JVC_BITS)) {
IR_DEBUG_PRINT(F("JVC: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
@ -151,11 +144,8 @@ bool IRrecv::decodeJVC() {
// Success
// decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
uint8_t tCommand = decodedIRData.decodedRawData >> JVC_ADDRESS_BITS; // upper 8 bits of LSB first value
uint8_t tAddress = decodedIRData.decodedRawData & 0xFF; // lowest 8 bit of LSB first value
decodedIRData.command = tCommand;
decodedIRData.address = tAddress;
decodedIRData.command = decodedIRData.decodedRawData >> JVC_ADDRESS_BITS; // upper 8 bits of LSB first value
decodedIRData.address = decodedIRData.decodedRawData & 0xFF; // lowest 8 bit of LSB first value
decodedIRData.numberOfBits = JVC_BITS;
decodedIRData.protocol = JVC;
}
@ -163,6 +153,9 @@ bool IRrecv::decodeJVC() {
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
bool IRrecv::decodeJVCMSB(decode_results *aResults) {
unsigned int offset = 1; // Skip first space

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2021 Armin Joachimsmeyer
* Copyright (c) 2020-2022 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,12 +32,6 @@
#ifndef _IR_KASEIKYO_HPP
#define _IR_KASEIKYO_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
#include "LongUnion.h"
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -86,86 +80,77 @@
#define KASEIKYO_REPEAT_PERIOD 130000
#define KASEIKYO_REPEAT_SPACE (KASEIKYO_REPEAT_PERIOD - KASEIKYO_AVERAGE_DURATION) // 74 ms
// for old decoder
#define KASEIKYO_DATA_BITS 32
#define PANASONIC_VENDOR_ID_CODE 0x2002
#define DENON_VENDOR_ID_CODE 0x3254
#define MITSUBISHI_VENDOR_ID_CODE 0xCB23
#define SHARP_VENDOR_ID_CODE 0x5AAA
#define JVC_VENDOR_ID_CODE 0x0103
//+=============================================================================
/*
* Send with LSB first
* Address is sub-device << 8 + device
struct PulsePauseWidthProtocolConstants KaseikyoProtocolConstants = { KASEIKYO, KASEIKYO_KHZ, KASEIKYO_HEADER_MARK,
KASEIKYO_HEADER_SPACE, KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE, KASEIKYO_BIT_MARK, KASEIKYO_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST,
SEND_STOP_BIT, (KASEIKYO_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
/************************************
* Start of send and decode functions
************************************/
/**
* Address can be interpreted as sub-device << 8 + device
*/
void IRsend::sendKaseikyo(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, uint16_t aVendorCode) {
void IRsend::sendKaseikyo(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, uint16_t aVendorCode) {
// Set IR carrier frequency
enableIROut(KASEIKYO_KHZ); // 37 kHz
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
// Vendor Parity
uint8_t tVendorParity = aVendorCode ^ (aVendorCode >> 8);
tVendorParity = (tVendorParity ^ (tVendorParity >> 4)) & 0xF;
// Header
mark(KASEIKYO_HEADER_MARK);
space(KASEIKYO_HEADER_SPACE);
LongUnion tSendValue;
// Vendor ID
sendPulseDistanceWidthData(KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE, KASEIKYO_BIT_MARK, KASEIKYO_ZERO_SPACE, aVendorCode,
KASEIKYO_VENDOR_ID_BITS, PROTOCOL_IS_LSB_FIRST, SEND_NO_STOP_BIT);
// Compute parity
tSendValue.UWord.LowWord = aAddress << KASEIKYO_VENDOR_ID_PARITY_BITS;
tSendValue.UByte.LowByte |= tVendorParity; // set low nibble to parity
tSendValue.UByte.MidHighByte = aCommand;
tSendValue.UByte.HighByte = aCommand ^ tSendValue.UByte.LowByte ^ tSendValue.UByte.MidLowByte; // Parity
// Vendor Parity
uint8_t tVendorParity = aVendorCode ^ (aVendorCode >> 8);
tVendorParity = (tVendorParity ^ (tVendorParity >> 4)) & 0xF;
LongUnion tSendValue;
tSendValue.UWord.LowWord = aAddress << KASEIKYO_VENDOR_ID_PARITY_BITS;
tSendValue.UByte.LowByte |= tVendorParity; // set low nibble to parity
tSendValue.UByte.MidHighByte = aCommand;
tSendValue.UByte.HighByte = aCommand ^ tSendValue.UByte.LowByte ^ tSendValue.UByte.MidLowByte; // Parity
// Send address (device and subdevice) + command + parity + Stop bit
sendPulseDistanceWidthData(KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE, KASEIKYO_BIT_MARK, KASEIKYO_ZERO_SPACE, tSendValue.ULong,
KASEIKYO_ADDRESS_BITS + KASEIKYO_VENDOR_ID_PARITY_BITS + KASEIKYO_COMMAND_BITS + KASEIKYO_PARITY_BITS,
PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT);
tNumberOfCommands--;
// skip last delay!
if (tNumberOfCommands > 0) {
// send repeated command in a fixed raster
delay(KASEIKYO_REPEAT_SPACE / MICROS_IN_ONE_MILLI);
}
}
IrReceiver.restartAfterSend();
uint32_t tRawKaseikyoData[2];
tRawKaseikyoData[0] = (uint32_t) tSendValue.UWord.LowWord << 16 | aVendorCode; // LSB of tRawKaseikyoData[0] is sent first
tRawKaseikyoData[1] = tSendValue.UWord.HighWord;
IrSender.sendPulseDistanceWidthFromArray(&KaseikyoProtocolConstants, &tRawKaseikyoData[0], KASEIKYO_BITS, aNumberOfRepeats);
}
/**
* Stub using Kaseikyo with PANASONIC_VENDOR_ID_CODE
*/
void IRsend::sendPanasonic(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPanasonic(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendKaseikyo(aAddress, aCommand, aNumberOfRepeats, PANASONIC_VENDOR_ID_CODE);
}
/**
* Stub using Kaseikyo with DENON_VENDOR_ID_CODE
*/
void IRsend::sendKaseikyo_Denon(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendKaseikyo_Denon(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendKaseikyo(aAddress, aCommand, aNumberOfRepeats, DENON_VENDOR_ID_CODE);
}
/**
* Stub using Kaseikyo with MITSUBISHI_VENDOR_ID_CODE
*/
void IRsend::sendKaseikyo_Mitsubishi(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendKaseikyo_Mitsubishi(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendKaseikyo(aAddress, aCommand, aNumberOfRepeats, MITSUBISHI_VENDOR_ID_CODE);
}
/**
* Stub using Kaseikyo with SHARP_VENDOR_ID_CODE
*/
void IRsend::sendKaseikyo_Sharp(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendKaseikyo_Sharp(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendKaseikyo(aAddress, aCommand, aNumberOfRepeats, SHARP_VENDOR_ID_CODE);
}
/**
* Stub using Kaseikyo with JVC_VENDOR_ID_CODE
*/
void IRsend::sendKaseikyo_JVC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendKaseikyo_JVC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendKaseikyo(aAddress, aCommand, aNumberOfRepeats, JVC_VENDOR_ID_CODE);
}
@ -184,21 +169,12 @@ bool IRrecv::decodeKaseikyo() {
return false;
}
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], KASEIKYO_HEADER_MARK)) {
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINTLN(F("Header mark length is wrong"));
return false;
}
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[2], KASEIKYO_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINTLN(F("Header space length is wrong"));
if (!checkHeader(&KaseikyoProtocolConstants)) {
return false;
}
// decode first 16 Vendor ID bits
if (!decodePulseDistanceData(KASEIKYO_VENDOR_ID_BITS, 3, KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE, KASEIKYO_ZERO_SPACE,
PROTOCOL_IS_LSB_FIRST)) {
if (!decodePulseDistanceData(&KaseikyoProtocolConstants, KASEIKYO_VENDOR_ID_BITS)) {
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINTLN(F("Vendor ID decode failed"));
return false;
@ -224,10 +200,9 @@ bool IRrecv::decodeKaseikyo() {
tVendorParity = (tVendorParity ^ (tVendorParity >> 4)) & 0xF;
// decode next 32 bits, 8 VendorID parity parity + 12 address (device and subdevice) + 8 command + 8 parity
if (!decodePulseDistanceData(
if (!decodePulseDistanceData(&KaseikyoProtocolConstants,
KASEIKYO_VENDOR_ID_PARITY_BITS + KASEIKYO_ADDRESS_BITS + KASEIKYO_COMMAND_BITS + KASEIKYO_PARITY_BITS,
3 + (2 * KASEIKYO_VENDOR_ID_BITS), KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE,
KASEIKYO_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST)) {
3 + (2 * KASEIKYO_VENDOR_ID_BITS))) {
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINTLN(F("VendorID parity, address, command + parity decode failed"));
return false;
@ -242,6 +217,8 @@ bool IRrecv::decodeKaseikyo() {
uint8_t tParity = tValue.UByte.LowByte ^ tValue.UByte.MidLowByte ^ tValue.UByte.MidHighByte;
if (tVendorParity != (tValue.UByte.LowByte & 0xF)) {
decodedIRData.flags = IRDATA_FLAGS_PARITY_FAILED | IRDATA_FLAGS_IS_LSB_FIRST;
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINT(F("4 bit VendorID parity is not correct. expected=0x"));
IR_DEBUG_PRINT(tVendorParity, HEX);
@ -249,7 +226,6 @@ bool IRrecv::decodeKaseikyo() {
IR_DEBUG_PRINT(decodedIRData.decodedRawData, HEX);
IR_DEBUG_PRINT(F(" VendorID=0x"));
IR_DEBUG_PRINTLN(tVendorId, HEX);
decodedIRData.flags = IRDATA_FLAGS_PARITY_FAILED | IRDATA_FLAGS_IS_LSB_FIRST;
}
if (tProtocol == KASEIKYO) {
@ -258,6 +234,8 @@ bool IRrecv::decodeKaseikyo() {
}
if (tValue.UByte.HighByte != tParity) {
decodedIRData.flags |= IRDATA_FLAGS_PARITY_FAILED;
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINT(F("8 bit Parity is not correct. expected=0x"));
IR_DEBUG_PRINT(tParity, HEX);
@ -267,7 +245,6 @@ bool IRrecv::decodeKaseikyo() {
IR_DEBUG_PRINT(decodedIRData.address, HEX);
IR_DEBUG_PRINT(F(" command=0x"));
IR_DEBUG_PRINTLN(decodedIRData.command, HEX);
decodedIRData.flags |= IRDATA_FLAGS_PARITY_FAILED;
}
// check for repeat
@ -282,60 +259,11 @@ bool IRrecv::decodeKaseikyo() {
return true;
}
/**
* Old MSB first decoder
/*
* Removed void IRsend::sendPanasonic(uint16_t aAddress, uint32_t aData)
* and bool IRrecv::decodePanasonicMSB(decode_results *aResults)
* since their implementations were wrong (wrong length), and nobody recognized it
*/
bool IRrecv::decodePanasonicMSB(decode_results *aResults) {
unsigned int offset = 1;
if (aResults->rawlen < (2 * KASEIKYO_BITS) + 2) {
return false;
}
if (!matchMark(aResults->rawbuf[offset], KASEIKYO_HEADER_MARK)) {
return false;
}
offset++;
if (!matchMark(aResults->rawbuf[offset], KASEIKYO_HEADER_SPACE)) {
return false;
}
offset++;
// decode address
if (!decodePulseDistanceData(KASEIKYO_ADDRESS_BITS + KASEIKYO_DATA_BITS, offset, KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE,
KASEIKYO_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST)) {
return false;
}
aResults->bits = KASEIKYO_BITS;
aResults->value = decodedIRData.decodedRawData;
aResults->address = PANASONIC_VENDOR_ID_CODE;
aResults->decode_type = PANASONIC;
decodedIRData.protocol = PANASONIC;
return true;
}
/**
* Old version with MSB first data
*/
void IRsend::sendPanasonic(uint16_t aAddress, uint32_t aData) {
// Set IR carrier frequency
enableIROut(KASEIKYO_KHZ); // 36.7kHz is the correct frequency
// Header
mark(KASEIKYO_HEADER_MARK);
space(KASEIKYO_HEADER_SPACE);
// Old version with MSB first Data Address
sendPulseDistanceWidthData(KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE, KASEIKYO_BIT_MARK, KASEIKYO_ZERO_SPACE, aAddress,
KASEIKYO_ADDRESS_BITS, PROTOCOL_IS_MSB_FIRST, SEND_NO_STOP_BIT);
// Old version with MSB first Data Data + stop bit
sendPulseDistanceWidthData(KASEIKYO_BIT_MARK, KASEIKYO_ONE_SPACE, KASEIKYO_BIT_MARK, KASEIKYO_ZERO_SPACE, aData,
KASEIKYO_DATA_BITS, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
IrReceiver.restartAfterSend();
}
/** @}*/
#endif // _IR_KASEIKYO_HPP

View File

@ -1,14 +1,14 @@
/*
* ir_LG.hpp
*
* Contains functions for receiving and sending LG IR Protocol in "raw" and standard format with 16 or 8 bit address and 8 bit command
* Contains functions for receiving and sending LG IR Protocol for air conditioner
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
*
************************************************************************************
* MIT License
*
* Copyright (c) 2017-2021 Darryl Smith, Armin Joachimsmeyer
* Copyright (c) 2017-2022 Darryl Smith, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,11 +32,6 @@
#ifndef _IR_LG_HPP
#define _IR_LG_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -54,14 +49,25 @@
// Bit and repeat timing is like NEC
// LG2 has different header timing and a shorter bit time
/*
* LG remote IR-LED measurements: Type AKB73315611, Ver1.1 from 2011.03.01
* LG remote IR-LED measurements: Type AKB 73315611 for air conditioner, Ver1.1 from 2011.03.01
* Protocol: LG2
* Internal crystal: 4 MHz
* Header: 8.9 ms mark 4.15 ms space
* Data: 500 / 540 and 500 / 1580;
* Clock is nor synchronized with gate so you have 19 and sometimes 19 and a spike pulses for mark
* Clock is not synchronized with gate so you have 19 and sometimes 19 and a spike pulses for mark
* Duty: 9 us on 17 us off => around 33 % duty
* NO REPEAT: If value like temperature has changed during long press, the last value is send at button release.
* If you do a double press, the next value can be sent after around 118 ms. Tested with the fan button.
* LG remote IR-LED measurements: Type AKB 75095308 for LG TV
* Protocol: NEC!!!
* Frequency 37.88 kHz
* Header: 9.0 ms mark 4.5 ms space
* Data: 560 / 560 and 560 / 1680;
* Clock is synchronized with gate, mark always starts with a full period
* Duty: 13 us on 13 us off => 50 % duty
* Repeat: 110 ms 9.0 ms mark, 2250 us space, 560 stop
* LSB first!
*
* The codes of the LG air conditioner are documented in https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/ac_LG.cpp
*/
@ -73,7 +79,7 @@
#define LG_UNIT 500 // 19 periods of 38 kHz
#define LG_HEADER_MARK (18 * LG_UNIT) // 9000
#define LG_HEADER_SPACE 4200 // 84
#define LG_HEADER_SPACE 4200 // 4200 | 84
#define LG2_HEADER_MARK (6 * LG_UNIT) // 3000
#define LG2_HEADER_SPACE (19 * LG_UNIT) // 9500
@ -88,29 +94,53 @@
#define LG_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
#define LG_REPEAT_SPACE (LG_REPEAT_PERIOD - LG_AVERAGE_DURATION) // 52 ms
//+=============================================================================
struct PulsePauseWidthProtocolConstants LGProtocolConstants = { LG, LG_KHZ, LG_HEADER_MARK, LG_HEADER_SPACE, LG_BIT_MARK,
LG_ONE_SPACE, LG_BIT_MARK, LG_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, (LG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI),
&sendNECSpecialRepeat };
struct PulsePauseWidthProtocolConstants LG2ProtocolConstants = { LG2, LG_KHZ, LG2_HEADER_MARK, LG2_HEADER_SPACE, LG_BIT_MARK,
LG_ONE_SPACE, LG_BIT_MARK, LG_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, (LG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI),
&sendLG2SpecialRepeat };
/************************************
* Start of send and decode functions
************************************/
/*
* Send repeat
* Repeat commands should be sent in a 110 ms raster.
* Send special LG repeat
*/
void IRsend::sendLGRepeat(bool aUseLG2Protocol) {
enableIROut(LG_KHZ); // 38 kHz
if (aUseLG2Protocol) {
mark(LG2_HEADER_MARK);
} else {
mark(LG_HEADER_MARK);
}
space(LG_REPEAT_HEADER_SPACE);
mark(LG_BIT_MARK);
void IRsend::sendLGRepeat() {
sendNECRepeat(); // we can take the NEC timing here
// enableIROut(LG_KHZ); // 38 kHz
// mark(LG_HEADER_MARK); // + 9000
// space(LG_REPEAT_HEADER_SPACE); // - 2250
// mark(LG_BIT_MARK); // + 500 // NEC has 560, but this should work also!
// IrReceiver.restartAfterSend();
}
/*
* Send special LG2 repeat
*/
void IRsend::sendLG2Repeat() {
enableIROut(LG_KHZ); // 38 kHz
mark(LG2_HEADER_MARK); // + 3000
space(LG_REPEAT_HEADER_SPACE); // - 2250
mark(LG_BIT_MARK); // + 500
IrReceiver.restartAfterSend();
}
/**
* Repeat commands should be sent in a 110 ms raster.
* There is NO delay after the last sent repeat!
* @param aUseLG2Protocol if true use LG2 protocol, which has a different header
* Static function for sending special repeat frame.
* For use in ProtocolConstants. Saves up to 250 bytes compared to a member function.
*/
void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat, bool aUseLG2Protocol) {
void sendLG2SpecialRepeat() {
IrSender.enableIROut(LG_KHZ); // 38 kHz
IrSender.mark(LG2_HEADER_MARK); // + 3000
IrSender.space(LG_REPEAT_HEADER_SPACE); // - 2250
IrSender.mark(LG_BIT_MARK); // + 500
IrReceiver.restartAfterSend();
}
uint32_t IRsend::computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand) {
uint32_t tRawData = ((uint32_t) aAddress << (LG_COMMAND_BITS + LG_CHECKSUM_BITS)) | ((uint32_t) aCommand << LG_CHECKSUM_BITS);
/*
* My guess of the 4 bit checksum
@ -122,63 +152,34 @@ void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfR
tChecksum += tTempForChecksum & 0xF; // add low nibble
tTempForChecksum >>= 4; // shift by a nibble
}
tRawData |= (tChecksum & 0xF);
sendLGRaw(tRawData, aNumberOfRepeats, aSendOnlySpecialLGRepeat, aUseLG2Protocol);
return (tRawData | (tChecksum & 0xF));
}
void IRsend::sendLG2(uint8_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat) {
sendLG(aAddress, aCommand, aNumberOfRepeats, aSendOnlySpecialLGRepeat);
}
/*
* Here you can put your raw data, even one with "wrong" checksum
/**
* LG uses the NEC repeat.
*/
void IRsend::sendLGRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialLGRepeat, bool aUseLG2Protocol) {
if (aSendOnlySpecialLGRepeat) {
sendLGRepeat();
return;
}
// Set IR carrier frequency
enableIROut(LG_KHZ);
// Header
if (aUseLG2Protocol) {
mark(LG2_HEADER_MARK);
space(LG2_HEADER_SPACE);
} else {
mark(LG_HEADER_MARK);
space(LG_HEADER_SPACE);
}
// MSB first
sendPulseDistanceWidthData(LG_BIT_MARK, LG_ONE_SPACE, LG_BIT_MARK, LG_ZERO_SPACE, aRawData, LG_BITS, PROTOCOL_IS_MSB_FIRST,
SEND_STOP_BIT);
for (uint_fast8_t i = 0; i < aNumberOfRepeats; ++i) {
// send repeat in a 110 ms raster
if (i == 0) {
delay(LG_REPEAT_SPACE / MICROS_IN_ONE_MILLI);
} else {
delay((LG_REPEAT_PERIOD - LG_REPEAT_DURATION) / MICROS_IN_ONE_MILLI);
}
// send repeat
sendLGRepeat(aUseLG2Protocol);
}
IrReceiver.restartAfterSend();
void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
sendPulseDistanceWidth(&LGProtocolConstants, computeLGRawDataAndChecksum(aAddress, aCommand), LG_BITS, aNumberOfRepeats);
}
//+=============================================================================
// LGs has a repeat like NEC
//
/*
* First check for right data length
* Next check start bit
* Next try the decode
* Last check stop bit
/**
* LG2 uses a special repeat.
*/
void IRsend::sendLG2(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
sendPulseDistanceWidth(&LG2ProtocolConstants, computeLGRawDataAndChecksum(aAddress, aCommand), LG_BITS, aNumberOfRepeats);
}
bool IRrecv::decodeLG() {
decode_type_t tProtocol = LG;
uint16_t tHeaderSpace = LG_HEADER_SPACE;
/*
* First check for right data length
* Next check start bit
* Next try the decode
* Last check stop bit
*/
// Check we have the right amount of data (60). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != ((2 * LG_BITS) + 4) && (decodedIRData.rawDataPtr->rawlen != 4)) {
IR_DEBUG_PRINT(F("LG: "));
@ -222,7 +223,7 @@ bool IRrecv::decodeLG() {
return false;
}
if (!decodePulseDistanceData(LG_BITS, 3, LG_BIT_MARK, LG_ONE_SPACE, LG_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST)) {
if (!decodePulseDistanceData(&LGProtocolConstants, LG_BITS)) {
IR_DEBUG_PRINT(F("LG: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
@ -267,6 +268,23 @@ bool IRrecv::decodeLG() {
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
/**
* Here you can put your raw data, even one with "wrong" checksum
* @param aNumberOfRepeats If < 0 then only a special repeat frame will be sent
*/
void IRsend::sendLGRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats) {
if (aNumberOfRepeats < 0) {
sendLGRepeat();
return;
}
sendPulseDistanceWidth(&LGProtocolConstants, aRawData, LG_BITS, aNumberOfRepeats);
}
bool IRrecv::decodeLGMSB(decode_results *aResults) {
unsigned int offset = 1; // Skip first space

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2021 Armin Joachimsmeyer
* Copyright (c) 2020-2022 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,11 +32,6 @@
#ifndef _IR_LEGO_HPP
#define _IR_LEGO_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -83,15 +78,20 @@
#define LEGO_AUTO_REPEAT_PERIOD_MIN 110000 // Every frame is auto repeated 5 times.
#define LEGO_AUTO_REPEAT_PERIOD_MAX 230000 // space for channel 3
/*
* Compatibility function for legacy code, this calls the send raw data function
*/
void IRsend::sendLegoPowerFunctions(uint16_t aRawData, bool aDoSend5Times) {
sendLegoPowerFunctions(aRawData, (aRawData >> (LEGO_MODE_BITS + LEGO_COMMAND_BITS + LEGO_PARITY_BITS)) & 0x3, aDoSend5Times);
}
#define LEGO_MODE_EXTENDED 0
#define LEGO_MODE_COMBO 1
#define LEGO_MODE_SINGLE 0x4 // here the 2 LSB have meanings like Output A / Output B
struct PulsePauseWidthProtocolConstants LegoProtocolConstants = { LEGO_PF, 38, LEGO_HEADER_MARK, LEGO_HEADER_SPACE, LEGO_BIT_MARK,
LEGO_ONE_SPACE, LEGO_BIT_MARK, LEGO_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (LEGO_AUTO_REPEAT_PERIOD_MIN
/ MICROS_IN_ONE_MILLI), NULL };
/************************************
* Start of send and decode functions
************************************/
/*
* Here we process the structured data, and call the send raw data function
* @param aMode one of LEGO_MODE_EXTENDED, LEGO_MODE_COMBO, LEGO_MODE_SINGLE
*/
void IRsend::sendLegoPowerFunctions(uint8_t aChannel, uint8_t aCommand, uint8_t aMode, bool aDoSend5Times) {
aChannel &= 0x0F; // allow toggle and escape bits too
@ -117,9 +117,8 @@ void IRsend::sendLegoPowerFunctions(uint16_t aRawData, uint8_t aChannel, bool aD
}
// required for repeat timing, see http://www.hackvandedam.nl/blog/?page_id=559
uint8_t tRepeatPeriod = (LEGO_AUTO_REPEAT_PERIOD_MIN / MICROS_IN_ONE_MILLI) + (aChannel * 40); // from 110 to 230
sendPulseDistanceWidth(38, LEGO_HEADER_MARK, LEGO_HEADER_SPACE, LEGO_BIT_MARK, LEGO_ONE_SPACE, LEGO_BIT_MARK, LEGO_ZERO_SPACE,
aRawData, LEGO_BITS, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, tRepeatPeriod, tNumberOfRepeats);
LegoProtocolConstants.RepeatPeriodMillis = tRepeatPeriod;
sendPulseDistanceWidth(&LegoProtocolConstants, aRawData, LEGO_BITS, tNumberOfRepeats);
}
/*
@ -127,9 +126,7 @@ void IRsend::sendLegoPowerFunctions(uint16_t aRawData, uint8_t aChannel, bool aD
*/
bool IRrecv::decodeLegoPowerFunctions() {
// Check header "mark"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], LEGO_HEADER_MARK)) {
// no debug output, since this check is mainly to determine the received protocol
if (!checkHeader(&LegoProtocolConstants)) {
return false;
}
@ -141,14 +138,8 @@ bool IRrecv::decodeLegoPowerFunctions() {
IR_DEBUG_PRINTLN(F(" is not 36"));
return false;
}
// Check header "space"
if (!matchSpace(decodedIRData.rawDataPtr->rawbuf[2], LEGO_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("LEGO: "));
IR_DEBUG_PRINTLN(F("Header space length is wrong"));
return false;
}
if (!decodePulseDistanceData(LEGO_BITS, 3, LEGO_BIT_MARK, LEGO_ONE_SPACE, LEGO_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST)) {
if (!decodePulseDistanceData(&LegoProtocolConstants, LEGO_BITS)) {
IR_DEBUG_PRINT(F("LEGO: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
@ -206,5 +197,13 @@ bool IRrecv::decodeLegoPowerFunctions() {
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
void IRsend::sendLegoPowerFunctions(uint16_t aRawData, bool aDoSend5Times) {
sendLegoPowerFunctions(aRawData, (aRawData >> (LEGO_MODE_BITS + LEGO_COMMAND_BITS + LEGO_PARITY_BITS)) & 0x3, aDoSend5Times);
}
/** @}*/
#endif // _IR_LEGO_HPP

View File

@ -33,10 +33,6 @@
#ifndef _IR_MAGIQUEST_HPP
#define _IR_MAGIQUEST_HPP
#include <Arduino.h>
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
#define LOCAL_DEBUG
#else
@ -107,6 +103,10 @@ union magiquest_t {
#define MAGIQUEST_ZERO_MARK MAGIQUEST_UNIT // 287.5
#define MAGIQUEST_ZERO_SPACE (3 * MAGIQUEST_UNIT) // 864
// assume 110 as repeat period
struct PulsePauseWidthProtocolConstants MagiQuestProtocolConstants = { MAGIQUEST, 38, MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE,
MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE, MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_NO_STOP_BIT, 110,
NULL };
//+=============================================================================
//
void IRsend::sendMagiQuest(uint32_t wand_id, uint16_t magnitude) {
@ -115,17 +115,10 @@ void IRsend::sendMagiQuest(uint32_t wand_id, uint16_t magnitude) {
enableIROut(38);
// 8 start bits
sendPulseDistanceWidthData(
MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE, MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE, 0, 8, PROTOCOL_IS_MSB_FIRST,
SEND_NO_STOP_BIT);
sendPulseDistanceWidthData(&MagiQuestProtocolConstants, 0, 8);
// Data
sendPulseDistanceWidthData(
MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE, MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE, wand_id, MAGIQUEST_WAND_ID_BITS,
PROTOCOL_IS_MSB_FIRST, SEND_NO_STOP_BIT);
sendPulseDistanceWidthData(
MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE, MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE, magnitude, MAGIQUEST_MAGNITUDE_BITS,
PROTOCOL_IS_MSB_FIRST, SEND_NO_STOP_BIT);
sendPulseDistanceWidthData(&MagiQuestProtocolConstants, wand_id, MAGIQUEST_WAND_ID_BITS);
sendPulseDistanceWidthData(&MagiQuestProtocolConstants, magnitude, MAGIQUEST_MAGNITUDE_BITS);
IrReceiver.restartAfterSend();
}
@ -203,7 +196,7 @@ bool IRrecv::decodeMagiQuest() {
decodedIRData.decodedRawData = data.cmd.wand_id; // 32 bit wand_id
decodedIRData.address = data.cmd.wand_id; // lower 16 bit of wand_id
decodedIRData.extra = data.cmd.wand_id << 16; // upper 16 bit of wand_id
decodedIRData.command = data.cmd.magnitude; // seems to be always 205 https://github.com/Arduino-IRremote/Arduino-IRremote/issues/1017
decodedIRData.command = data.cmd.magnitude; // seems to be always 205 https://github.com/Arduino-IRremote/Arduino-IRremote/issues/1017
return true;
}

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2021 Armin Joachimsmeyer
* Copyright (c) 2020-2022 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,12 +32,6 @@
#ifndef _IR_NEC_HPP
#define _IR_NEC_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
#include "LongUnion.h"
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -86,28 +80,43 @@
#define NEC_MAXIMUM_REPEAT_SPACE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 5) // 65 ms
#define APPLE_ADDRESS 0x87EE
//+=============================================================================
/*
* Send repeat
struct PulsePauseWidthProtocolConstants NECProtocolConstants = { NEC, NEC_KHZ, NEC_HEADER_MARK, NEC_HEADER_SPACE, NEC_BIT_MARK,
NEC_ONE_SPACE, NEC_BIT_MARK, NEC_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (NEC_REPEAT_PERIOD / MICROS_IN_ONE_MILLI),
&sendNECSpecialRepeat };
struct PulsePauseWidthProtocolConstants NEC2ProtocolConstants = { NEC2, NEC_KHZ, NEC_HEADER_MARK, NEC_HEADER_SPACE, NEC_BIT_MARK,
NEC_ONE_SPACE, NEC_BIT_MARK, NEC_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (NEC_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
/************************************
* Start of send and decode functions
************************************/
/**
* Send special NEC repeat frame
* Repeat commands should be sent in a 110 ms raster.
*/
void IRsend::sendNECRepeat() {
enableIROut(NEC_KHZ); // 38 kHz
mark(NEC_HEADER_MARK);
space(NEC_REPEAT_HEADER_SPACE);
mark(NEC_BIT_MARK);
enableIROut(NEC_KHZ); // 38 kHz
mark(NEC_HEADER_MARK); // + 9000
space(NEC_REPEAT_HEADER_SPACE); // - 2250
mark(NEC_BIT_MARK); // + 560
IrReceiver.restartAfterSend();
// ledOff(); // Always end with the LED off
}
/*
* Repeat commands should be sent in a 110 ms raster.
* There is NO delay after the last sent repeat!
* https://www.sbprojects.net/knowledge/ir/nec.php
* @param aSendOnlySpecialNECRepeat if true, send only one repeat frame without leading and trailing space
/**
* Static function for sending special repeat frame.
* For use in ProtocolConstants. Saves up to 250 bytes compared to a member function.
*/
void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat) {
void sendNECSpecialRepeat() {
IrSender.enableIROut(NEC_KHZ); // 38 kHz
IrSender.mark(NEC_HEADER_MARK); // + 9000
IrSender.space(NEC_REPEAT_HEADER_SPACE); // - 2250
IrSender.mark(NEC_BIT_MARK); // + 560
IrReceiver.restartAfterSend();
}
uint32_t IRsend::computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand) {
LongUnion tRawData;
// Address 16 bit LSB first
@ -122,8 +131,15 @@ void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOf
// send 8 command bits and then 8 inverted command bits LSB first
tRawData.UByte.MidHighByte = aCommand;
tRawData.UByte.HighByte = ~aCommand;
return tRawData.ULong;
}
sendNECRaw(tRawData.ULong, aNumberOfRepeats, aSendOnlySpecialNECRepeat);
/**
* @param aNumberOfRepeats If < 0 then only a special repeat frame will be sent
*/
void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendPulseDistanceWidth(&NECProtocolConstants, computeNECRawDataAndChecksum(aAddress, aCommand), NEC_BITS, aNumberOfRepeats);
}
/*
@ -131,45 +147,9 @@ void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOf
* There is NO delay after the last sent repeat!
* @param aSendOnlySpecialNECRepeat if true, send only one repeat frame without leading and trailing space
*/
void IRsend::sendNEC2(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
LongUnion tRawData;
// Address 16 bit LSB first
if ((aAddress & 0xFF00) == 0) {
// assume 8 bit address -> send 8 address bits and then 8 inverted address bits LSB first
tRawData.UByte.LowByte = aAddress;
tRawData.UByte.MidLowByte = ~tRawData.UByte.LowByte;
} else {
tRawData.UWord.LowWord = aAddress;
}
// send 8 command bits and then 8 inverted command bits LSB first
tRawData.UByte.MidHighByte = aCommand;
tRawData.UByte.HighByte = ~aCommand;
// Set IR carrier frequency
enableIROut(NEC_KHZ);
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
// Header
mark(NEC_HEADER_MARK);
space(NEC_HEADER_SPACE);
// LSB first + stop bit
sendPulseDistanceWidthData(NEC_BIT_MARK, NEC_ONE_SPACE, NEC_BIT_MARK, NEC_ZERO_SPACE, tRawData.ULong, NEC_BITS,
PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT);
tNumberOfCommands--;
// skip last delay!
if (tNumberOfCommands > 0) {
// send repeated command in a fixed raster
delay(NEC_REPEAT_SPACE / MICROS_IN_ONE_MILLI);
}
}
IrReceiver.restartAfterSend();
void IRsend::sendNEC2(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendPulseDistanceWidth(&NEC2ProtocolConstants, computeNECRawDataAndChecksum(aAddress, aCommand), NEC_BITS, aNumberOfRepeats);
}
/*
@ -177,16 +157,9 @@ void IRsend::sendNEC2(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberO
* There is NO delay after the last sent repeat!
* @param aSendOnlySpecialNECRepeat if true, send only one repeat frame without leading and trailing space
*/
void IRsend::sendOnkyo(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat) {
void IRsend::sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
LongUnion tRawData;
// Address 16 bit LSB first
tRawData.UWord.LowWord = aAddress;
// Command 16 bit LSB first
tRawData.UWord.HighWord = aCommand;
sendNECRaw(tRawData.ULong, aNumberOfRepeats, aSendOnlySpecialNECRepeat);
sendPulseDistanceWidth(&NECProtocolConstants, (uint32_t) aCommand << 16 | aAddress, NEC_BITS, aNumberOfRepeats);
}
/*
@ -197,7 +170,7 @@ void IRsend::sendOnkyo(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumbe
* @param aAddress is the DeviceId*
* @param aSendOnlySpecialNECRepeat if true, send only one repeat frame without leading and trailing space
*/
void IRsend::sendApple(uint8_t aDeviceId, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat) {
void IRsend::sendApple(uint8_t aDeviceId, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
LongUnion tRawData;
@ -208,54 +181,27 @@ void IRsend::sendApple(uint8_t aDeviceId, uint8_t aCommand, uint_fast8_t aNumber
tRawData.UByte.MidHighByte = aCommand;
tRawData.UByte.HighByte = aDeviceId; // e.g. 0xD7
sendNECRaw(tRawData.ULong, aNumberOfRepeats, aSendOnlySpecialNECRepeat);
sendPulseDistanceWidth(&NECProtocolConstants, tRawData.ULong, NEC_BITS, aNumberOfRepeats);
}
/*
* Sends NEC1 protocol
*/
void IRsend::sendNECRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats, bool aSendOnlySpecialNECRepeat) {
if (aSendOnlySpecialNECRepeat) {
sendNECRepeat();
return;
}
// Set IR carrier frequency
enableIROut(NEC_KHZ);
void IRsend::sendNECRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats) {
// Header
mark(NEC_HEADER_MARK);
space(NEC_HEADER_SPACE);
// LSB first + stop bit
sendPulseDistanceWidthData(NEC_BIT_MARK, NEC_ONE_SPACE, NEC_BIT_MARK, NEC_ZERO_SPACE, aRawData, NEC_BITS, PROTOCOL_IS_LSB_FIRST,
SEND_STOP_BIT);
for (uint_fast8_t i = 0; i < aNumberOfRepeats; ++i) {
// send repeat in a 110 ms raster
if (i == 0) {
delay(NEC_REPEAT_SPACE / MICROS_IN_ONE_MILLI);
} else {
delay((NEC_REPEAT_PERIOD - NEC_REPEAT_DURATION) / MICROS_IN_ONE_MILLI);
}
// send special NEC repeats
sendNECRepeat();
}
IrReceiver.restartAfterSend();
sendPulseDistanceWidth(&NECProtocolConstants, aRawData, NEC_BITS, aNumberOfRepeats);
}
//+=============================================================================
// NEC1 has a repeat only 4 items long
//
/*
* First check for right data length
* Next check start bit
* Next try the decode
* Last check stop bit
*
* Decodes also Apple
/**
* Decodes also Onkyo and Apple
*/
bool IRrecv::decodeNEC() {
/*
* First check for right data length
* Next check start bit
* Next try the decode
* Last check stop bit
*/
// Check we have the right amount of data (68). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != ((2 * NEC_BITS) + 4) && (decodedIRData.rawDataPtr->rawlen != 4)) {
IR_DEBUG_PRINT(F("NEC: "));
@ -290,7 +236,7 @@ bool IRrecv::decodeNEC() {
return false;
}
if (!decodePulseDistanceData(NEC_BITS, 3, NEC_BIT_MARK, NEC_ONE_SPACE, NEC_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST)) {
if (!decodePulseDistanceData(&NECProtocolConstants, NEC_BITS)) {
IR_DEBUG_PRINT(F("NEC: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
@ -333,16 +279,6 @@ bool IRrecv::decodeNEC() {
} else {
decodedIRData.protocol = ONKYO;
decodedIRData.command = tValue.UWord.HighWord; // 16 bit command
/*
* Old NEC plausibility check below, now it is just ONKYO :-)
*/
// IR_DEBUG_PRINT(F("NEC: "));
// IR_DEBUG_PRINT(F("Command=0x"));
// IR_DEBUG_PRINT(tValue.UByte.MidHighByte, HEX);
// IR_DEBUG_PRINT(F(" is not inverted value of 0x"));
// IR_DEBUG_PRINTLN(tValue.UByte.HighByte, HEX);
// decodedIRData.flags = IRDATA_FLAGS_PARITY_FAILED | IRDATA_FLAGS_IS_LSB_FIRST;
}
}
decodedIRData.numberOfBits = NEC_BITS;
@ -356,6 +292,10 @@ bool IRrecv::decodeNEC() {
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
bool IRrecv::decodeNECMSB(decode_results *aResults) {
unsigned int offset = 1; // Index in to results; Skip first space.

113
src/ir_Others.hpp Normal file
View File

@ -0,0 +1,113 @@
/*
* ir_Others.hpp
*
* Contains functions for miscellaneous protocols
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
*
************************************************************************************
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
************************************************************************************
*/
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
#ifndef _IR_OTHERS_HPP
#define _IR_OTHERS_HPP
//==============================================================================
// DDDD IIIII SSSS H H
// D D I S H H
// D D I SSS HHHHH
// D D I S H H
// DDDD IIIII SSSS H H
//==============================================================================
// DISH support by Todd Treece
//
// The send function needs to be repeated 4 times
// Only send the last for characters of the hex.
// I.E. Use 0x1C10 instead of 0x0000000000001C10 as listed in the LIRC file.
// Here is the LIRC file I found that seems to match the remote codes from the
// oscilloscope: DISH NETWORK (echostar 301):
// http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
#define DISH_BITS 16
#define DISH_HEADER_MARK 400
#define DISH_HEADER_SPACE 6100
#define DISH_BIT_MARK 400
#define DISH_ONE_SPACE 1700
#define DISH_ZERO_SPACE 2800
#define DISH_REPEAT_SPACE 6200 // really?
struct PulsePauseWidthProtocolConstants DishProtocolConstants = { UNKNOWN, 56, DISH_HEADER_MARK, DISH_HEADER_SPACE,
DISH_BIT_MARK, DISH_ONE_SPACE, DISH_BIT_MARK, DISH_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, 40, NULL };
void IRsend::sendDish(uint16_t aData) {
sendPulseDistanceWidth(&DishProtocolConstants, aData, DISH_BITS, 4);
}
//==============================================================================
// W W H H Y Y N N TTTTT EEEEE RRRRR
// W W H H Y Y NN N T E R R
// W W W HHHHH Y N N N T EEE RRRR
// W W W H H Y N NN T E R R
// WWW H H Y N N T EEEEE R R
//==============================================================================
// Whynter A/C ARC-110WD added by Francesco Meschia
// see https://docs.google.com/spreadsheets/d/1dsr4Jh-nzC6xvSKGpLlPBF0NRwvlpyw-ozg8eZU813w/edit#gid=0
// Looking at the code table the protocol is LSB first with start and stop bit.
// 4 bit checksum, constant address 0xAA00, 8 bit Command and 4 bit Command group
// but we use MSB first to be backwards compatible
#define WHYNTER_BITS 32
#define WHYNTER_HEADER_MARK 2850
#define WHYNTER_HEADER_SPACE 2850
#define WHYNTER_BIT_MARK 750
#define WHYNTER_ONE_SPACE 2150
#define WHYNTER_ZERO_SPACE 750
struct PulsePauseWidthProtocolConstants WhynterProtocolConstants = { WHYNTER, 38, WHYNTER_HEADER_MARK, WHYNTER_HEADER_SPACE,
WHYNTER_BIT_MARK, WHYNTER_ONE_SPACE, WHYNTER_BIT_MARK, WHYNTER_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, 110, NULL };
void IRsend::sendWhynter(unsigned long aData, uint8_t aNumberOfBitsToSend) {
sendPulseDistanceWidth(&WhynterProtocolConstants, aData, NEC_BITS, aNumberOfBitsToSend);
}
bool IRrecv::decodeWhynter() {
// Check we have the right amount of data (68). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != (2 * WHYNTER_BITS) + 4) {
return false;
}
if (!checkHeader(&WhynterProtocolConstants)) {
return false;
}
if (!decodePulseDistanceData(&WhynterProtocolConstants, WHYNTER_BITS)) {
return false;
}
// Success
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST;
decodedIRData.numberOfBits = WHYNTER_BITS;
decodedIRData.protocol = WHYNTER;
return true;
}
/** @}*/
#endif // _IR_OTHERS_HPP

View File

@ -34,13 +34,6 @@
#ifndef _IR_PRONTO_HPP
#define _IR_PRONTO_HPP
// The first number, here 0000, denotes the type of the signal. 0000 denotes a raw IR signal with modulation,
// The second number, here 006C, denotes a frequency code
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT"
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -65,8 +58,10 @@ static unsigned int toFrequencyKHz(uint16_t code) {
/*
* Parse the string given as Pronto Hex, and send it a number of times given as argument.
* The first number denotes the type of the signal. 0000 denotes a raw IR signal with modulation,
// The second number denotes a frequency code
*/
void IRsend::sendPronto(const uint16_t *data, unsigned int length, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPronto(const uint16_t *data, unsigned int length, int_fast8_t aNumberOfRepeats) {
unsigned int timebase = (microsecondsInSeconds * data[1] + referenceFrequency / 2) / referenceFrequency;
unsigned int khz;
switch (data[0]) {
@ -118,7 +113,7 @@ void IRsend::sendPronto(const uint16_t *data, unsigned int length, uint_fast8_t
if (intros >= 2) {
delay(durations[intros - 1] / MICROS_IN_ONE_MILLI); // equivalent to space(durations[intros - 1]); but allow bigger values for the gap
}
for (unsigned int i = 0; i < aNumberOfRepeats; i++) {
for (int i = 0; i < aNumberOfRepeats; i++) {
sendRaw(durations + intros, repeats - 1, khz);
if ((i + 1) < aNumberOfRepeats) { // skip last trailing space/gap, see above
delay(durations[intros + repeats - 1] / MICROS_IN_ONE_MILLI);
@ -143,7 +138,7 @@ void IRsend::sendPronto(const uint16_t *data, unsigned int length, uint_fast8_t
* @param str C type string (null terminated) containing a Pronto Hex representation.
* @param aNumberOfRepeats Number of times to send the signal.
*/
void IRsend::sendPronto(const char *str, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPronto(const char *str, int_fast8_t aNumberOfRepeats) {
size_t len = strlen(str) / (digitsInProntoNumber + 1) + 1;
uint16_t data[len];
const char *p = str;
@ -168,7 +163,7 @@ void IRsend::sendPronto(const char *str, uint_fast8_t aNumberOfRepeats) {
* @param aNumberOfRepeats Number of times to send the signal.
*/
//far pointer (? for ATMega2560 etc.)
void IRsend::sendPronto_PF(uint_farptr_t str, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPronto_PF(uint_farptr_t str, int_fast8_t aNumberOfRepeats) {
size_t len = strlen_PF(str);
char work[len + 1];
strncpy_PF(work, str, len);
@ -176,7 +171,7 @@ void IRsend::sendPronto_PF(uint_farptr_t str, uint_fast8_t aNumberOfRepeats) {
}
//standard pointer
void IRsend::sendPronto_P(const char *str, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPronto_P(const char *str, int_fast8_t aNumberOfRepeats) {
size_t len = strlen_P(str);
char work[len + 1];
strncpy_P(work, str, len);
@ -184,7 +179,7 @@ void IRsend::sendPronto_P(const char *str, uint_fast8_t aNumberOfRepeats) {
}
#endif
void IRsend::sendPronto(const __FlashStringHelper *str, uint_fast8_t aNumberOfRepeats) {
void IRsend::sendPronto(const __FlashStringHelper *str, int_fast8_t aNumberOfRepeats) {
size_t len = strlen_P(reinterpret_cast<const char*>(str));
char work[len + 1];
strncpy_P(work, reinterpret_cast<const char*>(str), len);

View File

@ -30,13 +30,6 @@
#ifndef _IR_RC5_RC6_HPP
#define _IR_RC5_RC6_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
//#define TRACE // Activate this for more debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
#include "LongUnion.h"
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -75,10 +68,14 @@ uint8_t sLastSendToggleValue = 1; // To start first command with toggle 0
#define RC5_REPEAT_PERIOD (128L * RC5_UNIT) // 113792
#define RC5_REPEAT_SPACE (RC5_REPEAT_PERIOD - RC5_DURATION) // 100 ms
/************************************
* Start of send and decode functions
************************************/
/**
* @param aCommand If aCommand is >=64 then we switch automatically to RC5X
*/
void IRsend::sendRC5(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) {
void IRsend::sendRC5(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) {
// Set IR carrier frequency
enableIROut(RC5_RC6_KHZ);
@ -273,9 +270,9 @@ void IRsend::sendRC6(uint32_t aRawData, uint8_t aNumberOfBitsToSend) {
/**
* Send RC6 64 bit raw data
* We do not wait for the minimal trailing space of 2666 us
* Can be used to send RC6A with ?31? data bits
*/
void IRsend::sendRC6(uint64_t data, uint8_t nbits) {
void IRsend::sendRC6(uint64_t aRawData, uint8_t aNumberOfBitsToSend) {
// Set IR carrier frequency
enableIROut(RC5_RC6_KHZ);
@ -288,11 +285,11 @@ void IRsend::sendRC6(uint64_t data, uint8_t nbits) {
space(RC6_UNIT);
// Data MSB first
uint64_t mask = 1ULL << (nbits - 1);
uint64_t mask = 1ULL << (aNumberOfBitsToSend - 1);
for (uint_fast8_t i = 1; mask; i++, mask >>= 1) {
// The fourth bit we send is the "double width toggle bit"
unsigned int t = (i == 4) ? (RC6_UNIT * 2) : (RC6_UNIT);
if (data & mask) {
if (aRawData & mask) {
mark(t);
space(t);
} else {
@ -308,7 +305,7 @@ void IRsend::sendRC6(uint64_t data, uint8_t nbits) {
* We do not wait for the minimal trailing space of 2666 us
* @param aEnableAutomaticToggle Send toggle bit according to the state of the static sLastSendToggleValue variable.
*/
void IRsend::sendRC6(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) {
void IRsend::sendRC6(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) {
LongUnion tIRRawData;
tIRRawData.UByte.LowByte = aCommand;
@ -464,6 +461,10 @@ bool IRrecv::decodeRC6() {
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
/**
* Old version with 32 bit data
*/
@ -490,7 +491,7 @@ void IRsend::sendRC5(uint32_t data, uint8_t nbits) {
}
/*
* Not longer required, use sendRC5 instead
* Not longer required, use sendRC5(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) instead
*/
void IRsend::sendRC5ext(uint8_t addr, uint8_t cmd, bool toggle) {
// Set IR carrier frequency

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2017-2021 Darryl Smith, Armin Joachimsmeyer
* Copyright (c) 2017-2022 Darryl Smith, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,12 +32,6 @@
#ifndef _IR_SAMSUNG_HPP
#define _IR_SAMSUNG_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
#include "LongUnion.h"
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -74,74 +68,73 @@
#define SAMSUNG_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
#define SAMSUNG_REPEAT_SPACE (SAMSUNG_REPEAT_PERIOD - SAMSUNG_AVERAGE_DURATION)
struct PulsePauseWidthProtocolConstants SamsungProtocolConstants = { SAMSUNG, SAMSUNG_KHZ, SAMSUNG_HEADER_MARK,
SAMSUNG_HEADER_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST,
SEND_STOP_BIT, (SAMSUNG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), &sendSamsungLGSpecialRepeat };
/************************************
* Start of send and decode functions
************************************/
/**
* Send repeat
* Repeat commands should be sent in a 110 ms raster.
* was sent by an LG 6711R1P071A remote
* This repeat was sent by an LG 6711R1P071A remote
*/
void IRsend::sendSamsungLGRepeat() {
enableIROut(SAMSUNG_KHZ); // 38 kHz
mark(SAMSUNG_HEADER_MARK);
space(SAMSUNG_HEADER_SPACE);
mark(SAMSUNG_BIT_MARK);
space(SAMSUNG_ZERO_SPACE);
mark(SAMSUNG_BIT_MARK);
enableIROut(SAMSUNG_KHZ); // 38 kHz
mark(SAMSUNG_HEADER_MARK); // + 4500
space(SAMSUNG_HEADER_SPACE); // - 4500
mark(SAMSUNG_BIT_MARK); // + 560
space(SAMSUNG_ZERO_SPACE); // - 560
mark(SAMSUNG_BIT_MARK); // + 560
IrReceiver.restartAfterSend();
}
void IRsend::sendSamsung(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats) {
/**
* Static function for sending special repeat frame.
* For use in ProtocolConstants. Saves up to 250 bytes compared to a member function.
*/
void sendSamsungLGSpecialRepeat() {
IrSender.enableIROut(SAMSUNG_KHZ); // 38 kHz
IrSender.mark(SAMSUNG_HEADER_MARK); // + 4500
IrSender.space(SAMSUNG_HEADER_SPACE); // - 4500
IrSender.mark(SAMSUNG_BIT_MARK); // + 560
IrSender.space(SAMSUNG_ZERO_SPACE); // - 560
IrSender.mark(SAMSUNG_BIT_MARK); // + 560
IrReceiver.restartAfterSend();
}
void IRsend::sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
// send 16 bit address and 8 command bits and then 8 inverted command bits LSB first
LongUnion tData;
tData.UWord.LowWord = aAddress;
tData.UByte.MidHighByte = aCommand;
tData.UByte.HighByte = ~aCommand;
LongUnion tRawData;
tRawData.UWord.LowWord = aAddress;
tRawData.UByte.MidHighByte = aCommand;
tRawData.UByte.HighByte = ~aCommand;
sendPulseDistanceWidth(SAMSUNG_KHZ, SAMSUNG_HEADER_MARK, SAMSUNG_HEADER_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE,
SAMSUNG_BIT_MARK, SAMSUNG_ZERO_SPACE, tData.ULong, SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND16_BITS, PROTOCOL_IS_LSB_FIRST,
SEND_STOP_BIT, SAMSUNG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI, aNumberOfRepeats);
sendPulseDistanceWidth(&SamsungProtocolConstants, tRawData.ULong, SAMSUNG_BITS, aNumberOfRepeats);
}
/*
* Sent e.g. by an LG 6711R1P071A remote
* @param aNumberOfRepeats If < 0 then only a special repeat frame will be sent
*/
void IRsend::sendSamsungLG(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats,
bool aSendOnlySpecialSamsungRepeat) {
if (aSendOnlySpecialSamsungRepeat) {
void IRsend::sendSamsungLG(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
if (aNumberOfRepeats < 0) {
sendSamsungLGRepeat();
return;
}
// Set IR carrier frequency
enableIROut(SAMSUNG_KHZ);
// Header
mark(SAMSUNG_HEADER_MARK);
space(SAMSUNG_HEADER_SPACE);
// send 16 bit address and 8 command bits and then 8 inverted command bits LSB first
LongUnion tSendValue;
tSendValue.UWord.LowWord = aAddress;
tSendValue.UByte.MidHighByte = aCommand;
tSendValue.UByte.HighByte = ~aCommand;
// Address
sendPulseDistanceWidthData(SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ZERO_SPACE, tSendValue.ULong,
SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND16_BITS, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT);
LongUnion tRawData;
tRawData.UWord.LowWord = aAddress;
tRawData.UByte.MidHighByte = aCommand;
tRawData.UByte.HighByte = ~aCommand;
for (uint_fast8_t i = 0; i < aNumberOfRepeats; ++i) {
// send repeat in a 110 ms raster
if (i == 0) {
delay((SAMSUNG_REPEAT_PERIOD - SAMSUNG_AVERAGE_DURATION) / MICROS_IN_ONE_MILLI);
} else {
delay((SAMSUNG_REPEAT_PERIOD - SAMSUNG_REPEAT_DURATION) / MICROS_IN_ONE_MILLI);
}
// send repeat
sendSamsungLGRepeat();
}
IrReceiver.restartAfterSend();
sendPulseDistanceWidth(&SamsungProtocolConstants, tRawData.ULong, SAMSUNG_BITS, aNumberOfRepeats);
}
//+=============================================================================
bool IRrecv::decodeSamsung() {
// Check we have enough data (68). The +4 is for initial gap, start bit mark and space + stop bit mark
@ -154,12 +147,7 @@ bool IRrecv::decodeSamsung() {
return false;
}
// Check header "mark" + "space"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], SAMSUNG_HEADER_MARK)
|| !matchSpace(decodedIRData.rawDataPtr->rawbuf[2], SAMSUNG_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("Samsung: "));
IR_DEBUG_PRINTLN(F("Header mark or space length is wrong"));
if (!checkHeader(&SamsungProtocolConstants)) {
return false;
}
@ -172,53 +160,51 @@ bool IRrecv::decodeSamsung() {
return true;
}
/*
* Decode first 32 bits
*/
if (!decodePulseDistanceData(&SamsungProtocolConstants, SAMSUNG_BITS)) {
IR_DEBUG_PRINT(F("Samsung: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
}
LongUnion tValue;
tValue.ULong = decodedIRData.decodedRawData;
decodedIRData.address = tValue.UWord.LowWord;
if (decodedIRData.rawDataPtr->rawlen == (2 * SAMSUNG48_BITS) + 4) {
/*
* Samsung48
*/
// decode 16 bit address
if (!decodePulseDistanceData(SAMSUNG_ADDRESS_BITS, 3, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_ZERO_SPACE,
PROTOCOL_IS_LSB_FIRST)) {
IR_DEBUG_PRINT(F("Samsung: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
}
decodedIRData.address = decodedIRData.decodedRawData;
// decode 32 bit command
if (!decodePulseDistanceData(SAMSUNG_COMMAND32_BITS, 3, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_ZERO_SPACE,
PROTOCOL_IS_LSB_FIRST)) {
// decode additional 16 bit
if (!decodePulseDistanceData(&SamsungProtocolConstants, (SAMSUNG_COMMAND32_BITS - SAMSUNG_COMMAND16_BITS),
3 + SAMSUNG_BITS)) {
IR_DEBUG_PRINT(F("Samsung: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
}
// Success
// decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
LongUnion tValue;
tValue.ULong = decodedIRData.decodedRawData;
// Put latest (MSB) bits in LowWord, LSB first would have them in HighWord so keep this in mind for decoding below
tValue.UWord.LowWord = decodedIRData.decodedRawData;
/*
* Check parity
*/
// receive 2 * (8 bits then 8 inverted bits) LSB first
if (tValue.UByte.HighByte != (uint8_t) (~tValue.UByte.MidHighByte)
&& tValue.UByte.MidLowByte != (uint8_t) (~tValue.UByte.LowByte)) {
decodedIRData.flags = IRDATA_FLAGS_PARITY_FAILED | IRDATA_FLAGS_IS_LSB_FIRST;
}
decodedIRData.command = tValue.UByte.HighByte << 8 | tValue.UByte.MidLowByte;
decodedIRData.command = tValue.UByte.MidLowByte << 8 | tValue.UByte.HighByte; // low and high word are swapped here, so fetch it this way
decodedIRData.numberOfBits = SAMSUNG48_BITS;
} else {
/*
* Samsung32
*/
if (!decodePulseDistanceData(SAMSUNG_BITS, 3, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_ZERO_SPACE,
PROTOCOL_IS_LSB_FIRST)) {
IR_DEBUG_PRINT(F("Samsung: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
}
LongUnion tValue;
tValue.ULong = decodedIRData.decodedRawData;
decodedIRData.address = tValue.UWord.LowWord;
if (tValue.UByte.MidHighByte == (uint8_t) (~tValue.UByte.HighByte)) {
// 8 bit command protocol
decodedIRData.command = tValue.UByte.MidHighByte; // first 8 bit
@ -239,6 +225,7 @@ bool IRrecv::decodeSamsung() {
return true;
}
// Old version with MSB first
bool IRrecv::decodeSAMSUNG(decode_results *aResults) {
unsigned int offset = 1; // Skip first space

View File

@ -30,11 +30,6 @@
#ifndef _IR_SONY_HPP
#define _IR_SONY_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
@ -82,31 +77,35 @@
#define SONY_REPEAT_PERIOD 45000 // Commands are repeated every 45 ms (measured from start to start) for as long as the key on the remote control is held down.
#define SONY_REPEAT_SPACE_MAX (SONY_REPEAT_PERIOD - SONY_AVERAGE_DURATION_MIN) // 24 ms
/*
* Repeat commands should be sent in a 45 ms raster.
* There is NO delay after the last sent command / repeat!
* @param numberOfBits if == 20 send 13 address bits otherwise only 5 address bits
*/
void IRsend::sendSony(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, uint8_t numberOfBits) {
uint32_t tData = (uint32_t)aAddress << 7 | aCommand;
// send 5, 8, 13 address bits LSB first
sendPulseDistanceWidth(SONY_KHZ, SONY_HEADER_MARK, SONY_SPACE, SONY_ONE_MARK, SONY_SPACE, SONY_ZERO_MARK, SONY_SPACE, tData,
numberOfBits, PROTOCOL_IS_LSB_FIRST, SEND_NO_STOP_BIT, SONY_REPEAT_PERIOD / MICROS_IN_ONE_MILLI, aNumberOfRepeats);
}
#define SIRCS_12_PROTOCOL 12
#define SIRCS_15_PROTOCOL 15
#define SIRCS_20_PROTOCOL 20
//+=============================================================================
struct PulsePauseWidthProtocolConstants SonyProtocolConstants = { SONY, SONY_KHZ, SONY_HEADER_MARK, SONY_SPACE, SONY_ONE_MARK,
SONY_SPACE, SONY_ZERO_MARK, SONY_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_NO_STOP_BIT, (SONY_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
/************************************
* Start of send and decode functions
************************************/
/**
* @param numberOfBits should be one of SIRCS_12_PROTOCOL, SIRCS_15_PROTOCOL, SIRCS_20_PROTOCOL. Not checked! 20 -> send 13 address bits
*/
void IRsend::sendSony(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, uint8_t numberOfBits) {
uint32_t tData = (uint32_t) aAddress << 7 | aCommand;
// send 5, 8, 13 address bits LSB first
sendPulseDistanceWidth(&SonyProtocolConstants, tData, numberOfBits, aNumberOfRepeats);
}
bool IRrecv::decodeSony() {
// Check header "mark"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], SONY_HEADER_MARK)) {
if (!checkHeader(&SonyProtocolConstants)) {
return false;
}
// Check we have enough data. +2 for initial gap and start bit mark and space minus the last/MSB space. NO stop bit! 26, 32, 42
if (decodedIRData.rawDataPtr->rawlen != (2 * SONY_BITS_MIN) + 2 && decodedIRData.rawDataPtr->rawlen != (2 * SONY_BITS_MAX) + 2
&& decodedIRData.rawDataPtr->rawlen != (2 * SONY_BITS_15) + 2) {
// ??? IR_TRACE_PRINT since I saw this too often
IR_DEBUG_PRINT(F("Sony: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
@ -114,13 +113,6 @@ bool IRrecv::decodeSony() {
return false;
}
// Check header "space"
if (!matchSpace(decodedIRData.rawDataPtr->rawbuf[2], SONY_SPACE)) {
IR_DEBUG_PRINT(F("Sony: "));
IR_DEBUG_PRINTLN(F("Header space length is wrong"));
return false;
}
if (!decodePulseWidthData((decodedIRData.rawDataPtr->rawlen - 1) / 2, 3, SONY_ONE_MARK, SONY_ZERO_MARK, SONY_SPACE,
PROTOCOL_IS_LSB_FIRST)) {
IR_DEBUG_PRINT(F("Sony: "));
@ -130,8 +122,10 @@ bool IRrecv::decodeSony() {
// Success
// decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
uint8_t tCommand = decodedIRData.decodedRawData & 0x7F; // first 7 bits
uint16_t tAddress = decodedIRData.decodedRawData >> 7; // next 5 or 8 or 13 bits
decodedIRData.command = decodedIRData.decodedRawData & 0x7F; // first 7 bits
decodedIRData.address = decodedIRData.decodedRawData >> 7; // next 5 or 8 or 13 bits
decodedIRData.numberOfBits = (decodedIRData.rawDataPtr->rawlen - 1) / 2;
decodedIRData.protocol = SONY;
/*
* Check for repeat
@ -139,14 +133,17 @@ bool IRrecv::decodeSony() {
if (decodedIRData.rawDataPtr->rawbuf[0] < ((SONY_REPEAT_SPACE_MAX + (SONY_REPEAT_SPACE_MAX / 4)) / MICROS_PER_TICK)) {
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST;
}
decodedIRData.command = tCommand;
decodedIRData.address = tAddress;
decodedIRData.numberOfBits = (decodedIRData.rawDataPtr->rawlen - 1) / 2;
decodedIRData.protocol = SONY;
return true;
}
/*********************************************************************************
* Old deprecated functions, kept for backward compatibility to old 2.0 tutorials
*********************************************************************************/
/*
* Old version with MSB first data
*/
#define SONY_DOUBLE_SPACE_USECS 500 // usually see 713 - not using ticks as get number wrap around
bool IRrecv::decodeSonyMSB(decode_results *aResults) {
long data = 0;

View File

@ -31,7 +31,7 @@
and add your protocol in the same way as it is already done for BOSEWAVE.
You have to change the following files:
IRSend.hpp IRsend::write(IRData *aIRSendData + uint_fast8_t aNumberOfRepeats)
IRSend.hpp IRsend::write(IRData *aIRSendData + int_fast8_t aNumberOfRepeats)
IRProtocol.h Add it to decode_type_t
IRReceive.hpp IRrecv::decode() + printActiveIRProtocols(Print *aSerial) + getProtocolString(decode_type_t aProtocol)
IRremote.hpp At 3 occurrences of DECODE_XXX
@ -56,7 +56,7 @@
*/
/*
* ir_Shuzu.cpp
* ir_Shuzu.hpp
*
* Contains functions for receiving and sending Shuzu IR Protocol ...
*
@ -92,13 +92,6 @@
#ifndef _IR_SHUZU_HPP
#define _IR_SHUZU_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
//#define SEND_SHUZU 1 // for testing
//#define DECODE_SHUZU 1 // for testing
//==============================================================================
//
//
@ -124,94 +117,61 @@
#define SHUZU_REPEAT_HEADER_SPACE (4 * SHUZU_UNIT) // 2250
#define SHUZU_REPEAT_PERIOD 110000
#define SHUZU_REPEAT_SPACE 45000
#define SHUZU_OTHER 1234 // Other things you may need to define
//+=============================================================================
//
void IRsend::sendShuzu(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
// Set IR carrier frequency
enableIROut(38);
// use BOSEWAVE, we have no SHUZU code
struct PulsePauseWidthProtocolConstants ShuzuProtocolConstants = { BOSEWAVE, 38, SHUZU_HEADER_MARK, SHUZU_HEADER_SPACE,
SHUZU_BIT_MARK, SHUZU_ONE_SPACE, SHUZU_BIT_MARK, SHUZU_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (SHUZU_REPEAT_PERIOD
/ MICROS_IN_ONE_MILLI), NULL };
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
/************************************
* Start of send and decode functions
************************************/
// Header
mark(SHUZU_HEADER_MARK);
space(SHUZU_HEADER_SPACE);
void IRsend::sendShuzu(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
// Address (device and subdevice)
sendPulseDistanceWidthData(SHUZU_BIT_MARK, SHUZU_ONE_SPACE, SHUZU_BIT_MARK, SHUZU_ZERO_SPACE, aAddress,
SHUZU_ADDRESS_BITS, PROTOCOL_IS_LSB_FIRST, SEND_NO_STOP_BIT); // false -> LSB first
// Command + stop bit
sendPulseDistanceWidthData(SHUZU_BIT_MARK, SHUZU_ONE_SPACE, SHUZU_BIT_MARK, SHUZU_ZERO_SPACE, aCommand,
SHUZU_COMMAND_BITS, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT); // false, true -> LSB first, stop bit
tNumberOfCommands--;
// skip last delay!
if (tNumberOfCommands > 0) {
// send repeated command in a fixed raster
delay(SHUZU_REPEAT_SPACE / MICROS_IN_ONE_MILLI);
}
}
IrReceiver.restartAfterSend();
sendPulseDistanceWidth(&ShuzuProtocolConstants, (uint32_t) aCommand << 8 | aCommand, SHUZU_BITS, aNumberOfRepeats);
}
//+=============================================================================
//
/*
* First check for right data length
* Next check start bit
* Next try the decode
* Last check stop bit
*/
bool IRrecv::decodeShuzu() {
/*
* First check for right data length
* Next check start bit
* Next try the decode
* Last check stop bit
*/
// Check we have the right amount of data (28). The +4 is for initial gap, start bit mark and space + stop bit mark
if (decodedIRData.rawDataPtr->rawlen != (2 * SHUZU_BITS) + 4) {
// no debug output, since this check is mainly to determine the received protocol
return false;
}
// Check header "space"
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], SHUZU_HEADER_MARK)
|| !matchSpace(decodedIRData.rawDataPtr->rawbuf[2], SHUZU_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("Shuzu: "));
IR_DEBUG_PRINTLN(F("Header mark or space length is wrong"));
// Check header
if (!checkHeader(&ShuzuProtocolConstants)) {
return false;
}
// false -> LSB first
if (!decodePulseDistanceData(SHUZU_BITS, 3, SHUZU_BIT_MARK, SHUZU_ONE_SPACE, SHUZU_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST)) {
// Decode
if (!decodePulseDistanceData(&ShuzuProtocolConstants, SHUZU_BITS)) {
IR_DEBUG_PRINT(F("Shuzu: "));
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
}
// Stop bit
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[3 + (2 * SHUZU_BITS)], SHUZU_BIT_MARK)) {
IR_DEBUG_PRINT(F("Shuzu: "));
IR_DEBUG_PRINTLN(F("Stop bit mark length is wrong"));
return false;
}
// Success
// Success, interpret raw data
// decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
uint8_t tCommand = decodedIRData.decodedRawData >> SHUZU_ADDRESS_BITS; // upper 8 bits of LSB first value
uint8_t tAddress = decodedIRData.decodedRawData & 0xFFFF; // lowest 16 bit of LSB first value
decodedIRData.command = decodedIRData.decodedRawData >> SHUZU_ADDRESS_BITS; // upper 8 bits of LSB first value
decodedIRData.address = decodedIRData.decodedRawData & 0xFFFF; // lowest 16 bit of LSB first value
decodedIRData.numberOfBits = SHUZU_BITS;
decodedIRData.protocol = BOSEWAVE; // we have no SHUZU code
/*
* Check for repeat
*/
//Check for repeat
if (decodedIRData.rawDataPtr->rawbuf[0] < ((SHUZU_REPEAT_SPACE + (SHUZU_REPEAT_SPACE / 4)) / MICROS_PER_TICK)) {
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST;
}
decodedIRData.command = tCommand;
decodedIRData.address = tAddress;
decodedIRData.numberOfBits = SHUZU_BITS;
decodedIRData.protocol = BOSEWAVE; // we have no SHUZU code
return true;
}

View File

@ -1,81 +0,0 @@
#ifndef _IR_WHYNTER_HPP
#define _IR_WHYNTER_HPP
#include <Arduino.h>
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
/** \addtogroup Decoder Decoders and encoders for different protocols
* @{
*/
//==============================================================================
// W W H H Y Y N N TTTTT EEEEE RRRRR
// W W H H Y Y NN N T E R R
// W W W HHHHH Y N N N T EEE RRRR
// W W W H H Y N NN T E R R
// WWW H H Y N N T EEEEE R R
//==============================================================================
// Whynter A/C ARC-110WD added by Francesco Meschia
// see https://docs.google.com/spreadsheets/d/1dsr4Jh-nzC6xvSKGpLlPBF0NRwvlpyw-ozg8eZU813w/edit#gid=0
#define WHYNTER_BITS 32
#define WHYNTER_HEADER_MARK 2850
#define WHYNTER_HEADER_SPACE 2850
#define WHYNTER_BIT_MARK 750
#define WHYNTER_ONE_SPACE 2150
#define WHYNTER_ZERO_SPACE 750
//+=============================================================================
void IRsend::sendWhynter(unsigned long data, int nbits) {
// Set IR carrier frequency
enableIROut(38);
// Start
mark(WHYNTER_BIT_MARK);
space(WHYNTER_ZERO_SPACE);
// Header
mark(WHYNTER_HEADER_MARK);
space(WHYNTER_HEADER_SPACE);
// Data + stop bit
sendPulseDistanceWidthData(WHYNTER_BIT_MARK, WHYNTER_ONE_SPACE, WHYNTER_BIT_MARK, WHYNTER_ZERO_SPACE, data, nbits,
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
IrReceiver.restartAfterSend();
}
//+=============================================================================
bool IRrecv::decodeWhynter() {
// Check we have the right amount of data (68). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != (2 * WHYNTER_BITS) + 4) {
return false;
}
// Sequence begins with a bit mark and a zero space
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], WHYNTER_BIT_MARK)
|| !matchSpace(decodedIRData.rawDataPtr->rawbuf[2], WHYNTER_HEADER_SPACE)) {
IR_DEBUG_PRINT(F("Whynter: "));
IR_DEBUG_PRINTLN(F("Header mark or space length is wrong"));
return false;
}
if (!decodePulseDistanceData(WHYNTER_BITS, 3, WHYNTER_BIT_MARK, WHYNTER_ONE_SPACE, WHYNTER_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST)) {
return false;
}
// trailing mark / stop bit
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[3 + (2 * WHYNTER_BITS)], WHYNTER_BIT_MARK)) {
IR_DEBUG_PRINTLN(F("Stop bit mark length is wrong"));
return false;
}
// Success
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST;
decodedIRData.numberOfBits = WHYNTER_BITS;
decodedIRData.protocol = WHYNTER;
return true;
}
/** @}*/
#endif // _IR_WHYNTER_HPP