M5Unit-INFRARED 0.2.0 git rev:76ad9e1
Loading...
Searching...
No Matches
rc5_codec.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_INFRARED_IR_RC5_CODEC_HPP
11#define M5_UNIT_INFRARED_IR_RC5_CODEC_HPP
12
13#include "ir_codec.hpp"
14
15namespace m5 {
16namespace unit {
17namespace ir {
18
31class Rc5Codec : public IRCodec {
32public:
35 {
36 }
37
39 item_container_type encode(uint16_t address, uint16_t command, bool repeat) override;
41 bool decode(const gpio::m5_rmt_item_t* items, uint32_t num, DecodeResult& result) override;
42
44 uint32_t carrierFrequencyHz() const override
45 {
46 return 36000;
47 }
48
53 bool toggle() const
54 {
55 return _toggle;
56 }
61 void setToggle(bool t)
62 {
63 _toggle = t;
64 }
67 {
68 _toggle = !_toggle;
69 }
70
71private:
72 bool _toggle{};
73
74 static constexpr uint16_t HALF_BIT{889};
75 static constexpr uint16_t FULL_BIT{1778};
76 static constexpr uint16_t TOLERANCE{250};
77};
78
79} // namespace ir
80} // namespace unit
81} // namespace m5
82#endif
Abstract base class for IR protocol encoding/decoding.
Definition ir_codec.hpp:62
Philips RC5 / RC5X IR protocol encoder/decoder.
Definition rc5_codec.hpp:31
bool toggle() const
Toggle bit state (flipped on each new key press)
Definition rc5_codec.hpp:53
void flipToggle()
Flip toggle bit (call on each new key press)
Definition rc5_codec.hpp:66
bool decode(const gpio::m5_rmt_item_t *items, uint32_t num, DecodeResult &result) override
Decode an RC5 / RC5X Manchester frame (14 bits including S1/S2/T)
Definition rc5_codec.cpp:43
Rc5Codec()
Constructor.
Definition rc5_codec.hpp:34
void setToggle(bool t)
Set toggle bit.
Definition rc5_codec.hpp:61
item_container_type encode(uint16_t address, uint16_t command, bool repeat) override
Encode an RC5 or RC5X frame (S2 = ~Cmd[6] when command ≥ 64)
Definition rc5_codec.cpp:17
uint32_t carrierFrequencyHz() const override
Carrier frequency for RC5 (36 kHz)
Definition rc5_codec.hpp:44
IR protocol codec base class and types.
std::vector< m5::unit::gpio::m5_rmt_item_t > item_container_type
RMT item container.
Definition ir_codec.hpp:54
CodecType
Identifies the IR protocol codec implementation.
Definition ir_codec.hpp:27
@ RC5
Philips RC5 / RC5X.
Top level namespace of M5Stack.
Unit-related namespace.
Result of decoding a received IR frame.
Definition ir_codec.hpp:44