Add ability for PWM controlled RGB.
This commit is contained in:
parent
059ebad84e
commit
0e18b3371b
3 changed files with 71 additions and 18 deletions
29
Lighting.h
29
Lighting.h
|
@ -12,7 +12,7 @@ DEFINE_GRADIENT_PALETTE(_sunrise_p) {
|
|||
};
|
||||
|
||||
class Lighting {
|
||||
int _ledCount, _whitePin;
|
||||
int _ledCount, _whitePin, _rPin, _gPin, _bPin;
|
||||
NaturalLight* _naturalLight;
|
||||
Weather* _weather;
|
||||
float _cloudCoverLimit;
|
||||
|
@ -22,6 +22,7 @@ class Lighting {
|
|||
float _heatIndex;
|
||||
float _brightness;
|
||||
byte _lastHeatIndex, _lastBrightness;
|
||||
bool _useStrip, _usePWM;
|
||||
|
||||
float _currentHeatIndex();
|
||||
float getIndexMultiplier(int now, int startTime, int endTime, bool swap);
|
||||
|
@ -29,17 +30,39 @@ class Lighting {
|
|||
float getPaletteHeatIndex(int time);
|
||||
float getBrightness();
|
||||
float getPaletteBrightness();
|
||||
int byteToAnalogue(byte input);
|
||||
void outputColour(CRGB colour);
|
||||
void updateRGB(int now);
|
||||
void updateWhite();
|
||||
|
||||
public:
|
||||
Lighting(int ledCount, NaturalLight* _naturalLight, Weather* _weather, float cloudCoverLimit);
|
||||
Lighting(NaturalLight* _naturalLight, Weather* _weather, float cloudCoverLimit);
|
||||
|
||||
template<uint8_t DATA_PIN, int WHITE_PIN> void setup() {
|
||||
template<uint8_t DATA_PIN, int LED_COUNT, int WHITE_PIN> void setupStrip() {
|
||||
_ledCount = LED_COUNT;
|
||||
FastLED.addLeds<WS2811, DATA_PIN, GRB>(_leds, _ledCount).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
|
||||
_whitePin = WHITE_PIN;
|
||||
pinMode(_whitePin, OUTPUT);
|
||||
analogWrite(_whitePin, 0);
|
||||
_useStrip = true;
|
||||
}
|
||||
|
||||
template<int R_PIN, int G_PIN, int B_PIN, int WHITE_PIN> void setupPWM() {
|
||||
_rPin = R_PIN;
|
||||
_gPin = G_PIN;
|
||||
_bPin = B_PIN;
|
||||
_whitePin = WHITE_PIN;
|
||||
pinMode(_rPin, OUTPUT);
|
||||
pinMode(_gPin, OUTPUT);
|
||||
pinMode(_bPin, OUTPUT);
|
||||
pinMode(_whitePin, OUTPUT);
|
||||
analogWrite(_rPin, 0);
|
||||
analogWrite(_gPin, 0);
|
||||
analogWrite(_bPin, 0);
|
||||
analogWrite(_whitePin, 0);
|
||||
_usePWM = true;
|
||||
}
|
||||
|
||||
void update(int time);
|
||||
float getCurrentHeatIndex() { return _heatIndex; }
|
||||
float getCurrentBrightness() { return _brightness; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue