M5Unit-RGB 0.1.0 git rev:b7fdb9a
Loading...
Searching...
No Matches
unit_SK6812.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_SK6812_HPP
11#define M5_UNIT_RGB_UNIT_SK6812_HPP
12
13#include "unit_LED.hpp"
14
15namespace m5 {
16namespace unit {
17
22class UnitSK6812 : public UnitLED {
23 M5_UNIT_COMPONENT_HPP_BUILDER(UnitSK6812, 0x00);
24
25protected:
26 UnitSK6812(const uint16_t num_of_pixels, const rgb::Order order) : UnitLED(num_of_pixels, order)
27 {
28 }
29
30public:
32 virtual ~UnitSK6812()
33 {
34 }
35
36protected:
37 virtual gpio::adapter_config_t rmt_config() override;
38 // Timing in ns (rgb::timing), converted to ticks at the actual RMT resolution.
39 // Same as WS2812 so SK6812 and WS2812 units can share one daisy chain
40 inline virtual gpio::m5_rmt_item_t rmt_item_one() override
41 {
42 return rmt_item_from_ns(rgb::timing::T1H_NS, rgb::timing::T1L_NS);
43 }
44 inline virtual gpio::m5_rmt_item_t rmt_item_zero() override
45 {
46 return rmt_item_from_ns(rgb::timing::T0H_NS, rgb::timing::T0L_NS);
47 }
48 inline virtual gpio::m5_rmt_item_t rmt_item_reset() override
49 {
50 return rmt_item_low_from_ns(rgb::timing::RESET_NS);
51 }
52};
53
58class UnitSK6812GRB : public UnitSK6812 {
59 M5_UNIT_COMPONENT_HPP_BUILDER(UnitSK6812GRB, 0x00);
60
61public:
66 explicit UnitSK6812GRB(const uint16_t num_of_pixels) : UnitSK6812(num_of_pixels, rgb::Order::grb24)
67 {
68 }
71 {
72 }
73};
74
79class UnitSK6812GRBW : public UnitSK6812 {
80 M5_UNIT_COMPONENT_HPP_BUILDER(UnitSK6812GRBW, 0x00);
81
82public:
87 explicit UnitSK6812GRBW(const uint16_t num_of_pixels) : UnitSK6812(num_of_pixels, rgb::Order::grbw32)
88 {
89 }
92 {
93 }
94};
95
96} // namespace unit
97} // namespace m5
98#endif
rgb::Order order() const
Color order.
Definition unit_LED.hpp:237
UnitSK6812GRB(const uint16_t num_of_pixels)
Constructor.
Definition unit_SK6812.hpp:66
virtual ~UnitSK6812GRB()
Destructor.
Definition unit_SK6812.hpp:70
UnitSK6812GRBW(const uint16_t num_of_pixels)
Constructor.
Definition unit_SK6812.hpp:87
virtual ~UnitSK6812GRBW()
Destructor.
Definition unit_SK6812.hpp:91
SK6812 base Unit.
virtual ~UnitSK6812()
Destructor.
Definition unit_SK6812.hpp:32
Top level namespace of M5Stack.
For M5Unit-RGB.
Unit-related namespace.
LED base unit for M5UnitUnified.