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 "NaturalLight.h"
#include "Weather.h"
@ -38,20 +41,20 @@ class Lighting {
public:
Lighting(NaturalLight* _naturalLight, Weather* _weather, float cloudCoverLimit);
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;
template<uint8_t dataPin, int ledCount, int whitePin> void setupStrip() {
_ledCount = ledCount;
FastLED.addLeds<WS2811, dataPin, GRB>(_leds, _ledCount).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
_whitePin = whitePin;
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;
template<int rPin, int gPin, int bPin, int whitePin> void setupPWM() {
_rPin = rPin;
_gPin = gPin;
_bPin = bPin;
_whitePin = whitePin;
pinMode(_rPin, OUTPUT);
pinMode(_gPin, OUTPUT);
pinMode(_bPin, OUTPUT);
@ -67,3 +70,5 @@ class Lighting {
float getCurrentHeatIndex() { return _heatIndex; }
float getCurrentBrightness() { return _brightness; }
};
#endif