Skip to content

Commit

Permalink
MitsubishiAC: Tweak repeat gap timing. (#1760)
Browse files Browse the repository at this point in the history
* Update supported devices
* Decrease gap between repeat messages by 1.6ms to improve capture of messages.
* Add/update unit tests accordingly.

Fixes #1759
  • Loading branch information
crankyoldgit authored Feb 15, 2022
1 parent 8b1bfc3 commit 789b926
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ir_Mitsubishi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const uint16_t kMitsubishiAcBitMark = 450;
const uint16_t kMitsubishiAcOneSpace = 1300;
const uint16_t kMitsubishiAcZeroSpace = 420;
const uint16_t kMitsubishiAcRptMark = 440;
const uint16_t kMitsubishiAcRptSpace = 17100;
const uint16_t kMitsubishiAcRptSpace = 15500;
const uint8_t kMitsubishiAcExtraTolerance = 5;

// Mitsubishi 136 bit A/C
Expand Down
1 change: 1 addition & 0 deletions src/ir_Mitsubishi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// Brand: Mitsubishi Electric, Model: SG15D remote (MITSUBISHI_AC)
// Brand: Mitsubishi Electric, Model: MSZ-ZW4017S A/C (MITSUBISHI_AC)
// Brand: Mitsubishi Electric, Model: MSZ-FHnnVE A/C (MITSUBISHI_AC)
// Brand: Mitsubishi Electric, Model: RH151 remote (MITSUBISHI_AC)

#ifndef IR_MITSUBISHI_H_
#define IR_MITSUBISHI_H_
Expand Down
91 changes: 81 additions & 10 deletions test/ir_Mitsubishi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ TEST(TestSendMitsubishiAC, SendDataOnly) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m440s17100"
"m440s15500"
"m3400s1750"
"m450s1300m450s1300m450s420m450s420m450s420m450s1300m450s420m450s420"
"m450s1300m450s1300m450s420m450s1300m450s420m450s420m450s1300m450s1300"
Expand All @@ -373,7 +373,7 @@ TEST(TestSendMitsubishiAC, SendDataOnly) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m440s17100",
"m440s15500",
irsend.outputStr());
}

Expand Down Expand Up @@ -409,7 +409,7 @@ TEST(TestSendMitsubishiAC, SendWithRepeats) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m440s17100",
"m440s15500",
irsend.outputStr());

irsend.reset();
Expand All @@ -435,7 +435,7 @@ TEST(TestSendMitsubishiAC, SendWithRepeats) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m440s17100"
"m440s15500"
"m3400s1750"
"m450s1300m450s1300m450s420m450s420m450s420m450s1300m450s420m450s420"
"m450s1300m450s1300m450s420m450s1300m450s420m450s420m450s1300m450s1300"
Expand All @@ -455,7 +455,7 @@ TEST(TestSendMitsubishiAC, SendWithRepeats) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m440s17100"
"m440s15500"
"m3400s1750"
"m450s1300m450s1300m450s420m450s420m450s420m450s1300m450s420m450s420"
"m450s1300m450s1300m450s420m450s1300m450s420m450s420m450s1300m450s1300"
Expand All @@ -475,7 +475,7 @@ TEST(TestSendMitsubishiAC, SendWithRepeats) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m440s17100",
"m440s15500",
irsend.outputStr());
}

Expand Down Expand Up @@ -518,7 +518,7 @@ TEST(TestSendMitsubishiAC, SendUnexpectedSizes) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m440s17100"
"m440s15500"
"m3400s1750"
"m450s1300m450s1300m450s420m450s420m450s420m450s1300m450s420m450s420"
"m450s1300m450s1300m450s420m450s1300m450s420m450s420m450s1300m450s1300"
Expand All @@ -539,7 +539,7 @@ TEST(TestSendMitsubishiAC, SendUnexpectedSizes) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s1300m450s1300m450s1300m450s1300m450s1300m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m440s17100",
"m440s15500",
irsend.outputStr());
}

Expand Down Expand Up @@ -751,7 +751,7 @@ TEST(TestMitsubishiACClass, MessageConstuction) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s1300m450s420m450s420m450s420"
"m450s420m450s1300m450s1300m450s1300m450s1300m450s420m450s1300m450s420"
"m440s17100"
"m440s15500"
"m3400s1750"
"m450s1300m450s1300m450s420m450s420m450s420m450s1300m450s420m450s420"
"m450s1300m450s1300m450s420m450s1300m450s420m450s420m450s1300m450s1300"
Expand All @@ -771,7 +771,7 @@ TEST(TestMitsubishiACClass, MessageConstuction) {
"m450s420m450s420m450s420m450s420m450s420m450s420m450s420m450s420"
"m450s420m450s420m450s420m450s420m450s1300m450s420m450s420m450s420"
"m450s420m450s1300m450s1300m450s1300m450s1300m450s420m450s1300m450s420"
"m440s17100",
"m440s15500",
irsend.outputStr());
}

Expand Down Expand Up @@ -1712,3 +1712,74 @@ TEST(TestMitsubishiACClass, WeeklyTimerEnabled) {
ac.setRaw(weekly_off);
EXPECT_FALSE(ac.getWeeklyTimerEnabled());
}

// Decode a 'real' example for a MLZ-RX5017AS A/C
TEST(TestDecodeMitsubishiAC, Issue1759) {
IRsendTest irsend(kGpioUnused);
IRrecv irrecv(kGpioUnused);
irsend.begin();

irsend.reset();
const uint16_t rawData[583] = {
3392, 1638, 456, 1220, 456, 1220, 456, 382, 454, 382, 456, 380, 456, 1222,
454, 380, 456, 382, 456, 1220, 456, 1220, 456, 382, 454, 1222, 454, 382,
456, 384, 454, 1222, 454, 1220, 454, 382, 456, 1220, 456, 1220, 456, 382,
456, 382, 456, 1220, 456, 380, 456, 382, 456, 1220, 456, 380, 456, 382,
456, 382, 456, 380, 456, 382, 456, 380, 458, 382, 456, 380, 456, 382, 456,
382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382,
456, 380, 458, 382, 456, 380, 456, 1220, 456, 380, 456, 382, 456, 382,
456, 382, 456, 382, 456, 1220, 456, 382, 456, 382, 456, 382, 456, 380,
456, 382, 456, 382, 456, 1220, 456, 382, 456, 382, 456, 382, 456, 382,
454, 382, 456, 382, 456, 382, 456, 382, 454, 384, 454, 382, 456, 380, 456,
382, 456, 382, 456, 382, 456, 382, 454, 382, 456, 382, 456, 382, 456, 382,
456, 1222, 454, 1220, 456, 382, 456, 382, 456, 382, 454, 1220, 456, 1220,
454, 1222, 454, 1220, 454, 382, 456, 382, 456, 382, 454, 382, 454, 382,
456, 382, 456, 382, 456, 382, 454, 382, 456, 380, 456, 382, 454, 382, 454,
384, 454, 382, 456, 382, 454, 384, 454, 382, 456, 382, 456, 382, 456, 384,
454, 384, 454, 382, 456, 382, 454, 382, 454, 384, 454, 382, 456, 1220,
456, 382, 456, 382, 454, 382, 456, 382, 456, 382, 454, 1220, 456, 382,
456, 382, 456, 382, 456, 382, 454, 382, 456, 382, 456, 382, 454, 382, 456,
382, 454, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382,
454, 1220, 456, 1220, 456, 380, 456, 1220, 456, 1220, 456, 1222, 454,
1220, 456, 1220, 456, 11280,
3392, 1638, 454, 1220, 456, 1220, 456, 382, 456, 382, 456, 382, 456, 1220,
456, 380, 456, 382, 456, 1220, 456, 1220, 454, 382, 456, 1220, 456, 382,
456, 382, 456, 1220, 456, 1222, 454, 382, 456, 1220, 456, 1220, 454, 382,
456, 382, 456, 1220, 454, 382, 456, 382, 456, 1220, 456, 382, 456, 382,
454, 382, 456, 382, 454, 382, 456, 382, 456, 382, 456, 382, 456, 382, 454,
382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 454, 382,
456, 382, 456, 382, 456, 382, 456, 1220, 456, 382, 456, 382, 456, 382,
454, 382, 456, 382, 456, 1220, 456, 380, 456, 382, 456, 382, 456, 382,
456, 382, 456, 382, 456, 1220, 456, 382, 454, 382, 456, 382, 454, 382,
456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 380, 456, 382, 456,
380, 456, 382, 456, 382, 456, 382, 454, 382, 456, 382, 454, 382, 456, 382,
456, 1220, 454, 1220, 456, 382, 456, 382, 456, 382, 454, 1220, 456, 1220,
454, 1222, 454, 1220, 454, 382, 456, 382, 456, 382, 456, 382, 456, 382,
456, 382, 456, 382, 454, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456,
382, 456, 382, 456, 382, 454, 382, 456, 382, 456, 382, 456, 382, 456, 382,
456, 382, 456, 382, 456, 380, 456, 382, 456, 382, 456, 382, 456, 1220,
456, 382, 456, 382, 456, 382, 454, 382, 456, 382, 456, 1222, 454, 380,
456, 382, 456, 382, 456, 382, 456, 380, 456, 382, 456, 382, 454, 382, 454,
382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382, 456, 382,
456, 1220, 456, 1220, 454, 382, 456, 1222, 454, 1220, 454, 1220, 454,
1222, 454, 1220, 456}; // UNKNOWN 76CCC723
irsend.sendRaw(rawData, 583, 38);
irsend.makeDecodeResult();

ASSERT_TRUE(irrecv.decode(&irsend.capture));
ASSERT_EQ(MITSUBISHI_AC, irsend.capture.decode_type);
EXPECT_EQ(kMitsubishiACBits, irsend.capture.bits);
uint8_t expected[kMitsubishiACStateLength] = {
0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x08, 0x04, 0x00, 0xC0,
0x78, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0xFB};
EXPECT_STATE_EQ(expected, irsend.capture.state, irsend.capture.bits);
EXPECT_EQ(
"Power: On, Mode: 1 (Heat), Temp: 20C, Fan: 0 (Auto), "
"Swing(V): 0 (Auto), Swing(H): 0 (UNKNOWN), Clock: 20:00, "
"On Timer: 00:00, Off Timer: 00:00, Timer: -, Weekly Timer: Off, "
"10C Heat: Off, ISee: Off, Econo: Off, Absense detect: Off, "
"Direct / Indirect Mode: 0, Fresh: Off",
IRAcUtils::resultAcToString(&irsend.capture));
stdAc::state_t r, p;
ASSERT_TRUE(IRAcUtils::decodeToState(&irsend.capture, &r, &p));
}

0 comments on commit 789b926

Please sign in to comment.