Skip to content

Commit

Permalink
Pioneer: Update timings based on user collected data. (#1222)
Browse files Browse the repository at this point in the history
* Adjust protocol timings based on the average seen across ten different captures.
* Update unit tests accordingly.
* Updated supported devices.

Fixes #1220

* Add Unit test case to help debug Pioneer Power Toggle message.
Ref: #1220 (comment)
  • Loading branch information
crankyoldgit authored Jul 26, 2020
1 parent ad436f7 commit 6a5918b
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 52 deletions.
28 changes: 12 additions & 16 deletions src/ir_Pioneer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
/// @see http://www.adrian-kingston.com/IRFormatPioneer.htm
/// @see https://github.com/crankyoldgit/IRremoteESP8266/pull/547
/// @see https://www.pioneerelectronics.com/PUSA/Support/Home-Entertainment-Custom-Install/IR+Codes/A+V+Receivers
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1220

// Supports:
// Brand: Pioneer, Model: AV Receivers
// Brand: Pioneer, Model: VSX-324 AV Receiver
// Brand: Pioneer, Model: AXD7690 Remote

#define __STDC_LIMIT_MACROS
#include <stdint.h>
Expand All @@ -20,22 +23,15 @@
#include "IRutils.h"

// Constants
const uint16_t kPioneerTick = 534;
const uint16_t kPioneerHdrMarkTicks = 16;
const uint16_t kPioneerHdrMark = kPioneerHdrMarkTicks * kPioneerTick;
const uint16_t kPioneerHdrSpaceTicks = 8;
const uint16_t kPioneerHdrSpace = kPioneerHdrSpaceTicks * kPioneerTick;
const uint16_t kPioneerBitMarkTicks = 1;
const uint16_t kPioneerBitMark = kPioneerBitMarkTicks * kPioneerTick;
const uint16_t kPioneerOneSpaceTicks = 3;
const uint16_t kPioneerOneSpace = kPioneerOneSpaceTicks * kPioneerTick;
const uint16_t kPioneerZeroSpaceTicks = 1;
const uint16_t kPioneerZeroSpace = kPioneerZeroSpaceTicks * kPioneerTick;
const uint16_t kPioneerMinCommandLengthTicks = 159;
const uint32_t kPioneerMinCommandLength = kPioneerMinCommandLengthTicks *
kPioneerTick;
const uint16_t kPioneerMinGapTicks = 47;
const uint32_t kPioneerMinGap = kPioneerMinGapTicks * kPioneerTick;
// Ref: https://github.com/crankyoldgit/IRremoteESP8266/issues/1220
const uint16_t kPioneerTick = 534; ///< uSeconds.
const uint16_t kPioneerHdrMark = 8506; ///< uSeconds.
const uint16_t kPioneerHdrSpace = 4191; ///< uSeconds.
const uint16_t kPioneerBitMark = 568; ///< uSeconds.
const uint16_t kPioneerOneSpace = 1542; ///< uSeconds.
const uint16_t kPioneerZeroSpace = 487; ///< uSeconds.
const uint32_t kPioneerMinCommandLength = 84906; ///< uSeconds.
const uint32_t kPioneerMinGap = 25181; ///< uSeconds.

#if SEND_PIONEER
/// Send a raw Pioneer formatted message.
Expand Down
146 changes: 110 additions & 36 deletions test/ir_Pioneer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ TEST(TestSendPioneer, SendDataOnly) {
irsend.sendPioneer(0);
EXPECT_EQ(
"f40000d33"
"m8544s4272"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s37380"
"m8544s4272"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s37380",
"m8506s4191"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s37881"
"m8506s4191"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s37881",
irsend.outputStr());
irsend.sendPioneer(0x55FF00AAAA00FF55);
EXPECT_EQ(
"f40000d33"
"m8544s4272"
"m534s534m534s1602m534s534m534s1602m534s534m534s1602m534s534m534s1602"
"m534s1602m534s1602m534s1602m534s1602m534s1602m534s1602m534s1602m534s1602"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s1602m534s534m534s1602m534s534m534s1602m534s534m534s1602m534s534"
"m534s25098"
"m8544s4272"
"m534s1602m534s534m534s1602m534s534m534s1602m534s534m534s1602m534s534"
"m534s534m534s534m534s534m534s534m534s534m534s534m534s534m534s534"
"m534s1602m534s1602m534s1602m534s1602m534s1602m534s1602m534s1602m534s1602"
"m534s534m534s1602m534s534m534s1602m534s534m534s1602m534s534m534s1602"
"m534s25098",
"m8506s4191"
"m568s487m568s1542m568s487m568s1542m568s487m568s1542m568s487m568s1542"
"m568s1542m568s1542m568s1542m568s1542m568s1542m568s1542m568s1542m568s1542"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s1542m568s487m568s1542m568s487m568s1542m568s487m568s1542m568s487"
"m568s25181"
"m8506s4191"
"m568s1542m568s487m568s1542m568s487m568s1542m568s487m568s1542m568s487"
"m568s487m568s487m568s487m568s487m568s487m568s487m568s487m568s487"
"m568s1542m568s1542m568s1542m568s1542m568s1542m568s1542m568s1542m568s1542"
"m568s487m568s1542m568s487m568s1542m568s487m568s1542m568s487m568s1542"
"m568s25181",
irsend.outputStr());
}

Expand Down Expand Up @@ -139,17 +139,91 @@ TEST(TestDecodePioneer, SyntheticPioneerMessage) {
irsend.sendPioneer(0x659A857AF50A3DC2, 64, 0);
EXPECT_EQ(
"f40000d33"
"m8544s4272"
"m534s534m534s1602m534s1602m534s534m534s534m534s1602m534s534m534s1602"
"m534s1602m534s534m534s534m534s1602m534s1602m534s534m534s1602m534s534"
"m534s1602m534s534m534s534m534s534m534s534m534s1602m534s534m534s1602"
"m534s534m534s1602m534s1602m534s1602m534s1602m534s534m534s1602m534s534"
"m534s25098"
"m8544s4272"
"m534s1602m534s1602m534s1602m534s1602m534s534m534s1602m534s534m534s1602"
"m534s534m534s534m534s534m534s534m534s1602m534s534m534s1602m534s534"
"m534s534m534s534m534s1602m534s1602m534s1602m534s1602m534s534m534s1602"
"m534s1602m534s1602m534s534m534s534m534s534m534s534m534s1602m534s534"
"m534s25098",
"m8506s4191"
"m568s487m568s1542m568s1542m568s487m568s487m568s1542m568s487m568s1542"
"m568s1542m568s487m568s487m568s1542m568s1542m568s487m568s1542m568s487"
"m568s1542m568s487m568s487m568s487m568s487m568s1542m568s487m568s1542"
"m568s487m568s1542m568s1542m568s1542m568s1542m568s487m568s1542m568s487"
"m568s25181"
"m8506s4191"
"m568s1542m568s1542m568s1542m568s1542m568s487m568s1542m568s487m568s1542"
"m568s487m568s487m568s487m568s487m568s1542m568s487m568s1542m568s487"
"m568s487m568s487m568s1542m568s1542m568s1542m568s1542m568s487m568s1542"
"m568s1542m568s1542m568s487m568s487m568s487m568s487m568s1542m568s487"
"m568s25181",
irsend.outputStr());
}

// Ref: https://github.com/crankyoldgit/IRremoteESP8266/issues/1220#issuecomment-661598412
TEST(TestDecodePioneer, Issue1220) {
IRsendTest irsend(0);
IRrecv irrecv(0);
irsend.begin();

irsend.reset();
// Pwr Toggle {"IrReceived":{"Protocol":"PIONEER","Bits":64,
// "Data":"0xA55A38C7A55A38C7"}}
const uint16_t rawPowerToggle[203] = {
8510, 4188, 580, 1544, 556, 470, 582, 1566, 556, 494, 560, 488, 556, 1542,
580, 470, 584, 1540, 582, 492, 552, 1522, 578, 496, 558, 1564, 558, 1542,
580, 470, 586, 1564, 536, 512, 532, 494, 560, 464, 582, 1542, 580, 1544,
578, 1544, 578, 498, 558, 492, 562, 488, 556, 1518, 582, 1542, 582, 492,
552, 498, 556, 494, 550, 1572, 560, 1538, 562, 1536, 586, 25188,
8512, 4186, 584, 1540, 584, 468, 576, 1572, 528, 522, 532, 492, 552, 1546,
584, 492, 550, 1548, 582, 494, 560, 1538, 580, 468, 586, 1514, 586, 1538,
584, 490, 554, 1546, 586, 488, 554, 470, 584, 490, 556, 1542, 556, 1542,
580, 1544, 578, 496, 560, 466, 578, 496, 560, 1538, 584, 1516, 584, 490,
554, 472, 582, 492, 552, 1546, 586, 1536, 586, 1538, 586, 25162,
8514, 4184, 582, 1542, 580, 496, 562, 1536, 584, 490, 554, 496, 560, 1538,
562, 514, 530, 1542, 580, 496, 560, 1538, 584, 466, 578, 1546, 576, 1524,
578, 496, 558, 1542, 586, 488, 554, 496, 558, 466, 576, 1546, 576, 1548,
586, 1512, 578, 498, 558, 492, 552, 496, 558, 1540, 580, 1542, 578, 498,
556, 494, 550, 498, 556, 1516, 584, 1540, 584, 1540, 580};
irsend.sendRaw(rawPowerToggle, 203, 40); // Pioneer uses 40kHz
irsend.makeDecodeResult();
EXPECT_TRUE(irrecv.decode(&irsend.capture));
EXPECT_EQ(PIONEER, irsend.capture.decode_type);
EXPECT_EQ(kPioneerBits, irsend.capture.bits);
EXPECT_EQ(0xA55A38C7A55A38C7, irsend.capture.value);
EXPECT_EQ(0xA51C, irsend.capture.address);
EXPECT_EQ(0xA51C, irsend.capture.command);

irsend.reset();
irsend.sendPioneer(0xA55A38C7A55A38C7, 64, 1);
irsend.makeDecodeResult();
EXPECT_TRUE(irrecv.decode(&irsend.capture));
EXPECT_EQ(PIONEER, irsend.capture.decode_type);
EXPECT_EQ(kPioneerBits, irsend.capture.bits);
EXPECT_EQ(0xA55A38C7A55A38C7, irsend.capture.value);
EXPECT_EQ(0xA51C, irsend.capture.address);
EXPECT_EQ(0xA51C, irsend.capture.command);
EXPECT_EQ(
"f40000d33"
"m8506s4191"
"m568s1542m568s487m568s1542m568s487m568s487m568s1542m568s487m568s1542"
"m568s487m568s1542m568s487m568s1542m568s1542m568s487m568s1542m568s487"
"m568s487m568s487m568s1542m568s1542m568s1542m568s487m568s487m568s487"
"m568s1542m568s1542m568s487m568s487m568s487m568s1542m568s1542m568s1542"
"m568s25181"
"m8506s4191"
"m568s1542m568s487m568s1542m568s487m568s487m568s1542m568s487m568s1542"
"m568s487m568s1542m568s487m568s1542m568s1542m568s487m568s1542m568s487"
"m568s487m568s487m568s1542m568s1542m568s1542m568s487m568s487m568s487"
"m568s1542m568s1542m568s487m568s487m568s487m568s1542m568s1542m568s1542"
"m568s25181"
"m8506s4191"
"m568s1542m568s487m568s1542m568s487m568s487m568s1542m568s487m568s1542"
"m568s487m568s1542m568s487m568s1542m568s1542m568s487m568s1542m568s487"
"m568s487m568s487m568s1542m568s1542m568s1542m568s487m568s487m568s487"
"m568s1542m568s1542m568s487m568s487m568s487m568s1542m568s1542m568s1542"
"m568s25181"
"m8506s4191"
"m568s1542m568s487m568s1542m568s487m568s487m568s1542m568s487m568s1542"
"m568s487m568s1542m568s487m568s1542m568s1542m568s487m568s1542m568s487"
"m568s487m568s487m568s1542m568s1542m568s1542m568s487m568s487m568s487"
"m568s1542m568s1542m568s487m568s487m568s487m568s1542m568s1542m568s1542"
"m568s25181",
irsend.outputStr());

EXPECT_EQ(0xA55A38C7A55A38C7, irsend.encodePioneer(0xA51C, 0xA51C));
}

2 comments on commit 6a5918b

@s-hadinger
Copy link
Contributor

Choose a reason for hiding this comment

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

As Theo is releasing a new major version of Tasmota, we have included these latest changes in Tasmota, not waiting for 2.7.9.

Great job David.

@crankyoldgit
Copy link
Owner Author

Choose a reason for hiding this comment

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

As Theo is releasing a new major version of Tasmota, we have included these latest changes in Tasmota, not waiting for 2.7.9.

Great job David.

I was going to create a new release yesterday. Looks like I should have. :-/

Please sign in to comment.