Closes #728
This commit is contained in:
parent
78b4f8c40c
commit
476d224d39
|
@ -1,5 +1,6 @@
|
|||
## 2.8.2 2020/11
|
||||
- Added SendRaw with byte data.
|
||||
- Fixed resume bug if irparams.rawlen >= RAW_BUFFER_LENGTH. Thanks to Iosif Peterfi
|
||||
|
||||
## 2.8.1 2020/10
|
||||
- Fixed bug in Sony decode introduced in 2.8.0.
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
// Define exactly one of these
|
||||
//#define VAR_IN_PROGMEM
|
||||
#define VAR_IN_MEM
|
||||
//#define USE_F_FORM
|
||||
// Comment this out if you to send from FLASH
|
||||
#define VAR_IN_PROGMEM
|
||||
|
||||
#define TIMES_TO_SEND 10U
|
||||
|
||||
#include <IRremote.h>
|
||||
|
||||
const char yamahaVolDown[]
|
||||
#ifdef VAR_IN_PROGMEM
|
||||
PROGMEM
|
||||
#if defined(VAR_IN_PROGMEM) && HAS_FLASH_READ
|
||||
PROGMEM
|
||||
#endif
|
||||
= "0000 006C 0022 0002 "
|
||||
= "0000 006C 0022 0002 "
|
||||
"015B 00AD 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 "
|
||||
"0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 "
|
||||
"0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 05F7 015B 0057 0016 0E6C";
|
||||
|
@ -32,20 +30,35 @@ void setup() {
|
|||
|
||||
void loop() {
|
||||
|
||||
|
||||
#ifdef VAR_IN_PROGMEM
|
||||
#if defined(VAR_IN_PROGMEM) && HAS_FLASH_READ
|
||||
Serial.println(F("Sending from PROGMEM"));
|
||||
irsend.sendPronto_PF(yamahaVolDown, TIMES_TO_SEND);
|
||||
#elif defined(VAR_IN_MEM)
|
||||
#else
|
||||
Serial.println(F("Sending from normal memory"));
|
||||
irsend.sendPronto(yamahaVolDown, TIMES_TO_SEND);
|
||||
#else
|
||||
Serial.println(F("Sending using the F()-form"));
|
||||
irsend.sendPronto(F("0000 006C 0022 0002 "
|
||||
"015B 00AD 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 "
|
||||
"0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 "
|
||||
"0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 05F7 015B 0057 0016 0E6C"), TIMES_TO_SEND);
|
||||
#endif
|
||||
|
||||
delay(2000);
|
||||
#if HAS_FLASH_READ
|
||||
Serial.println(F("Sending Yamaha (Nec) using the F()-form"));
|
||||
irsend.sendPronto(
|
||||
F(
|
||||
"0000 006C 0022 0002 "
|
||||
"015B 00AD 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 "
|
||||
"0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 "
|
||||
"0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 05F7 015B 0057 0016 0E6C"),
|
||||
TIMES_TO_SEND);
|
||||
delay(2000);
|
||||
#endif
|
||||
|
||||
// send Nec code aquired by IRreceiveDumpV2.cpp
|
||||
Serial.println(F("Sending Nec: address 0xFF00, data 0x15"));
|
||||
// 006D -> 38029 Hz
|
||||
irsend.sendPronto(
|
||||
"0000 006D 0022 0000 015C 00AB 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 0017 0015 "
|
||||
"0017 003F 0017 003E 0017 003F 0017 003E 0017 003F 0015 003F 0017 003F 0015 003F 0017 003E 0017 0015 0017 003F 0017 0015 0017 "
|
||||
"003E 0017 0015 0017 0017 0015 0017 0017 0015 0017 003E 0017 0015 0017 003F 0015 0017 0017 003E 0017 003F 0015 003F 0017 0806",
|
||||
1); // no repeats
|
||||
|
||||
delay(5000);
|
||||
}
|
||||
|
|
|
@ -128,15 +128,9 @@ ISR (TIMER_INTR_NAME) {
|
|||
TIMER_RESET_INTR_PENDING; // reset timer interrupt flag if required (currently only for Teensy and ATmega4809)
|
||||
|
||||
// Read if IR Receiver -> SPACE [xmt LED off] or a MARK [xmt LED on]
|
||||
// digitalRead() is very slow. Optimisation is possible, but makes the code unportable
|
||||
uint8_t irdata = (uint8_t) digitalRead(irparams.recvpin);
|
||||
|
||||
irparams.timer++; // One more 50uS tick
|
||||
if (irparams.rawlen >= RAW_BUFFER_LENGTH) {
|
||||
// Flag up a read overflow; Stop the State Machine
|
||||
irparams.overflow = true;
|
||||
irparams.rcvstate = IR_REC_STATE_STOP;
|
||||
}
|
||||
|
||||
/*
|
||||
* Due to a ESP32 compiler bug https://github.com/espressif/esp-idf/issues/1552 no switch statements are possible for ESP32
|
||||
|
@ -158,7 +152,20 @@ ISR (TIMER_INTR_NAME) {
|
|||
irparams.rcvstate = IR_REC_STATE_MARK;
|
||||
}
|
||||
}
|
||||
} else if (irparams.rcvstate == IR_REC_STATE_MARK) { // Timing Mark
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we detected a start mark and record the signal
|
||||
*/
|
||||
// First check for buffer overflow
|
||||
if (irparams.rawlen >= RAW_BUFFER_LENGTH) {
|
||||
// Flag up a read overflow; Stop the State Machine
|
||||
irparams.overflow = true;
|
||||
irparams.rcvstate = IR_REC_STATE_STOP;
|
||||
}
|
||||
|
||||
// record marks and spaces and detect end of code
|
||||
if (irparams.rcvstate == IR_REC_STATE_MARK) { // Timing Mark
|
||||
if (irdata == SPACE) { // Mark ended; Record time
|
||||
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
|
||||
irparams.timer = 0;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* @file irPronto.cpp
|
||||
* @brief In this file, the functions IRrecv::dumpPronto and
|
||||
* IRsend::sendPronto are defined.
|
||||
* See http://www.harctoolbox.org/Glossary.html#ProntoSemantics
|
||||
*/
|
||||
|
||||
#include "IRremote.h"
|
||||
|
@ -23,6 +24,9 @@ static unsigned int toFrequencyKHz(uint16_t code) {
|
|||
return ((referenceFrequency / code) + 500) / 1000;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the string given as Pronto Hex, and send it a number of times given as argument.
|
||||
*/
|
||||
void IRsend::sendPronto(const uint16_t *data, unsigned int size, unsigned int times) {
|
||||
unsigned int timebase = (microsecondsInSeconds * data[1] + referenceFrequency / 2) / referenceFrequency;
|
||||
unsigned int khz;
|
||||
|
@ -38,8 +42,9 @@ void IRsend::sendPronto(const uint16_t *data, unsigned int size, unsigned int ti
|
|||
}
|
||||
unsigned int intros = 2 * data[2];
|
||||
unsigned int repeats = 2 * data[3];
|
||||
if (numbersInPreamble + intros + repeats != size) // inconsistent sizes
|
||||
if (numbersInPreamble + intros + repeats != size) { // inconsistent sizes
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t durations[intros + repeats];
|
||||
for (unsigned int i = 0; i < intros + repeats; i++) {
|
||||
|
@ -48,17 +53,26 @@ void IRsend::sendPronto(const uint16_t *data, unsigned int size, unsigned int ti
|
|||
}
|
||||
|
||||
unsigned int numberRepeats = intros > 0 ? times - 1 : times;
|
||||
if (intros > 0) {
|
||||
|
||||
/*
|
||||
* Send the intro. intros is even.
|
||||
* Do not send the trailing space here, send it if repeats are requested
|
||||
*/
|
||||
if (intros >= 2) {
|
||||
sendRaw(durations, intros - 1, khz);
|
||||
}
|
||||
|
||||
if (numberRepeats == 0)
|
||||
if (repeats == 0 || numberRepeats == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
delay(durations[intros - 1] / 1000U);
|
||||
/*
|
||||
* Now send the trailing space/gap of the intro and all the repeats
|
||||
*/
|
||||
delay(durations[intros - 1] / 1000U); // equivalent to space(durations[intros - 1]); but allow bigger values for the gap
|
||||
for (unsigned int i = 0; i < numberRepeats; i++) {
|
||||
sendRaw(durations + intros, repeats - 1, khz);
|
||||
if (i < numberRepeats - 1) { // skip last wait
|
||||
sendRaw(&durations[0] + intros, repeats - 1, khz);
|
||||
if (i < numberRepeats - 1) { // skip last trailing space/gap, see above
|
||||
delay(durations[intros + repeats - 1] / 1000U);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +107,6 @@ void IRsend::sendPronto_PF(uint_farptr_t str, unsigned int times) {
|
|||
void IRsend::sendPronto_PF(const char *str, unsigned int times) {
|
||||
sendPronto_PF(reinterpret_cast<uint_farptr_t>(str), times); // to avoid infinite recursion
|
||||
}
|
||||
;
|
||||
|
||||
void IRsend::sendPronto(const __FlashStringHelper *str, unsigned int times) {
|
||||
return sendPronto_PF(reinterpret_cast<uint_farptr_t>(str), times);
|
||||
|
@ -157,7 +170,8 @@ void IRrecv::dumpPronto(Print *aSerial, unsigned int frequency) {
|
|||
// I know Stream * is locally inconsistent, but all global print functions use it
|
||||
//
|
||||
void IRrecv::printIRResultAsPronto(Print *aSerial, unsigned int frequency) {
|
||||
aSerial->print("Pronto Hex: ");
|
||||
aSerial->println("Pronto Hex as string");
|
||||
aSerial->print("char ProntoData[] = \"");
|
||||
dumpPronto(aSerial, frequency);
|
||||
aSerial->println();
|
||||
aSerial->println("\"");
|
||||
}
|
||||
|
|
|
@ -248,7 +248,6 @@ bool IRrecv::available() {
|
|||
//
|
||||
void IRrecv::resume() {
|
||||
irparams.rcvstate = IR_REC_STATE_IDLE;
|
||||
// irparams.rawlen = 0; // not required
|
||||
}
|
||||
|
||||
# if DECODE_HASH
|
||||
|
@ -510,7 +509,7 @@ void IRrecv::printIRResultRaw(Print *aSerial, bool aOutputMicrosecondsInsteadOfT
|
|||
for (int i = 0; i < count; i++) {
|
||||
uint32_t tDurationMicros;
|
||||
if (aOutputMicrosecondsInsteadOfTicks) {
|
||||
tDurationMicros = results.rawbuf[i] * (uint32_t)MICROS_PER_TICK;
|
||||
tDurationMicros = results.rawbuf[i] * (uint32_t) MICROS_PER_TICK;
|
||||
} else {
|
||||
tDurationMicros = results.rawbuf[i];
|
||||
}
|
||||
|
@ -560,7 +559,7 @@ void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsI
|
|||
aSerial->print(" ");
|
||||
}
|
||||
aSerial->print(tDurationMicros, DEC);
|
||||
if (i < results.rawlen - 1) {
|
||||
if (i + 1 < results.rawlen) {
|
||||
aSerial->print(", "); //',' not required for last one
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +597,7 @@ void IRrecv::printIRResultAsCArray(Print *aSerial, bool aOutputMicrosecondsInste
|
|||
} else {
|
||||
aSerial->print(results.rawbuf[i]);
|
||||
}
|
||||
if (i < results.rawlen - 1)
|
||||
if (i + 1 < results.rawlen)
|
||||
aSerial->print(","); // ',' not required on last one
|
||||
if (!(i & 1))
|
||||
aSerial->print(" ");
|
||||
|
|
|
@ -112,7 +112,7 @@ bool IRrecv::decodeBoseWave() {
|
|||
DBG_PRINTLN("Decoding Bose Wave ...");
|
||||
|
||||
// Check we have enough data
|
||||
if (irparams.rawlen < (2 * BOSEWAVE_BITS * 2) + 3) {
|
||||
if (results.rawlen < (2 * BOSEWAVE_BITS * 2) + 3) {
|
||||
DBG_PRINT("\tInvalid data length found: ");
|
||||
DBG_PRINTLN(results.rawlen);
|
||||
return false;
|
||||
|
|
|
@ -22,7 +22,7 @@ bool IRrecv::decodeLG() {
|
|||
int offset = 1; // Skip first space
|
||||
|
||||
// Check we have the right amount of data +3 for start bit mark and space + stop bit mark
|
||||
if (irparams.rawlen <= (2 * LG_BITS) + 3)
|
||||
if (results.rawlen <= (2 * LG_BITS) + 3)
|
||||
return false;
|
||||
|
||||
// Initial mark/space
|
||||
|
|
|
@ -64,7 +64,7 @@ bool IRrecv::decodeLegoPowerFunctions() {
|
|||
unsigned long data = 0; // Somewhere to build our code
|
||||
DBG_PRINTLN(results.rawlen, DEC);
|
||||
// Check we have the right amount of data
|
||||
if (irparams.rawlen != (2 * LEGO_PF_BITS) + 4)
|
||||
if (results.rawlen != (2 * LEGO_PF_BITS) + 4)
|
||||
return false;
|
||||
|
||||
DBG_PRINTLN("Attempting Lego Power Functions Decode");
|
||||
|
|
|
@ -49,7 +49,7 @@ bool IRrecv::decodeSAMSUNG() {
|
|||
offset++;
|
||||
|
||||
// Check for repeat
|
||||
if ((irparams.rawlen == 4) && MATCH_SPACE(results.rawbuf[offset], SAMSUNG_REPEAT_SPACE)
|
||||
if ((results.rawlen == 4) && MATCH_SPACE(results.rawbuf[offset], SAMSUNG_REPEAT_SPACE)
|
||||
&& MATCH_MARK(results.rawbuf[offset + 1], SAMSUNG_BIT_MARK)) {
|
||||
results.bits = 0;
|
||||
results.value = REPEAT;
|
||||
|
@ -57,7 +57,7 @@ bool IRrecv::decodeSAMSUNG() {
|
|||
results.decode_type = SAMSUNG;
|
||||
return true;
|
||||
}
|
||||
if (irparams.rawlen < (2 * SAMSUNG_BITS) + 4) {
|
||||
if (results.rawlen < (2 * SAMSUNG_BITS) + 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ bool IRrecv::decodeSanyo() {
|
|||
}
|
||||
offset++;
|
||||
|
||||
while (offset + 1 < irparams.rawlen) {
|
||||
while (offset + 1 < results.rawlen) {
|
||||
if (!MATCH_SPACE(results.rawbuf[offset], SANYO_HEADER_SPACE)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -101,9 +101,9 @@ bool IRrecv::decodeSharp() {
|
|||
// Check we have the right amount of data
|
||||
// Either one burst or three where second is inverted
|
||||
// The setting #define _GAP 5000 in IRremoteInt.h will give one burst and possibly three calls to this function
|
||||
if (irparams.rawlen == (SHARP_BITS + 1) * 2)
|
||||
if (results.rawlen == (SHARP_BITS + 1) * 2)
|
||||
loops = 1;
|
||||
else if (irparams.rawlen == (SHARP_BITS + 1) * 2 * 3)
|
||||
else if (results.rawlen == (SHARP_BITS + 1) * 2 * 3)
|
||||
loops = 3;
|
||||
else
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue