Skip to content

Commit

Permalink
Re-add PET998DR quiet postamble (#249)
Browse files Browse the repository at this point in the history
Co-authored-by: nullstalgia <[email protected]>
  • Loading branch information
hhvrc and nullstalgia authored Jul 4, 2024
1 parent f3d3552 commit 98e922f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/radio/rmt/Petrainer998DREncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const rmt_data_t kRmtPreamble = {1500, 1, 750, 0};
const rmt_data_t kRmtOne = {750, 1, 250, 0};
const rmt_data_t kRmtZero = {250, 1, 750, 0};
const rmt_data_t kRmtPostamble = {1500, 0, 1500, 0}; // Some subvariants expect a quiet period between commands

using namespace OpenShock;

Expand Down Expand Up @@ -45,14 +46,15 @@ std::vector<rmt_data_t> Rmt::Petrainer998DREncoder::GetSequence(std::uint16_t sh
std::uint64_t data = (static_cast<std::uint64_t>(channel & 0b111) << 35 | static_cast<std::uint64_t>(typeVal & 0b1111) << 31 | static_cast<std::uint64_t>(shockerId & 0x1FFFF) << 14 | static_cast<std::uint64_t>(intensity & 0x7F) << 7 | static_cast<std::uint64_t>(typeInvert & 0b1111) << 3 | static_cast<std::uint64_t>(channelInvert & 0b111));

std::vector<rmt_data_t> pulses;
pulses.reserve(42);
pulses.reserve(43);

// Generate the sequence
pulses.push_back(kRmtPreamble);
pulses.push_back(kRmtOne);
Internal::EncodeBits<38>(pulses, data, kRmtOne, kRmtZero);
pulses.push_back(kRmtZero);
pulses.push_back(kRmtZero);
pulses.push_back(kRmtPostamble);

return pulses;
}

0 comments on commit 98e922f

Please sign in to comment.