M5Unit-RGB 0.0.1 git rev:55cb205
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:
26 explicit UnitWS2812(const uint16_t num_of_pixels) : UnitLED(num_of_pixels, rgb::Order::grb24)
27 {
28 }
29 virtual ~UnitWS2812()
30 {
31 }
32
33protected:
34 virtual gpio::adapter_config_t rmt_config() override;
35 inline virtual gpio::m5_rmt_item_t rmt_item_one() override
36 {
37 return gpio::m5_rmt_item_t{{14, 1, 12, 0}};
38 }
39 inline virtual gpio::m5_rmt_item_t rmt_item_zero() override
40 {
41 return gpio::m5_rmt_item_t{{7, 1, 16, 0}};
42 }
43 inline virtual gpio::m5_rmt_item_t rmt_item_reset() override
44 {
45 // return gpio::m5_rmt_item_t{{1000, 0, 0, 0}}; // 50us
46 return gpio::m5_rmt_item_t{{1600, 0, 0, 0}}; // Same as SK6812 (Measures for SK/WS mixed daisy chain)
47 }
48};
49
50} // namespace unit
51} // namespace m5
52#endif
UnitLED(const uint16_t num_of_pixels, const rgb::Order order)
Constructor.
Definition unit_LED.hpp:188
Top level namespace of M5stack.
For M5Unit-RGB.
Unit-related namespace.
LED base unit for M5UnitUnified.
Order
Color order.
Definition unit_LED.hpp:65