-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Elite Screens protocol. (#1310)
* Add support for Elite Screens protocol. * A constant bit time 32-bit protocol with a single repeat. * Add `sendElitescreens()` & `decodeElitescreens()` * Unit test coverage including real & synthetic examples. * decoding confirmed to be working. See #1306 (comment) Fixes #1306
- Loading branch information
1 parent
5e82c21
commit b77b0e1
Showing
9 changed files
with
258 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2020 David Conran | ||
/// @file | ||
/// @brief Elite Screens protocol support | ||
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1306 | ||
/// @see https://elitescreens.com/kcfinder/upload/files/FAQ/ir_commands.pdf | ||
|
||
// Supports: | ||
// Brand: Elite Screens, Model: Spectrum series | ||
// Brand: Elite Screens, Model: VMAX2 / VMAX2 Plus series | ||
// Brand: Elite Screens, Model: VMAX Plus4 series | ||
// Brand: Elite Screens, Model: Home2 / Home3 series | ||
// Brand: Elite Screens, Model: CineTension2 / CineTension3 series | ||
// Brand: Elite Screens, Model: ZSP-IR-B / ZSP-IR-W remote | ||
|
||
// Known Elite Screens commands: | ||
// 0xFEA3387 (STOP) | ||
// 0xFDA2256 (UP) | ||
// 0xFBA1136 (DOWN) | ||
|
||
#include "IRrecv.h" | ||
#include "IRsend.h" | ||
#include "IRutils.h" | ||
|
||
|
||
// Constants | ||
const uint16_t kEliteScreensOne = 470; | ||
const uint16_t kEliteScreensZero = 1214; | ||
const uint16_t kEliteScreensGap = 29200; | ||
|
||
#if SEND_ELITESCREENS | ||
/// Send an Elite Screens formatted message. | ||
/// Status: BETA / Probably Working. | ||
/// @param[in] data The message to be sent. | ||
/// @param[in] nbits The number of bits of message to be sent. | ||
/// @param[in] repeat The number of times the command is to be repeated. | ||
void IRsend::sendElitescreens(uint64_t data, uint16_t nbits, uint16_t repeat) { | ||
// Protocol uses a constant bit time encoding. | ||
sendGeneric(0, 0, // No header. | ||
kEliteScreensOne, kEliteScreensZero, | ||
kEliteScreensZero, kEliteScreensOne, | ||
0, kEliteScreensGap, data, nbits, 38000, true, repeat, 50); | ||
} | ||
#endif | ||
|
||
#if DECODE_ELITESCREENS | ||
/// Decode the supplied Elite Screens message. | ||
/// Status: STABLE / Confirmed working. | ||
/// @param[in,out] results Ptr to the data to decode & where to store the decode | ||
/// result. | ||
/// @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 A boolean. True if it can decode it, false if it can't. | ||
bool IRrecv::decodeElitescreens(decode_results *results, uint16_t offset, | ||
const uint16_t nbits, const bool strict) { | ||
// Compliance check. | ||
if (strict && nbits != kEliteScreensBits) return false; | ||
|
||
uint64_t data = 0; | ||
|
||
// Data + Footer | ||
if (!matchGenericConstBitTime(results->rawbuf + offset, &data, | ||
results->rawlen - offset, nbits, | ||
// Header (None) | ||
0, 0, | ||
// Data | ||
kEliteScreensOne, kEliteScreensZero, | ||
// Footer (None) | ||
0, kEliteScreensGap, true)) return false; | ||
|
||
// Success | ||
results->decode_type = decode_type_t::ELITESCREENS; | ||
results->bits = nbits; | ||
results->value = data; | ||
results->address = 0; | ||
results->command = 0; | ||
results->repeat = false; | ||
return true; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// Copyright 2017 David Conran | ||
|
||
#include "IRac.h" | ||
#include "IRsend.h" | ||
#include "IRsend_test.h" | ||
#include "gtest/gtest.h" | ||
|
||
// Housekeeping tests | ||
|
||
TEST(TestUtils, Housekeeping) { | ||
ASSERT_EQ("ELITESCREENS", typeToString(decode_type_t::ELITESCREENS)); | ||
ASSERT_EQ(decode_type_t::ELITESCREENS, strToDecodeType("ELITESCREENS")); | ||
ASSERT_FALSE(hasACState(decode_type_t::ELITESCREENS)); | ||
ASSERT_FALSE(IRac::isProtocolSupported(decode_type_t::ELITESCREENS)); | ||
ASSERT_EQ(kEliteScreensBits, | ||
IRsendTest::defaultBits(decode_type_t::ELITESCREENS)); | ||
ASSERT_EQ(kEliteScreensDefaultRepeat, | ||
IRsendTest::minRepeats(decode_type_t::ELITESCREENS)); | ||
} | ||
|
||
// Tests for sendElitescreens(). | ||
|
||
// Test sending typical data only. | ||
TEST(TestSendElitescreens, SendDataOnly) { | ||
IRsendTest irsend(kGpioUnused); | ||
irsend.begin(); | ||
|
||
irsend.reset(); | ||
irsend.sendElitescreens(0xFEA3387); // STOP command | ||
EXPECT_EQ( | ||
"f38000d50" | ||
"m1214s470m1214s470m1214s470m1214s470" | ||
"m470s1214m470s1214m470s1214m470s1214" | ||
"m470s1214m470s1214m470s1214m1214s470" | ||
"m470s1214m1214s470m470s1214m1214s470" | ||
"m1214s470m1214s470m470s1214m470s1214" | ||
"m1214s470m1214s470m470s1214m470s1214" | ||
"m470s1214m1214s470m1214s470m1214s470" | ||
"m1214s470m470s1214m470s1214m470" | ||
"s30414" | ||
"m1214s470m1214s470m1214s470m1214s470" | ||
"m470s1214m470s1214m470s1214m470s1214" | ||
"m470s1214m470s1214m470s1214m1214s470" | ||
"m470s1214m1214s470m470s1214m1214s470" | ||
"m1214s470m1214s470m470s1214m470s1214" | ||
"m1214s470m1214s470m470s1214m470s1214" | ||
"m470s1214m1214s470m1214s470m1214s470" | ||
"m1214s470m470s1214m470s1214m470" | ||
"s30414", | ||
irsend.outputStr()); | ||
} | ||
|
||
// Tests for decodeElitescreens(). | ||
|
||
// Decode a 'real' example | ||
TEST(TestDecodeElitescreens, RealExample) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
irsend.begin(); | ||
|
||
// From https://github.com/crankyoldgit/IRremoteESP8266/issues/1306#issuecomment-715913084 | ||
// STOP (111100000010 0xF02) | ||
const uint16_t rawData[127] = { | ||
1278, 456, 1248, 486, 1226, 452, 1252, 454, // 0 0 0 0 0x0 | ||
474, 1220, 474, 1222, 480, 1214, 476, 1222, // 1 1 1 1 0xF | ||
472, 1224, 478, 1216, 476, 1220, 1256, 480, // 1 1 1 0 0xE | ||
450, 1216, 1248, 488, 442, 1222, 1252, 486, // 1 0 1 0 0xA | ||
1226, 478, 1224, 482, 448, 1220, 472, 1222, // 0 0 1 1 0x3 | ||
1254, 482, 1220, 486, 444, 1222, 480, 1218, // 0 0 1 1 0x3 | ||
474, 1220, 1254, 482, 1222, 484, 1218, 488, // 1 0 0 0 0x8 | ||
1224, 482, 450, 1218, 474, 1220, 470, // 0 1 1 1 0x7 | ||
30482, | ||
1246, 460, 1274, 460, 1220, 456, 1246, 488, | ||
452, 1214, 478, 1218, 474, 1220, 470, 1228, | ||
476, 1220, 472, 1222, 480, 1214, 1248, 486, | ||
476, 1190, 1274, 460, 480, 1186, 1278, 460, | ||
1252, 426, 1276, 456, 474, 1194, 478, 1216, | ||
1280, 456, 1246, 460, 482, 1186, 474, 1224, | ||
478, 1216, 1282, 454, 1248, 458, 1244, 462, | ||
1252, 456, 474, 1192, 480, 1216, 476}; // UNKNOWN 148A4DFF | ||
|
||
irsend.reset(); | ||
irsend.sendRaw(rawData, 127, 38000); | ||
irsend.makeDecodeResult(); | ||
|
||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(ELITESCREENS, irsend.capture.decode_type); | ||
EXPECT_EQ(kEliteScreensBits, irsend.capture.bits); | ||
EXPECT_EQ(0xFEA3387, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_FALSE(irsend.capture.repeat); | ||
} | ||
|
||
// Decode a Synthetic example | ||
TEST(TestDecodeElitescreens, SyntheticExample) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
irsend.begin(); | ||
|
||
irsend.reset(); | ||
irsend.sendElitescreens(0xFEA3387); | ||
irsend.makeDecodeResult(); | ||
|
||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(ELITESCREENS, irsend.capture.decode_type); | ||
EXPECT_EQ(kEliteScreensBits, irsend.capture.bits); | ||
EXPECT_EQ(0xFEA3387, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_FALSE(irsend.capture.repeat); | ||
} | ||
|
||
// Decode a 'real' example with no repeat. | ||
TEST(TestDecodeElitescreens, RealExampleNoRepeat) { | ||
IRsendTest irsend(kGpioUnused); | ||
IRrecv irrecv(kGpioUnused); | ||
irsend.begin(); | ||
|
||
// From https://github.com/crankyoldgit/IRremoteESP8266/issues/1306#issuecomment-715901468 | ||
// UP | ||
const uint16_t rawData[63] = { | ||
1250, 450, 1250, 450, 1250, 500, 1200, 500, 450, 1250, 450, 1200, 500, 1200, | ||
500, 1200, 500, 1200, 500, 1200, 1250, 450, 500, 1200, 450, 1250, 1250, 450, | ||
450, 1250, 1250, 450, 1250, 450, 1250, 450, 500, 1200, 1250, 450, 1250, 450, | ||
1250, 450, 500, 1200, 1250, 450, 1250, 450, 500, 1200, 1250, 450, 500, 1200, | ||
1250, 450, 500, 1200, 500, 1200, 1250}; // Protocol=UNKNOWN Data=0x2D8CB141 | ||
|
||
irsend.reset(); | ||
irsend.sendRaw(rawData, 63, 38000); | ||
irsend.makeDecodeResult(); | ||
|
||
ASSERT_TRUE(irrecv.decode(&irsend.capture)); | ||
EXPECT_EQ(ELITESCREENS, irsend.capture.decode_type); | ||
EXPECT_EQ(kEliteScreensBits, irsend.capture.bits); | ||
EXPECT_EQ(0xFDA2256, irsend.capture.value); | ||
EXPECT_EQ(0x0, irsend.capture.address); | ||
EXPECT_EQ(0x0, irsend.capture.command); | ||
EXPECT_FALSE(irsend.capture.repeat); | ||
} |