ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
pd_pioneer_protocol.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
4namespace esphome::remote_base {
5
6ESPHOME_LOG_TAG(TAG, "remote.pd_pioneer");
7
8// Timings from captured Pronto codes (006D timebase, 26 us per word)
9static constexpr uint32_t HEADER_MARK_US = 3120;
10static constexpr uint32_t HEADER_SPACE_US = 1560;
11static constexpr uint32_t BIT_MARK_US = 520;
12static constexpr uint32_t BIT_ONE_SPACE_US = 1066;
13static constexpr uint32_t BIT_ZERO_SPACE_US = 312;
14static constexpr uint32_t FOOTER_MARK_US = 520;
15static constexpr uint32_t FOOTER_SPACE_US = 10010;
16
18 dst->set_carrier_frequency(38000);
19 dst->reserve(2 + PDPioneerData::FRAME_SIZE * 8 * 2 + 2);
20 dst->item(HEADER_MARK_US, HEADER_SPACE_US);
21 for (uint8_t idx = 0; idx < PDPioneerData::FRAME_SIZE; idx++) {
22 for (uint8_t mask = 1; mask; mask <<= 1)
23 dst->item(BIT_MARK_US, (src[idx] & mask) ? BIT_ONE_SPACE_US : BIT_ZERO_SPACE_US);
24 }
25 dst->item(FOOTER_MARK_US, FOOTER_SPACE_US);
26}
27
30 if (!src.expect_item(HEADER_MARK_US, HEADER_SPACE_US))
31 return {};
32 for (uint8_t idx = 0; idx < PDPioneerData::FRAME_SIZE; idx++) {
33 for (uint8_t mask = 1; mask; mask <<= 1) {
34 if (src.expect_item(BIT_MARK_US, BIT_ONE_SPACE_US)) {
35 out[idx] |= mask;
36 } else if (!src.expect_item(BIT_MARK_US, BIT_ZERO_SPACE_US)) {
37 return {};
38 }
39 }
40 }
41 // The receiver's idle timeout usually ends the capture inside the footer space, so only the mark is required
42 if (!src.expect_mark(FOOTER_MARK_US))
43 return {};
44 if (!out.is_valid()) {
46 ESP_LOGV(TAG, "Checksum mismatch: %s", out.to_str(buf));
47 return {};
48 }
49 return out;
50}
51
54 ESP_LOGI(TAG, "Received PD-Pioneer: %s", data.to_str(buf));
55}
56
57} // namespace esphome::remote_base
static constexpr size_t TO_STR_BUFFER_SIZE
void encode(RemoteTransmitData *dst, const PDPioneerData &src)
optional< PDPioneerData > decode(RemoteReceiveData src)
void set_carrier_frequency(uint32_t carrier_frequency)
Definition remote_base.h:31
void item(uint32_t mark, uint32_t space)
Definition remote_base.h:26
std::vector< uint8_t > & out
Definition gif.cpp:49
ESPHOME_LOG_TAG(TAG, "remote.abbwelcome")
const void * src
Definition hal.h:68
static void uint32_t