My Project
 All Classes Functions Variables Pages
WS2812.h
1 
2 
3 #ifndef MAIN_WS2812_H_
4 #define MAIN_WS2812_H_
5 #include <stdint.h>
6 #include <driver/rmt.h>
7 #include <driver/gpio.h>
8 
12 typedef struct {
16  uint8_t red;
20  uint8_t green;
24  uint8_t blue;
25 } pixel_t;
26 
27 
49 class WS2812 {
50 public:
51  WS2812(gpio_num_t gpioNum, uint16_t pixelCount, int channel = RMT_CHANNEL_0);
52  void show();
53  void setColorOrder(char* order);
54  void setPixel(uint16_t index, uint8_t red, uint8_t green, uint8_t blue);
55  void setPixel(uint16_t index, pixel_t pixel);
56  void setPixel(uint16_t index, uint32_t pixel);
57  void setHSBPixel(uint16_t index, uint16_t hue, uint8_t saturation, uint8_t brightness);
58  void clear();
59  virtual ~WS2812();
60 
61 private:
62  char* colorOrder;
63  uint16_t pixelCount;
64  rmt_channel_t channel;
65  rmt_item32_t* items;
66  pixel_t* pixels;
67 
68 };
69 
70 #endif /* MAIN_WS2812_H_ */
WS2812(gpio_num_t gpioNum, uint16_t pixelCount, int channel=RMT_CHANNEL_0)
Construct a wrapper for the pixels.
Definition: WS2812.cpp:107
void setHSBPixel(uint16_t index, uint16_t hue, uint8_t saturation, uint8_t brightness)
Set the given pixel to the specified HSB color.
Definition: WS2812.cpp:257
Driver for WS2812/NeoPixel data.
Definition: WS2812.h:49
void setPixel(uint16_t index, uint8_t red, uint8_t green, uint8_t blue)
Set the given pixel to the specified color.
Definition: WS2812.cpp:210
void show()
Show the current Neopixel data.
Definition: WS2812.cpp:151
void setColorOrder(char *order)
Set the color order of data sent to the LEDs.
Definition: WS2812.cpp:193
A data type representing the color of a pixel.
Definition: SmartLED.h:14
void clear()
Clear all the pixel colors.
Definition: WS2812.cpp:322
virtual ~WS2812()
Class instance destructor.
Definition: WS2812.cpp:334