M5Unit-RGB 0.0.2 git rev:51dfbe6
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;
33 UnitHexLED37() : BaseClass(37)
34 {
35 }
36
41 inline virtual uint16_t width() const override
42 {
43 return 4;
44 }
49 inline virtual uint16_t height() const override
50 {
51 return 7;
52 }
53
58 inline virtual uint8_t maxRotation() const override
59 {
60 // 0:0 1:60 2:120 3:180 4:240 5:300
61 return 6;
62 }
63
64protected:
65 virtual uint16_t index_of(const uint16_t n) const override;
66};
67
72class UnitHex : public UnitHexLED37<UnitWS2812> {
73 M5_UNIT_COMPONENT_HPP_BUILDER(UnitHex, 0x00);
74
75public:
78 {
79 auto ccfg = component_config();
80 ccfg.max_children = 1; // Can connect 1 Unit
81 component_config(ccfg);
82 }
83};
84
89class UnitNeoHex : public UnitHexLED37<UnitSK6812GRB> {
90 M5_UNIT_COMPONENT_HPP_BUILDER(UnitNeoHex, 0x00);
91
92public:
95 {
96 auto ccfg = component_config();
97 ccfg.max_children = 1; // Can connect 1 Unit
98 component_config(ccfg);
99 }
100};
101
102} // namespace unit
103} // namespace m5
104#endif
UnitHex()
Constructor.
Definition unit_Hex.hpp:77
Unit comprising 37 LED hexagons.
UnitHexLED37()
Default constructor (37 LEDs)
Definition unit_Hex.hpp:33
virtual uint16_t width() const override
Edge length of the hexagon (4 LEDs per edge)
Definition unit_Hex.hpp:41
virtual uint8_t maxRotation() const override
Get the max rotation (6 steps: 0/60/120/180/240/300 deg)
Definition unit_Hex.hpp:58
virtual uint16_t height() const override
Number of rows in the hexagon.
Definition unit_Hex.hpp:49
UnitNeoHex()
Constructor.
Definition unit_Hex.hpp:94
Top level namespace of M5Stack.
Unit-related namespace.
SK6812 unit for M5UnitUnified.
WS2812 unit for M5UnitUnified.