Ir esp8266 lib update and code impacts (#235)
* integrate new IRremoteESP8266 lib 2.4.2 and add new protocols IR_RC6 IR_MITSUBISHI IR_GICABLE IR_MITSUBISHI2 IR_LASERTAG IR_CARRIER_AC IR_MIDEA IR_NIKAI IR_SHERWOOD IR_DENON IR_AIWA_RC_T501 IR_JVC
This commit is contained in:
1 parent
9b258723a8
commit
b12ee19979
130 files changed
+16548
-1693
No files matched your search
@@ -5,7 +5,6 @@
|
||||
#include <algorithm>
|
||||
#include "IRrecv.h"
|
||||
#include "IRsend.h"
|
||||
#include "IRtimer.h"
|
||||
#include "IRutils.h"
|
||||
|
||||
// MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
|
||||
@@ -40,6 +39,16 @@
|
||||
#define MITSUBISHI_MIN_GAP (MITSUBISHI_MIN_GAP_TICKS * \
|
||||
MITSUBISHI_TICK)
|
||||
|
||||
// Mitsubishi Projector (HC3000)
|
||||
// Ref:
|
||||
// https://github.com/markszabo/IRremoteESP8266/issues/441
|
||||
#define MITSUBISHI2_HDR_MARK 8400U
|
||||
#define MITSUBISHI2_HDR_SPACE (MITSUBISHI2_HDR_MARK / 2)
|
||||
#define MITSUBISHI2_BIT_MARK 560U
|
||||
#define MITSUBISHI2_ZERO_SPACE 520U
|
||||
#define MITSUBISHI2_ONE_SPACE (MITSUBISHI2_ZERO_SPACE * 3)
|
||||
#define MITSUBISHI2_MIN_GAP 28500U
|
||||
|
||||
// Mitsubishi A/C
|
||||
// Ref:
|
||||
// https://github.com/r45635/HVAC-IR-Control/blob/master/HVAC_ESP8266/HVAC_ESP8266.ino#L84
|
||||
@@ -67,24 +76,14 @@
|
||||
// https://github.com/marcosamarinho/IRremoteESP8266/blob/master/ir_Mitsubishi.cpp
|
||||
// GlobalCache's Control Tower's Mitsubishi TV data.
|
||||
void IRsend::sendMitsubishi(uint64_t data, uint16_t nbits, uint16_t repeat) {
|
||||
enableIROut(33); // Set IR carrier frequency
|
||||
IRtimer usecTimer = IRtimer();
|
||||
|
||||
for (uint16_t i = 0; i <= repeat; i++) {
|
||||
usecTimer.reset();
|
||||
// No header
|
||||
|
||||
// Data
|
||||
sendData(MITSUBISHI_BIT_MARK, MITSUBISHI_ONE_SPACE,
|
||||
MITSUBISHI_BIT_MARK, MITSUBISHI_ZERO_SPACE,
|
||||
data, nbits, true);
|
||||
// Footer
|
||||
mark(MITSUBISHI_BIT_MARK);
|
||||
space(std::max(MITSUBISHI_MIN_COMMAND_LENGTH - usecTimer.elapsed(),
|
||||
MITSUBISHI_MIN_GAP));
|
||||
}
|
||||
sendGeneric(0, 0, // No Header
|
||||
MITSUBISHI_BIT_MARK, MITSUBISHI_ONE_SPACE,
|
||||
MITSUBISHI_BIT_MARK, MITSUBISHI_ZERO_SPACE,
|
||||
MITSUBISHI_BIT_MARK, MITSUBISHI_MIN_GAP,
|
||||
MITSUBISHI_MIN_COMMAND_LENGTH,
|
||||
data, nbits, 33, true, repeat, 50);
|
||||
}
|
||||
#endif
|
||||
#endif // SEND_MITSUBISHI
|
||||
|
||||
#if DECODE_MITSUBISHI
|
||||
// Decode the supplied Mitsubishi message.
|
||||
@@ -152,7 +151,122 @@ bool IRrecv::decodeMitsubishi(decode_results *results, uint16_t nbits,
|
||||
results->command = 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif // DECODE_MITSUBISHI
|
||||
|
||||
#if SEND_MITSUBISHI2
|
||||
// Send a Mitsubishi2 message
|
||||
//
|
||||
// Args:
|
||||
// data: Contents of the message to be sent.
|
||||
// nbits: Nr. of bits of data to be sent. Typically MITSUBISHI_BITS.
|
||||
// repeat: Nr. of additional times the message is to be sent.
|
||||
//
|
||||
// Status: ALPHA / untested.
|
||||
//
|
||||
// Notes:
|
||||
// Based on a Mitsubishi HC3000 projector's remote.
|
||||
// This protocol appears to have a manditory in-protocol repeat.
|
||||
// That is in *addition* to the entire message needing to be sent twice
|
||||
// for the device to accept the command. That is separate from the repeat.
|
||||
// i.e. Allegedly, the real remote requires the "OFF" button pressed twice.
|
||||
// You will need to add a suitable gap yourself.
|
||||
// Ref:
|
||||
// https://github.com/markszabo/IRremoteESP8266/issues/441
|
||||
void IRsend::sendMitsubishi2(uint64_t data, uint16_t nbits, uint16_t repeat) {
|
||||
for (uint16_t i = 0; i <= repeat; i++) {
|
||||
// First half of the data.
|
||||
sendGeneric(MITSUBISHI2_HDR_MARK, MITSUBISHI2_HDR_SPACE,
|
||||
MITSUBISHI2_BIT_MARK, MITSUBISHI2_ONE_SPACE,
|
||||
MITSUBISHI2_BIT_MARK, MITSUBISHI2_ZERO_SPACE,
|
||||
MITSUBISHI2_BIT_MARK, MITSUBISHI2_HDR_SPACE,
|
||||
data >> (nbits / 2), nbits / 2, 33, true, 0, 50);
|
||||
// Second half of the data.
|
||||
sendGeneric(0, 0, // No header for the second data block
|
||||
MITSUBISHI2_BIT_MARK, MITSUBISHI2_ONE_SPACE,
|
||||
MITSUBISHI2_BIT_MARK, MITSUBISHI2_ZERO_SPACE,
|
||||
MITSUBISHI2_BIT_MARK, MITSUBISHI2_MIN_GAP,
|
||||
data & ((1 << (nbits / 2)) - 1), nbits / 2, 33, true, 0, 50);
|
||||
}
|
||||
}
|
||||
#endif // SEND_MITSUBISHI2
|
||||
|
||||
#if DECODE_MITSUBISHI2
|
||||
// Decode the supplied Mitsubishi2 message.
|
||||
//
|
||||
// Args:
|
||||
// results: Ptr to the data to decode and where to store the decode result.
|
||||
// nbits: Nr. of data bits to expect.
|
||||
// strict: Flag indicating if we should perform strict matching.
|
||||
// Returns:
|
||||
// boolean: True if it can decode it, false if it can't.
|
||||
//
|
||||
// Status: BETA / Works with simulated data.
|
||||
//
|
||||
// Notes:
|
||||
// Hardware supported:
|
||||
// * Mitsubishi HC3000 projector's remote.
|
||||
//
|
||||
// Ref:
|
||||
// https://github.com/markszabo/IRremoteESP8266/issues/441
|
||||
bool IRrecv::decodeMitsubishi2(decode_results *results, uint16_t nbits,
|
||||
bool strict) {
|
||||
if (results->rawlen < 2 * nbits + HEADER + (FOOTER * 2) - 1)
|
||||
return false; // Shorter than shortest possibly expected.
|
||||
if (strict && nbits != MITSUBISHI_BITS)
|
||||
return false; // Request is out of spec.
|
||||
|
||||
uint16_t offset = OFFSET_START;
|
||||
uint64_t data = 0;
|
||||
uint16_t actualBits = 0;
|
||||
|
||||
// Header
|
||||
if (!matchMark(results->rawbuf[offset++], MITSUBISHI2_HDR_MARK))
|
||||
return false;
|
||||
if (!matchSpace(results->rawbuf[offset++], MITSUBISHI2_HDR_SPACE))
|
||||
return false;
|
||||
for (uint8_t i = 1; i <= 2; i++) {
|
||||
// Data
|
||||
match_result_t data_result = matchData(&(results->rawbuf[offset]),
|
||||
nbits / 2,
|
||||
MITSUBISHI2_BIT_MARK,
|
||||
MITSUBISHI2_ONE_SPACE,
|
||||
MITSUBISHI2_BIT_MARK,
|
||||
MITSUBISHI2_ZERO_SPACE);
|
||||
if (data_result.success == false) return false;
|
||||
data <<= nbits / 2;
|
||||
data += data_result.data;
|
||||
offset += data_result.used;
|
||||
actualBits += data_result.used / 2;
|
||||
|
||||
// Footer
|
||||
if (!matchMark(results->rawbuf[offset++], MITSUBISHI2_BIT_MARK))
|
||||
return false;
|
||||
if (i % 2) { // Every odd data block, we expect a HDR space.
|
||||
if (!matchSpace(results->rawbuf[offset++], MITSUBISHI2_HDR_SPACE))
|
||||
return false;
|
||||
} else { // Every even data block, we expect Min Gap or end of the message.
|
||||
if (offset < results->rawlen &&
|
||||
!matchAtLeast(results->rawbuf[offset++], MITSUBISHI2_MIN_GAP))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Compliance
|
||||
if (actualBits < nbits)
|
||||
return false;
|
||||
if (strict && actualBits != nbits)
|
||||
return false; // Not as we expected.
|
||||
|
||||
// Success
|
||||
results->decode_type = MITSUBISHI2;
|
||||
results->bits = actualBits;
|
||||
results->value = data;
|
||||
results->address = data >> actualBits / 2;
|
||||
results->command = data & ((1 << (actualBits / 2)) - 1);
|
||||
return true;
|
||||
}
|
||||
#endif // DECODE_MITSUBISHI2
|
||||
|
||||
#if SEND_MITSUBISHI_AC
|
||||
// Send a Mitsubishi A/C message.
|
||||
@@ -170,23 +284,13 @@ void IRsend::sendMitsubishiAC(unsigned char data[], uint16_t nbytes,
|
||||
if (nbytes < MITSUBISHI_AC_STATE_LENGTH)
|
||||
return; // Not enough bytes to send a proper message.
|
||||
|
||||
// Set IR carrier frequency
|
||||
enableIROut(38);
|
||||
// Mitsubishi AC remote sends the packet twice.
|
||||
for (uint16_t r = 0; r <= repeat; r++) {
|
||||
// Header
|
||||
mark(MITSUBISHI_AC_HDR_MARK);
|
||||
space(MITSUBISHI_AC_HDR_SPACE);
|
||||
// Data
|
||||
for (uint16_t i = 0; i < nbytes; i++)
|
||||
sendData(MITSUBISHI_AC_BIT_MARK, MITSUBISHI_AC_ONE_SPACE,
|
||||
MITSUBISHI_AC_BIT_MARK, MITSUBISHI_AC_ZERO_SPACE,
|
||||
data[i], 8, false);
|
||||
// Footer
|
||||
mark(MITSUBISHI_AC_RPT_MARK);
|
||||
space(MITSUBISHI_AC_RPT_SPACE);
|
||||
}
|
||||
sendGeneric(MITSUBISHI_AC_HDR_MARK, MITSUBISHI_AC_HDR_SPACE,
|
||||
MITSUBISHI_AC_BIT_MARK, MITSUBISHI_AC_ONE_SPACE,
|
||||
MITSUBISHI_AC_BIT_MARK, MITSUBISHI_AC_ZERO_SPACE,
|
||||
MITSUBISHI_AC_RPT_MARK, MITSUBISHI_AC_RPT_SPACE,
|
||||
data, nbytes, 38, false, repeat, 50);
|
||||
}
|
||||
#endif // SEND_MITSUBISHI_AC
|
||||
|
||||
// Code to emulate Mitsubishi A/C IR remote control unit.
|
||||
// Inspired and derived from the work done at:
|
||||
@@ -232,11 +336,13 @@ void IRMitsubishiAC::begin() {
|
||||
_irsend.begin();
|
||||
}
|
||||
|
||||
#if SEND_MITSUBISHI_AC
|
||||
// Send the current desired state to the IR LED.
|
||||
void IRMitsubishiAC::send() {
|
||||
checksum(); // Ensure correct checksum before sending.
|
||||
_irsend.sendMitsubishiAC(remote_state);
|
||||
}
|
||||
#endif // SEND_MITSUBISHI_AC
|
||||
|
||||
// Return a pointer to the internal state date of the remote.
|
||||
uint8_t* IRMitsubishiAC::getRaw() {
|
||||
@@ -346,4 +452,3 @@ void IRMitsubishiAC::setVane(uint8_t mode) {
|
||||
uint8_t IRMitsubishiAC::getVane() {
|
||||
return ((remote_state[9] & 0b00111000) >> 3);
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user