M5Unit-RGB 0.0.2 git rev:51dfbe6
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 inline virtual gpio::m5_rmt_item_t rmt_item_one() override
41 {
42 return gpio::m5_rmt_item_t{{14, 1, 12, 0}};
43 }
44 inline virtual gpio::m5_rmt_item_t rmt_item_zero() override
45 {
46 return gpio::m5_rmt_item_t{{7, 1, 16, 0}};
47 }
48 inline virtual gpio::m5_rmt_item_t rmt_item_reset() override
49 {
50 // return gpio::m5_rmt_item_t{{1000, 0, 0, 0}}; // 50us
51 return gpio::m5_rmt_item_t{{1600, 0, 0, 0}}; // Same as SK6812 (Measures for SK/WS mixed daisy chain)
52 }
53};
54
55} // namespace unit
56} // namespace m5
57#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.