Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,11 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Eurom decode");
if (decodeEurom(results, offset, kEuromBits)) return true;
#endif // DECODE_EUROM
#if DECODE_MITSUBISHI_HEAVY_64
DPRINTLN("Attempting Mitsubishi Heavy 64-bit decode");
if (decodeMitsubishiHeavy64(results, offset, kMitsubishiHeavy64Bits))
return true;
#endif // DECODE_MITSUBISHI_HEAVY_64
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down
6 changes: 6 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,12 @@ class IRrecv {
const uint16_t nbits = kEuromBits,
const bool strict = true);
#endif // DECODE_EUROM
#if DECODE_MITSUBISHI_HEAVY_64
bool decodeMitsubishiHeavy64(decode_results *results,
uint16_t offset = kStartOffset,
const uint16_t nbits = kMitsubishiHeavy64Bits,
const bool strict = true);
#endif // DECODE_MITSUBISHI_HEAVY_64
};

#endif // IRRECV_H_
15 changes: 13 additions & 2 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,13 @@ typedef volatile const uint16_t atomic_const_uint16_t;
#define SEND_EUROM _IR_ENABLE_DEFAULT_
#endif // SEND_EUROM

#ifndef DECODE_MITSUBISHI_HEAVY_64
#define DECODE_MITSUBISHI_HEAVY_64 _IR_ENABLE_DEFAULT_
#endif // DECODE_MITSUBISHI_HEAVY_64
#ifndef SEND_MITSUBISHI_HEAVY_64
#define SEND_MITSUBISHI_HEAVY_64 _IR_ENABLE_DEFAULT_
#endif // SEND_MITSUBISHI_HEAVY_64

#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
Expand All @@ -995,7 +1002,7 @@ typedef volatile const uint16_t atomic_const_uint16_t;
DECODE_DAIKIN200 || DECODE_HAIER_AC160 || DECODE_TCL96AC || \
DECODE_BOSCH144 || DECODE_SANYO_AC152 || DECODE_DAIKIN312 || \
DECODE_CARRIER_AC84 || DECODE_YORK || DECODE_BLUESTARHEAVY || \
DECODE_EUROM || \
DECODE_EUROM || DECODE_MITSUBISHI_HEAVY_64 || \
false)
// Add any DECODE to the above if it uses result->state (see kStateSizeMax)
// you might also want to add the protocol to hasACState function
Expand Down Expand Up @@ -1164,8 +1171,9 @@ enum decode_type_t {
YORK,
BLUESTARHEAVY,
EUROM,
MITSUBISHI_HEAVY_64, // 2262
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = EUROM,
kLastDecodeType = MITSUBISHI_HEAVY_64,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -1356,6 +1364,9 @@ const uint16_t kMitsubishiHeavy88MinRepeat = kNoRepeat;
const uint16_t kMitsubishiHeavy152StateLength = 19;
const uint16_t kMitsubishiHeavy152Bits = kMitsubishiHeavy152StateLength * 8;
const uint16_t kMitsubishiHeavy152MinRepeat = kNoRepeat;
const uint16_t kMitsubishiHeavy64StateLength = 8;
const uint16_t kMitsubishiHeavy64Bits = kMitsubishiHeavy64StateLength * 8;
const uint16_t kMitsubishiHeavy64MinRepeat = kNoRepeat;
const uint16_t kMultibracketsBits = 8;
const uint16_t kMultibracketsDefaultRepeat = kSingleRepeat;
const uint16_t kNikaiBits = 24;
Expand Down
7 changes: 7 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
return kDaikin64Bits;
case ELECTRA_AC:
return kElectraAcBits;
case MITSUBISHI_HEAVY_64:
return kMitsubishiHeavy64Bits;
case EUROM:
return kEuromBits;
case GREE:
Expand Down Expand Up @@ -1378,6 +1380,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
sendMitsubishiHeavy152(state, nbytes);
break;
#endif // SEND_MITSUBISHIHEAVY
#if SEND_MITSUBISHI_HEAVY_64
case MITSUBISHI_HEAVY_64:
sendMitsubishiHeavy64(state, nbytes);
break;
#endif // SEND_MITSUBISHI_HEAVY_64
#if SEND_MWM
case MWM:
sendMWM(state, nbytes);
Expand Down
6 changes: 6 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,12 @@ class IRsend {
const uint16_t nbytes = kEuromStateLength,
const uint16_t repeat = kNoRepeat);
#endif // SEND_EUROM
#if SEND_MITSUBISHI_HEAVY_64
void sendMitsubishiHeavy64(
const unsigned char data[],
const uint16_t nbytes = kMitsubishiHeavy64StateLength,
const uint16_t repeat = kNoRepeat);
#endif // SEND_MITSUBISHI_HEAVY_64

protected:
#ifdef UNIT_TEST
Expand Down
2 changes: 2 additions & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) {
D_STR_BLUESTARHEAVY, D_STR_UNSUPPORTED) "\x0"
COND(DECODE_EUROM || SEND_EUROM,
D_STR_EUROM, D_STR_UNSUPPORTED) "\x0"
COND(DECODE_MITSUBISHI_HEAVY_64 || SEND_MITSUBISHI_HEAVY_64,
D_STR_MITSUBISHI_HEAVY_64, D_STR_UNSUPPORTED) "\x0"
///< New protocol (macro) strings should be added just above this line.
"\x0" ///< This string requires double null termination.
};
Expand Down
1 change: 1 addition & 0 deletions src/IRutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ bool hasACState(const decode_type_t protocol) {
case MITSUBISHI136:
case MITSUBISHI112:
case MITSUBISHI_AC:
case MITSUBISHI_HEAVY_64:
case MITSUBISHI_HEAVY_88:
case MITSUBISHI_HEAVY_152:
case MWM:
Expand Down
82 changes: 82 additions & 0 deletions src/ir_MitsubishiHeavy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ const uint16_t kMitsubishiHeavyOneSpace = 420;
const uint16_t kMitsubishiHeavyZeroSpace = 1220;
const uint32_t kMitsubishiHeavyGap = kDefaultMessageGap; // Just a guess.

// Timing for the 64-bit "Jinling" variant (RYD502A003B remote).
// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/2262
const uint16_t kMitsubishiHeavy64HdrMark = 5950;
const uint16_t kMitsubishiHeavy64HdrSpace = 7475;
const uint16_t kMitsubishiHeavy64BitMark = 508;
const uint16_t kMitsubishiHeavy64OneSpace = 3454;
const uint16_t kMitsubishiHeavy64ZeroSpace = 1496;
// Measured gap between repeats. The raw captures end each frame with a trailing
// space of ~7422-7426us before the leading mark of the next repeat appears, so
// this is the real inter-message gap, not a guess. It happens to be ~the same
// as the header space (7475us); this remote uses a short gap between repeats.
const uint16_t kMitsubishiHeavy64Gap = 7422;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seem's awfully short for a gap for between messages. How was this calculated? Just checking?
e.g. how big a gap is there between repeats messages?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a guess — it's the measured gap between repeats. Each raw capture ends with a trailing space of ~7422–7426 µs, after which the leading mark of the next repeat appears, so the capture caught that leading edge and it isn't a timeout artifact. It is short because this remote uses a short inter-repeat gap — it's about the same as the header space (7475 µs).

Example tail of a Cool-18 °C capture: ..., 506, 3464, 506, 7424, 532 where 7424 is the inter-repeat gap and 532 is the start of the next frame. I've added a comment documenting this; the full raw dumps are in #2262.


using irutils::addBoolToString;
using irutils::addIntToString;
using irutils::addLabeledString;
Expand Down Expand Up @@ -70,6 +83,27 @@ void IRsend::sendMitsubishiHeavy152(const unsigned char data[],
}
#endif // SEND_MITSUBISHIHEAVY

#if SEND_MITSUBISHI_HEAVY_64
/// Send a MitsubishiHeavy 64-bit (RYD502A003B remote) A/C message.
/// Status: STABLE / Confirmed working with a real remote.
/// @param[in] data The message (8 bytes) to be sent.
/// @param[in] nbytes The number of bytes of message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
/// @note The whole frame is four inverted byte pairs, so it carries no
/// separate checksum byte. The bytes are sent LSB-first.
void IRsend::sendMitsubishiHeavy64(const unsigned char data[],
const uint16_t nbytes,
const uint16_t repeat) {
if (nbytes < kMitsubishiHeavy64StateLength)
return; // Not enough bytes to send a proper message.
sendGeneric(kMitsubishiHeavy64HdrMark, kMitsubishiHeavy64HdrSpace,
kMitsubishiHeavy64BitMark, kMitsubishiHeavy64OneSpace,
kMitsubishiHeavy64BitMark, kMitsubishiHeavy64ZeroSpace,
kMitsubishiHeavy64BitMark, kMitsubishiHeavy64Gap,
data, nbytes, 38000, false, repeat, kDutyDefault);
}
#endif // SEND_MITSUBISHI_HEAVY_64

// Class for decoding and constructing MitsubishiHeavy152 AC messages.

/// Class constructor
Expand Down Expand Up @@ -1048,3 +1082,51 @@ bool IRrecv::decodeMitsubishiHeavy(decode_results* results, uint16_t offset,
return true;
}
#endif // DECODE_MITSUBISHIHEAVY

#if DECODE_MITSUBISHI_HEAVY_64
/// Decode the supplied MitsubishiHeavy 64-bit (RYD502A003B remote) message.
/// Status: STABLE / Confirmed working with a real remote.
/// @param[in,out] results Ptr to the data to decode & where to store the decode
/// @param[in] offset The starting index to use when attempting to decode the
/// raw data. Typically/Defaults to kStartOffset.
/// @param[in] nbits The number of data bits to expect.
/// @param[in] strict Flag indicating if we should perform strict matching.
/// @return True if it can decode it, false if it can't.
/// @note Unlike the 88/152-bit variants, this frame is one block of four
/// inverted byte pairs: `FF 00 | B2 ~B2 | B4 ~B4 | 2A D5`.
bool IRrecv::decodeMitsubishiHeavy64(decode_results* results, uint16_t offset,
const uint16_t nbits, const bool strict) {
if (strict && nbits != kMitsubishiHeavy64Bits)
return false; // Not what is expected.

uint16_t used = matchGeneric(results->rawbuf + offset, results->state,
results->rawlen - offset, nbits,
kMitsubishiHeavy64HdrMark,
kMitsubishiHeavy64HdrSpace,
kMitsubishiHeavy64BitMark,
kMitsubishiHeavy64OneSpace,
kMitsubishiHeavy64BitMark,
kMitsubishiHeavy64ZeroSpace,
kMitsubishiHeavy64BitMark,
kMitsubishiHeavy64Gap, true,
_tolerance, 0, false);
if (used == 0) return false;

// Compliance
if (strict) {
// The whole frame is four inverted byte pairs (it has no separate
// checksum), so every second byte must be the complement of the first.
if (!checkInvertedBytePairs(results->state, kMitsubishiHeavy64StateLength))
return false;
// Fixed header & footer signature bytes. The pair check above implies
// state[1] == 0x00 and state[7] == 0xD5.
if (results->state[0] != 0xFF || results->state[6] != 0x2A) return false;
}

// Success
results->decode_type = MITSUBISHI_HEAVY_64;
results->bits = nbits;
// No need to record the state as we stored it as we decoded it.
return true;
}
#endif // DECODE_MITSUBISHI_HEAVY_64
3 changes: 3 additions & 0 deletions src/ir_MitsubishiHeavy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/660
/// @see https://github.com/ToniA/Raw-IR-decoder-for-Arduino/blob/master/MitsubishiHeavy.cpp
/// @see https://github.com/ToniA/arduino-heatpumpir/blob/master/MitsubishiHeavyHeatpumpIR.cpp
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/2262

// Supports:
// Brand: Mitsubishi Heavy Industries, Model: RLA502A700B remote (152 bit)
// Brand: Mitsubishi Heavy Industries, Model: SRKxxZM-S A/C (152 bit)
// Brand: Mitsubishi Heavy Industries, Model: SRKxxZMXA-S A/C (152 bit)
// Brand: Mitsubishi Heavy Industries, Model: RKX502A001C remote (88 bit)
// Brand: Mitsubishi Heavy Industries, Model: SRKxxZJ-S A/C (88 bit)
// Brand: Mitsubishi Heavy Industries, Model: RYD502A003B remote (64 bit)
// Brand: Mitsubishi Heavy Industries, Model: SRKxxAJ-S A/C (64 bit)

#ifndef IR_MITSUBISHIHEAVY_H_
#define IR_MITSUBISHIHEAVY_H_
Expand Down
3 changes: 3 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,9 @@ D_STR_INDIRECT " " D_STR_MODE
#ifndef D_STR_MITSUBISHI_HEAVY_88
#define D_STR_MITSUBISHI_HEAVY_88 "MITSUBISHI_HEAVY_88"
#endif // D_STR_MITSUBISHI_HEAVY_88
#ifndef D_STR_MITSUBISHI_HEAVY_64
#define D_STR_MITSUBISHI_HEAVY_64 "MITSUBISHI_HEAVY_64"
#endif // D_STR_MITSUBISHI_HEAVY_64
#ifndef D_STR_MULTIBRACKETS
#define D_STR_MULTIBRACKETS "MULTIBRACKETS"
#endif // D_STR_MULTIBRACKETS
Expand Down
Loading
Loading