M5Unit-INFRARED 0.2.0 git rev:76ad9e1
Loading...
Searching...
No Matches
rc6_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_RC6_CODEC_HPP
11#define M5_UNIT_INFRARED_IR_RC6_CODEC_HPP
12
13#include "ir_codec.hpp"
14
15namespace m5 {
16namespace unit {
17namespace ir {
18
31class Rc6Codec : 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 T_UNIT{444}; // 1t
75 static constexpr uint16_t LEADER_MARK{2666}; // 6t
76 static constexpr uint16_t LEADER_SPACE{889}; // 2t
77 static constexpr uint16_t HALF_BIT{444}; // 1t for normal bits
78 static constexpr uint16_t HALF_BIT_TR{889}; // 2t for trailer bit
79 static constexpr uint16_t TOLERANCE{150};
80};
81
82} // namespace ir
83} // namespace unit
84} // namespace m5
85#endif
Abstract base class for IR protocol encoding/decoding.
Definition ir_codec.hpp:62
Philips RC6 Mode 0 IR protocol encoder/decoder.
Definition rc6_codec.hpp:31
bool decode(const gpio::m5_rmt_item_t *items, uint32_t num, DecodeResult &result) override
Decode an RC6 Mode 0 Manchester frame (with 2t-wide trailer bit)
Definition rc6_codec.cpp:90
void setToggle(bool t)
Set toggle bit.
Definition rc6_codec.hpp:61
bool toggle() const
Toggle bit state.
Definition rc6_codec.hpp:53
Rc6Codec()
Constructor.
Definition rc6_codec.hpp:34
void flipToggle()
Flip toggle bit.
Definition rc6_codec.hpp:66
item_container_type encode(uint16_t address, uint16_t command, bool repeat) override
Encode an RC6 Mode 0 frame (21 bits: SB+Mode+Trailer+Addr+Cmd)
Definition rc6_codec.cpp:17
uint32_t carrierFrequencyHz() const override
Carrier frequency for RC6 (36 kHz)
Definition rc6_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
@ RC6
Philips RC6 Mode 0.
Top level namespace of M5Stack.
Unit-related namespace.
Result of decoding a received IR frame.
Definition ir_codec.hpp:44