M5Unit-HUB 0.0.2 git rev:98420fc
Loading...
Searching...
No Matches
unit_PCA9548AP.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_PAHUB_UNIT_PCA9548AP_HPP
11#define M5_UNIT_PAHUB_UNIT_PCA9548AP_HPP
12
13#include <M5UnitComponent.hpp>
14#include <array>
15
16namespace m5 {
17namespace unit {
18
23class UnitPCA9548AP : public Component {
24 M5_UNIT_COMPONENT_HPP_BUILDER(UnitPCA9548AP, 0x70);
25
26public:
27 constexpr static uint8_t MAX_CHANNEL = 6;
28
29 explicit UnitPCA9548AP(const uint8_t addr = DEFAULT_ADDRESS);
30 virtual ~UnitPCA9548AP() = default;
31
36 uint8_t currentChannel() const
37 {
38 return _current;
39 }
40
46 bool readChannel(uint8_t& bits);
47
48protected:
49 virtual Adapter* duplicate_adapter(const uint8_t ch) override;
50 virtual m5::hal::error::error_t select_channel(const uint8_t ch = 8) override;
51
52protected:
53 std::array<std::unique_ptr<Adapter>, +MAX_CHANNEL> _adapters{}; // For children
54 uint8_t _current{0xFF}; // current channel 0 ~ MAX_CHANNEL
55};
56
57} // namespace unit
58} // namespace m5
59#endif
PCA9548AP unit.
Definition unit_PCA9548AP.hpp:23
bool readChannel(uint8_t &bits)
Read channel status bits.
Definition unit_PCA9548AP.cpp:32
uint8_t currentChannel() const
Definition unit_PCA9548AP.hpp:36
Top level namespace of M5stack.
Unit-related namespace.