Move lighting logic in to its own class. Add definition guards around classes.
This commit is contained in:
parent
0052ac0169
commit
a3068a2d15
6 changed files with 111 additions and 64 deletions
38
Lighting.h
Normal file
38
Lighting.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include <FastLED.h>
|
||||
#include "NaturalLight.h"
|
||||
#include "Weather.h"
|
||||
|
||||
DEFINE_GRADIENT_PALETTE(_sunrise_p) {
|
||||
0, 0, 0, 0,
|
||||
128, 255, 128, 0,
|
||||
224, 255, 255, 0,
|
||||
240, 255, 255, 255, // Hack to get around LINEARBLEND problem (for now, hopefully)
|
||||
255, 255, 255, 2552
|
||||
};
|
||||
|
||||
class Lighting {
|
||||
int _ledCount;
|
||||
NaturalLight* _naturalLight;
|
||||
Weather* _weather;
|
||||
float _cloudCoverLimit;
|
||||
CRGB _leds;
|
||||
CRGBPalette16 _sunrise = _sunrise_p;
|
||||
long _nextLightningFlash = 0;
|
||||
float _heatIndex;
|
||||
float _brightness;
|
||||
|
||||
float _currentHeatIndex();
|
||||
float getIndexMultiplier(int now, int startTime, int endTime, bool swap);
|
||||
float getHeatIndex(int time);
|
||||
float getBrightness();
|
||||
|
||||
public:
|
||||
Lighting(int ledCount, NaturalLight* _naturalLight, Weather* _weather, float cloudCoverLimit);
|
||||
|
||||
template<uint8_t DATA_PIN> void setup() {
|
||||
FastLED.addLeds<WS2811, DATA_PIN, GRB>(&_leds, _ledCount).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
|
||||
}
|
||||
void update(int time);
|
||||
float getCurrentHeatIndex() { return _heatIndex; }
|
||||
float getCurrentBrightness() { return _brightness; }
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue