M5Unit-RGB 0.0.1 git rev:55cb205
Loading...
Searching...
No Matches
unit_Hex.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_RGB_UNIT_HEX_HPP
11#define M5_UNIT_RGB_UNIT_HEX_HPP
12
13#include "unit_SK6812.hpp"
14#include "unit_WS2812.hpp"
15
16namespace m5 {
17namespace unit {
18
25template <class BaseClass>
26class UnitHexLED37 : public BaseClass {
27 static_assert(std::is_base_of<UnitLED, BaseClass>::value, "BaseClass must derive from UnitLED");
28 M5_UNIT_COMPONENT_HPP_BUILDER(UnitHexLED37, 0x00);
29
30public:
31 using BaseClass::BaseClass;
32 UnitHexLED37() : BaseClass(37)
33 {
34 }
35 virtual uint16_t index_of(const uint16_t n) const override;
36
38 inline virtual uint16_t width() const override
39 {
40 return 4;
41 }
43 inline virtual uint16_t height() const override
44 {
45 return 7;
46 }
47
48 inline virtual uint8_t maxRotation() const
49 {
50 // 0:0 1:60 2:120 3:180 4:240 5:300
51 return 6;
52 }
53};
54
59class UnitHex : public UnitHexLED37<UnitWS2812> {
60 M5_UNIT_COMPONENT_HPP_BUILDER(UnitHex, 0x00);
61
62public:
63 UnitHex() : UnitHexLED37<UnitWS2812>()
64 {
65 auto ccfg = component_config();
66 ccfg.max_children = 1; // Can connect 1 Unit
67 component_config(ccfg);
68 }
69};
70
75class UnitNeoHex : public UnitHexLED37<UnitSK6812GRB> {
76 M5_UNIT_COMPONENT_HPP_BUILDER(UnitNeoHex, 0x00);
77
78public:
79 UnitNeoHex() : UnitHexLED37<UnitSK6812GRB>()
80 {
81 auto ccfg = component_config();
82 ccfg.max_children = 1; // Can connect 1 Unit
83 component_config(ccfg);
84 }
85};
86
87} // namespace unit
88} // namespace m5
89#endif
virtual uint16_t width() const override
Edge length of the hexagon (4 LEDs per edge)
Definition unit_Hex.hpp:38
virtual uint16_t height() const override
Number of rows in the hexagon (7 rows)
Definition unit_Hex.hpp:43
Top level namespace of M5stack.
Unit-related namespace.
SK6812 unit for M5UnitUnified.
WS2812 unit for M5UnitUnified.