M5UnitUnified 0.1.0 git rev:f196fcd
Loading...
Searching...
No Matches
M5UnitUnified.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
16#ifndef M5_UNIT_UNIFIED_HPP
17#define M5_UNIT_UNIFIED_HPP
18
19#include "M5UnitComponent.hpp"
20#include <M5HAL.hpp>
21#if defined(M5_UNIT_UNIFIED_USING_RMT_V2)
22#else
23#include <driver/rmt.h>
24#endif
25#include <vector>
26#include <string>
27
28class TwoWire;
29
34namespace m5 {
39namespace unit {
40class Component;
41
46class UnitUnified {
47public:
48 using container_type = std::vector<Component*>;
49
53 UnitUnified() = default;
54 UnitUnified(const UnitUnified&) = delete;
55 UnitUnified(UnitUnified&&) noexcept = default;
57
61 UnitUnified& operator=(const UnitUnified&) = delete;
62
63 UnitUnified& operator=(UnitUnified&&) noexcept = default;
65
68
74 bool add(Component& u, TwoWire& wire);
82 bool add(Component& u, const int8_t rx_pin, const int8_t tx_pin);
89 bool add(Component& u, m5::hal::bus::Bus* bus);
91
93 bool begin();
95 void update(const bool force = false);
96
98 std::string debugInfo() const;
99
100protected:
101 bool add_children(Component& u);
102 // bool add(Component& u, m5::unit::Adapter* a);
103
104 std::string make_unit_info(const Component* u, const uint8_t indent = 0) const;
105
106protected:
107 container_type _units{};
108
109private:
110 static uint32_t _registerCount;
111};
112
113} // namespace unit
114} // namespace m5
115
116#endif
Main header of M5UnitComponent.
std::string debugInfo() const
Output information for debug.
Definition M5UnitUnified.cpp:165
bool begin()
Begin of all units under management.
Definition M5UnitUnified.cpp:143
void update(const bool force=false)
Update of all units under management.
Definition M5UnitUnified.cpp:155
bool add(Component &u, TwoWire &wire)
Adding unit to be managed (I2C)
Definition M5UnitUnified.cpp:41
Top level namespace of M5stack.
Definition test_helper.hpp:18
Unit-related namespace.