-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputfastled.h
89 lines (75 loc) · 2.13 KB
/
outputfastled.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef __INC_AA_OUTPUT_FASTLED
#define __INC_AA_OUTPUT_FASTLED
#include <stdint.h>
#include <FastLED.h>
#include "color.h"
#include "outputabstract.h"
/**
* FastLED generic output
*
* See http://fastled.io/
*/
template <ESPIChipsets CHIPSET, EOrder RGB_ORDER>
class OutputFastLED : public OutputAbstract
{
public:
/**
* Constructs a new FastLED output
*
* @param numLEDs Number of LEDs
*/
OutputFastLED(int numLEDs) : OutputAbstract(numLEDs)
{
// Initialize the arrays and add the LEDs
_leds = new CRGB[numLEDs];
FastLED.addLeds<CHIPSET, RGB_ORDER>(_leds, numLEDs);
}
/**
* Destroys the FastLED output
*/
~OutputFastLED()
{
delete [] _leds;
}
virtual bool isSoftwareBrightness() override
{
// FastLED only supports global brightness at the hardware level on
// some chips. Per-pixel control isn't supported.
return true;
}
virtual void initialize() override
{
// Initialize the LED display
}
virtual void show() override
{
// Update the LED display
FastLED.show();
}
virtual void setBrightness(int index, uint8_t brightness) override
{
// Set LED to given brightness
// TODO: software brightness as per OutputAdafruitDotStar
}
virtual void setColor(int index, sCRGB color) override
{
// Set LED to given color, resetting brightness
// TODO: software brightness as per OutputAdafruitDotStar
_leds[index].setRGB(color.r, color.g, color.b);
}
virtual void setColor(int index, sCRGB color, uint8_t brightness) override
{
// Set LED to given color and brightness
_leds[index].setRGB(color.r, color.g, color.b);
// TODO: software brightness as per OutputAdafruitDotStar
}
virtual void setColor(int index, sCRGB color) override
{
// Set LED to given color, keeping brightness
// TODO: software brightness as per OutputAdafruitDotStar
_leds[index].setRGB(color.r, color.g, color.b);
}
private:
CRGB *_leds; ///< Internal array of LED values
};
#endif