M5Unit-RF433 0.0.1 git rev:a9e15af
Loading...
Searching...
No Matches
unit_SYN531R.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_RF433_UNIT_SYN531R_HPP
11#define M5_UNIT_RF433_UNIT_SYN531R_HPP
12
13#include <M5UnitComponent.hpp>
14#include "rmt_item_types.hpp"
15#include <vector>
16
17namespace m5 {
18namespace unit {
19
25class UnitSYN531R : public Component {
26 M5_UNIT_COMPONENT_HPP_BUILDER(UnitSYN531R, 0x00);
27
28public:
29 using container_type = rf433::container_type;
30
35 struct config_t {
37 rf433::Protocol protocol{rf433::ProtocolIncludeSendCount | rf433::ProtocolIncludeIdentifier};
38 };
39
42
44 {
45 return _cfg;
46 }
48 inline void config(const config_t& cfg)
49 {
50 _cfg = cfg;
51 }
53
54 UnitSYN531R() : Component(DEFAULT_ADDRESS)
55 {
56 auto ccfg = component_config();
57 ccfg.stored_size = 2048; // inner buffer size
58 component_config(ccfg);
59 }
60 virtual ~UnitSYN531R()
61 {
62 }
63
64 virtual bool begin() override;
65 virtual void update(const bool force = false) override;
66
70 inline size_t available() const
71 {
72 return _data.size();
73 }
75 inline bool empty() const
76 {
77 return _data.empty();
78 }
80 inline uint8_t oldest() const
81 {
82 return !_data.empty() ? _data.front() : 0;
83 }
85 inline uint8_t latest() const
86 {
87 return !_data.empty() ? _data.back() : 0;
88 }
90 inline void discard()
91 {
92 if (!_data.empty()) {
93 _data.erase(_data.begin());
94 }
95 }
97 inline void flush()
98 {
99 _data.clear();
100 }
101
103 inline const container_type& container() const
104 {
105 return _data;
106 }
108
109protected:
110 bool read_data();
111
112private:
113 container_type _data{};
114 config_t _cfg{};
115};
116
117} // namespace unit
118} // namespace m5
119#endif
config_t config()
Gets the configration.
Definition unit_SYN531R.hpp:43
void config(const config_t &cfg)
Set the configration.
Definition unit_SYN531R.hpp:48
size_t available() const
Gets the number of stored data.
Definition unit_SYN531R.hpp:70
const container_type & container() const
Gets the received container reference.
Definition unit_SYN531R.hpp:103
void discard()
Discard the oldest data accumulated.
Definition unit_SYN531R.hpp:90
bool empty() const
Is empty stored data?
Definition unit_SYN531R.hpp:75
uint8_t latest() const
Retrieve latest stored data.
Definition unit_SYN531R.hpp:85
uint8_t oldest() const
Retrieve oldest stored data.
Definition unit_SYN531R.hpp:80
void flush()
Discard all data.
Definition unit_SYN531R.hpp:97
Top level namespace of M5stack.
Unit-related namespace.
RMT releated definition and function for RF433.
uint8_t Protocol
Protocol type.
Definition rmt_item_types.hpp:33
Settings for begin.
Definition unit_SYN531R.hpp:35
rf433::Protocol protocol
Protocol.
Definition unit_SYN531R.hpp:37