Refactor lighting with define guard and cammel case template variables (so the macros in monitor.ino don't overwrite)
This commit is contained in:
parent
1513e5af70
commit
12e756fef1
1 changed files with 15 additions and 10 deletions
23
Lighting.h
23
Lighting.h
|
@ -1,3 +1,6 @@
|
||||||
|
#ifndef Lighting_h
|
||||||
|
#define Lighting_h
|
||||||
|
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
#include "NaturalLight.h"
|
#include "NaturalLight.h"
|
||||||
#include "Weather.h"
|
#include "Weather.h"
|
||||||
|
@ -38,20 +41,20 @@ class Lighting {
|
||||||
public:
|
public:
|
||||||
Lighting(NaturalLight* _naturalLight, Weather* _weather, float cloudCoverLimit);
|
Lighting(NaturalLight* _naturalLight, Weather* _weather, float cloudCoverLimit);
|
||||||
|
|
||||||
template<uint8_t DATA_PIN, int LED_COUNT, int WHITE_PIN> void setupStrip() {
|
template<uint8_t dataPin, int ledCount, int whitePin> void setupStrip() {
|
||||||
_ledCount = LED_COUNT;
|
_ledCount = ledCount;
|
||||||
FastLED.addLeds<WS2811, DATA_PIN, GRB>(_leds, _ledCount).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
|
FastLED.addLeds<WS2811, dataPin, GRB>(_leds, _ledCount).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
|
||||||
_whitePin = WHITE_PIN;
|
_whitePin = whitePin;
|
||||||
pinMode(_whitePin, OUTPUT);
|
pinMode(_whitePin, OUTPUT);
|
||||||
analogWrite(_whitePin, 0);
|
analogWrite(_whitePin, 0);
|
||||||
_useStrip = true;
|
_useStrip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int R_PIN, int G_PIN, int B_PIN, int WHITE_PIN> void setupPWM() {
|
template<int rPin, int gPin, int bPin, int whitePin> void setupPWM() {
|
||||||
_rPin = R_PIN;
|
_rPin = rPin;
|
||||||
_gPin = G_PIN;
|
_gPin = gPin;
|
||||||
_bPin = B_PIN;
|
_bPin = bPin;
|
||||||
_whitePin = WHITE_PIN;
|
_whitePin = whitePin;
|
||||||
pinMode(_rPin, OUTPUT);
|
pinMode(_rPin, OUTPUT);
|
||||||
pinMode(_gPin, OUTPUT);
|
pinMode(_gPin, OUTPUT);
|
||||||
pinMode(_bPin, OUTPUT);
|
pinMode(_bPin, OUTPUT);
|
||||||
|
@ -67,3 +70,5 @@ class Lighting {
|
||||||
float getCurrentHeatIndex() { return _heatIndex; }
|
float getCurrentHeatIndex() { return _heatIndex; }
|
||||||
float getCurrentBrightness() { return _brightness; }
|
float getCurrentBrightness() { return _brightness; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue