Refactor lighting with define guard and cammel case template variables (so the macros in monitor.ino don't overwrite)

This commit is contained in:
Robert Marshall 2019-03-03 21:35:55 +00:00
parent 1513e5af70
commit 12e756fef1

View file

@ -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