M5UnitUnified 0.4.4 git rev:306ddd5
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;
29class HardwareSerial;
30class SPIClass;
31struct SPISettings;
32
37namespace m5 {
38class I2C_Class;
43namespace unit {
44class Component;
45
50class UnitUnified {
51public:
52 using container_type = std::vector<Component*>;
53
57 UnitUnified() = default;
58 UnitUnified(const UnitUnified&) = delete;
59 UnitUnified(UnitUnified&&) noexcept = default;
61
65 UnitUnified& operator=(const UnitUnified&) = delete;
66
67 UnitUnified& operator=(UnitUnified&&) noexcept = default;
69
72
78 bool add(Component& u, TwoWire& wire);
86 bool add(Component& u, const int8_t rx_pin, const int8_t tx_pin);
93 bool add(Component& u, HardwareSerial& serial);
100 bool add(Component& u, SPIClass& spi, const SPISettings& settings);
107 bool add(Component& u, m5::hal::bus::Bus* bus);
114 bool add(Component& u, m5::I2C_Class& i2c);
116
118 bool begin();
120 void update(const bool force = false);
121
123 std::string debugInfo() const;
124
125protected:
126 bool add_children(Component& u);
127 std::string make_unit_info(const Component* u, const uint8_t indent = 0) const;
128
129protected:
130 container_type _units{};
131
132private:
133 static uint32_t _registerCount;
134};
135
136} // namespace unit
137} // namespace m5
138
139#endif
Main header of M5UnitComponent.
std::string debugInfo() const
Output information for debug.
Definition M5UnitUnified.cpp:191
bool begin()
Begin of all units under management.
Definition M5UnitUnified.cpp:169
void update(const bool force=false)
Update of all units under management.
Definition M5UnitUnified.cpp:181
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:20
Unit-related namespace.