M5Unit-RGB 0.1.0 git rev:b7fdb9a
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
15namespace m5 {
16namespace unit {
17
24template <class BaseClass>
25class UnitHexLED37 : public BaseClass {
26 static_assert(std::is_base_of<UnitLED, BaseClass>::value, "BaseClass must derive from UnitLED");
27 M5_UNIT_COMPONENT_HPP_BUILDER(UnitHexLED37, 0x00);
28
29public:
30 using BaseClass::BaseClass;
32 UnitHexLED37() : BaseClass(37)
33 {
34 }
35
40 inline virtual uint16_t width() const override
41 {
42 return 4;
43 }
48 inline virtual uint16_t height() const override
49 {
50 return 7;
51 }
52
57 inline virtual uint8_t maxRotation() const override
58 {
59 // 0:0 1:60 2:120 3:180 4:240 5:300
60 return 6;
61 }
62
63protected:
64 virtual uint16_t index_of(const uint16_t n) const override;
65};
66
71class UnitHex : public UnitHexLED37<UnitSK6812GRB> {
72 M5_UNIT_COMPONENT_HPP_BUILDER(UnitHex, 0x00);
73
74public:
77 {
78 auto ccfg = component_config();
79 ccfg.max_children = 1; // Can connect 1 Unit
80 component_config(ccfg);
81 }
82};
83
88class UnitNeoHex : public UnitHexLED37<UnitSK6812GRB> {
89 M5_UNIT_COMPONENT_HPP_BUILDER(UnitNeoHex, 0x00);
90
91public:
94 {
95 auto ccfg = component_config();
96 ccfg.max_children = 1; // Can connect 1 Unit
97 component_config(ccfg);
98 }
99};
100
101} // namespace unit
102} // namespace m5
103#endif
UnitHex()
Constructor.
Definition unit_Hex.hpp:76
Unit comprising 37 LED hexagons.
UnitHexLED37()
Default constructor (37 LEDs)
Definition unit_Hex.hpp:32
virtual uint16_t width() const override
Edge length of the hexagon (4 LEDs per edge)
Definition unit_Hex.hpp:40
virtual uint8_t maxRotation() const override
Get the max rotation (6 steps: 0/60/120/180/240/300 deg)
Definition unit_Hex.hpp:57
virtual uint16_t height() const override
Number of rows in the hexagon.
Definition unit_Hex.hpp:48
UnitNeoHex()
Constructor.
Definition unit_Hex.hpp:93
Top level namespace of M5Stack.
Unit-related namespace.
SK6812 unit for M5UnitUnified.