M5Unit-RGB 0.1.0 git rev:b7fdb9a
Loading...
Searching...
No Matches
unit_WS2812.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_WS2812_HPP
11#define M5_UNIT_RGB_UNIT_WS2812_HPP
12
13#include "unit_LED.hpp"
14
15namespace m5 {
16namespace unit {
17
22class UnitWS2812 : public UnitLED {
23 M5_UNIT_COMPONENT_HPP_BUILDER(UnitWS2812, 0x00);
24
25public:
30 explicit UnitWS2812(const uint16_t num_of_pixels) : UnitLED(num_of_pixels, rgb::Order::grb24)
31 {
32 }
34 virtual ~UnitWS2812()
35 {
36 }
37
38protected:
39 virtual gpio::adapter_config_t rmt_config() override;
40 // Timing in ns (rgb::timing), converted to ticks at the actual RMT resolution.
41 // Same as SK6812 so SK6812 and WS2812 units can share one daisy chain
42 inline virtual gpio::m5_rmt_item_t rmt_item_one() override
43 {
44 return rmt_item_from_ns(rgb::timing::T1H_NS, rgb::timing::T1L_NS);
45 }
46 inline virtual gpio::m5_rmt_item_t rmt_item_zero() override
47 {
48 return rmt_item_from_ns(rgb::timing::T0H_NS, rgb::timing::T0L_NS);
49 }
50 inline virtual gpio::m5_rmt_item_t rmt_item_reset() override
51 {
52 return rmt_item_low_from_ns(rgb::timing::RESET_NS);
53 }
54};
55
56} // namespace unit
57} // namespace m5
58#endif
LED base unit.
virtual ~UnitWS2812()
Destructor.
Definition unit_WS2812.hpp:34
UnitWS2812(const uint16_t num_of_pixels)
Constructor.
Definition unit_WS2812.hpp:30
Top level namespace of M5Stack.
For M5Unit-RGB.
Unit-related namespace.
LED base unit for M5UnitUnified.