Skip to content

Commit

Permalink
Mirage: Change bit order based on user data.
Browse files Browse the repository at this point in the history
* Also update status as it has been confirmed working.

Ref: #1289 (comment)
  • Loading branch information
crankyoldgit committed Oct 9, 2020
1 parent 3ee88f1 commit 790aca2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
14 changes: 6 additions & 8 deletions src/ir_Mirage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ const uint16_t kMirageFreq = 38000; ///< Hz. (Just a guess)

#if SEND_MIRAGE
/// Send a Mirage formatted message.
/// Status: BETA / Probably works.
/// Status: STABLE / Reported as working.
/// @param[in] data An array of bytes containing the IR command.
/// It is assumed to be in MSB order for this code.
/// @todo Confirm the bit ordering of the data.
/// @param[in] nbytes Nr. of bytes of data in the array. (>=kMirageStateLength)
/// @param[in] repeat Nr. of times the message is to be repeated.
void IRsend::sendMirage(const uint8_t data[], const uint16_t nbytes,
Expand All @@ -35,16 +33,15 @@ void IRsend::sendMirage(const uint8_t data[], const uint16_t nbytes,
kMirageBitMark, kMirageOneSpace,
kMirageBitMark, kMirageZeroSpace,
kMirageBitMark, kMirageGap,
data, nbytes,
kMirageFreq, true, repeat, kDutyDefault);
data, nbytes, kMirageFreq, false, // LSB
repeat, kDutyDefault);
}
#endif // SEND_MIRAGE

#if DECODE_MIRAGE
/// Decode the supplied Mirage message.
/// Status: BETA / Probably works.
/// Status: STABLE / Reported as working.
/// @param[in,out] results Ptr to the data to decode & where to store the decode
/// @todo Confirm the bit ordering of the result data.
/// @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.
Expand All @@ -59,7 +56,8 @@ bool IRrecv::decodeMirage(decode_results *results, uint16_t offset,
kMirageHdrMark, kMirageHdrSpace,
kMirageBitMark, kMirageOneSpace,
kMirageBitMark, kMirageZeroSpace,
kMirageBitMark, kMirageGap, true)) return false;
kMirageBitMark, kMirageGap, true,
kUseDefTol, kMarkExcess, false)) return false;

// Success
results->decode_type = decode_type_t::MIRAGE;
Expand Down
12 changes: 6 additions & 6 deletions test/ir_Mirage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ TEST(TestDecodeMirage, RealExample) {
1600, 556, 542, 560, 542, 532, 568, 558, 542, 610, 1538, 504, 1646, 582,
518, 528, 572, 528, 1612, 556, 544, 528, 580, 554}; // UNKNOWN 28DACDC4
const uint8_t expected[kMirageStateLength] = {
0x6A, 0xAE, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x68, 0x28, 0x64};
0x56, 0x75, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x16, 0x14, 0x26};
irsend.begin();
irsend.reset();
irsend.sendRaw(rawData, 243, 38);
Expand All @@ -63,8 +63,8 @@ TEST(TestDecodeMirage, SyntheticExample) {
IRsendTest irsend(kGpioUnused);
IRrecv irrecv(kGpioUnused);
const uint8_t expected[kMirageStateLength] = {
0x6A, 0xAE, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x68, 0x28, 0x64};
0x56, 0x75, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x16, 0x14, 0x26};
irsend.begin();
irsend.reset();
irsend.sendMirage(expected);
Expand Down Expand Up @@ -106,8 +106,8 @@ TEST(TestDecodeMirage, RealExampleWithDodgyHardwareCapture) {
558, 542, 610, 1538, 504, 1646, 582, 518, 528, 572, 528, 1612, 556, 544,
528, 580, 554}; // UNKNOWN 28DACDC4
const uint8_t expected[kMirageStateLength] = {
0x6A, 0xAE, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x68, 0x28, 0x64};
0x56, 0x75, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x16, 0x14, 0x26};
irrecv.setTolerance(kTolerance + 10); // Bump tolerance to match poor data.
irsend.begin();
irsend.reset();
Expand Down

0 comments on commit 790aca2

Please sign in to comment.