Skip to content

Commit

Permalink
LG2: Better enforce a repeat for LG2 messages.
Browse files Browse the repository at this point in the history
* Looking at comments for LG2 it seems the repeat is manditory, but we have no proof. So, lets try making it (a minimum of a single repeat for LG2) manditory in most cases.
* LG should stay the same with "no repeats" as the default.
* Extend existing unit tests to cover these points and to confirm expected operation.

This really needs to verified with hard data to be sure.

Might fix #1298
  • Loading branch information
crankyoldgit committed Oct 16, 2020
1 parent ecfc472 commit f75fb43
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ const uint16_t kLegoPfMinRepeat = kNoRepeat;
const uint16_t kLgBits = 28;
const uint16_t kLg32Bits = 32;
const uint16_t kLgDefaultRepeat = kNoRepeat;
const uint16_t kLg2DefaultRepeat = kSingleRepeat;
const uint16_t kLutronBits = 35;
const uint16_t kMagiquestBits = 56;
const uint16_t kMetzBits = 19;
Expand Down
1 change: 1 addition & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ uint16_t IRsend::minRepeats(const decode_type_t protocol) {
case COOLIX:
case GICABLE:
case INAX:
case LG2:
case MIDEA24:
case MITSUBISHI:
case MITSUBISHI2:
Expand Down
4 changes: 2 additions & 2 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ class IRsend {
#endif
#if SEND_LG
void sendLG(uint64_t data, uint16_t nbits = kLgBits,
uint16_t repeat = kNoRepeat);
uint16_t repeat = kLgDefaultRepeat);
void sendLG2(uint64_t data, uint16_t nbits = kLgBits,
uint16_t repeat = kNoRepeat);
uint16_t repeat = kLg2DefaultRepeat);
uint32_t encodeLG(uint16_t address, uint16_t command);
#endif
#if (SEND_SHARP || SEND_DENON)
Expand Down
38 changes: 35 additions & 3 deletions test/IRac_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ TEST(TestIRac, LG) {
IRLgAc ac(kGpioUnused);
IRac irac(kGpioUnused);
IRrecv capture(kGpioUnused);
char expected[] =
char lg_expected[] =
"Model: 1 (GE6711AR2853M), "
"Power: On, Mode: 1 (Dry), Temp: 27C, Fan: 2 (Medium)";

Expand All @@ -941,14 +941,46 @@ TEST(TestIRac, LG) {
27, // Degrees C
stdAc::fanspeed_t::kMedium); // Fan speed

ASSERT_EQ(expected, ac.toString());
ASSERT_EQ(lg_expected, ac.toString());
ac._irsend.makeDecodeResult();
EXPECT_TRUE(capture.decode(&ac._irsend.capture));
ASSERT_EQ(LG, ac._irsend.capture.decode_type);
ASSERT_EQ(kLgBits, ac._irsend.capture.bits);
ASSERT_EQ(expected, IRAcUtils::resultAcToString(&ac._irsend.capture));
ASSERT_EQ(lg_expected, IRAcUtils::resultAcToString(&ac._irsend.capture));
stdAc::state_t r, p;
ASSERT_TRUE(IRAcUtils::decodeToState(&ac._irsend.capture, &r, &p));

// Tests for the LG2 protocol variant/model.
ac._irsend.reset();
char lg2_expected[] =
"Model: 2 (AKB75215403), "
"Power: On, Mode: 0 (Cool), Temp: 26C, Fan: 5 (Auto)";
irac.lg(&ac,
lg_ac_remote_model_t::AKB75215403, // Model
true, // Power
stdAc::opmode_t::kCool, // Mode
26, // Degrees C
stdAc::fanspeed_t::kAuto); // Fan speed

ASSERT_EQ(lg2_expected, ac.toString());
ac._irsend.makeDecodeResult();
EXPECT_TRUE(capture.decode(&ac._irsend.capture));
ASSERT_EQ(LG2, ac._irsend.capture.decode_type);
ASSERT_EQ(kLgBits, ac._irsend.capture.bits);
ASSERT_EQ(lg2_expected, IRAcUtils::resultAcToString(&ac._irsend.capture));
ASSERT_TRUE(IRAcUtils::decodeToState(&ac._irsend.capture, &r, &p));
EXPECT_EQ(
"f38000d50"
"m3200s9850"
"m550s1600m550s550m550s550m550s550m550s1600m550s550m550s550m550s550"
"m550s550m550s550m550s550m550s550m550s550m550s550m550s550m550s550"
"m550s1600m550s550m550s1600m550s1600m550s550m550s1600m550s550m550s1600"
"m550s550m550s550m550s550m550s550"
"m550s56300"
"m3200s2250"
"m550s102050",
ac._irsend.outputStr());
ac._irsend.reset();
}

TEST(TestIRac, Midea) {
Expand Down
10 changes: 9 additions & 1 deletion test/ir_LG_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ TEST(TestSendLG2, SendDataOnly) {
"m550s550m550s550m550s550m550s550m550s550m550s550m550s550m550s550"
"m550s1600m550s550m550s550m550s1600m550s550m550s1600m550s550m550s550"
"m550s1600m550s1600m550s550m550s1600"
"m550s55250",
"m550s55250"
"m3200s2250"
"m550s102050",
irsend.outputStr());
}

Expand Down Expand Up @@ -658,15 +660,21 @@ TEST(TestIRLgAcClass, calcChecksum) {
}

TEST(TestUtils, Housekeeping) {
// LG 28 bit protocol
ASSERT_EQ("LG", typeToString(decode_type_t::LG));
ASSERT_EQ(decode_type_t::LG, strToDecodeType("LG"));
ASSERT_FALSE(hasACState(decode_type_t::LG));
ASSERT_TRUE(IRac::isProtocolSupported(decode_type_t::LG));
ASSERT_EQ(kLgBits, IRsend::defaultBits(decode_type_t::LG));
ASSERT_EQ(kLgDefaultRepeat, IRsend::minRepeats(decode_type_t::LG));

// LG2 28 bit protocol
ASSERT_EQ("LG2", typeToString(decode_type_t::LG2));
ASSERT_EQ(decode_type_t::LG2, strToDecodeType("LG2"));
ASSERT_FALSE(hasACState(decode_type_t::LG2));
ASSERT_TRUE(IRac::isProtocolSupported(decode_type_t::LG2));
ASSERT_EQ(kLgBits, IRsend::defaultBits(decode_type_t::LG2));
ASSERT_EQ(kLg2DefaultRepeat, IRsend::minRepeats(decode_type_t::LG2));
}

TEST(TestIRLgAcClass, KnownExamples) {
Expand Down

0 comments on commit f75fb43

Please sign in to comment.