Put in hack to reduce flickering issue.
This commit is contained in:
parent
c0c4e75db0
commit
ccbbf6e4c1
3 changed files with 23 additions and 16 deletions
30
Lighting.cpp
30
Lighting.cpp
|
@ -42,21 +42,27 @@ float Lighting::getPaletteBrightness(){
|
|||
}
|
||||
|
||||
void Lighting::updateRGB(int now) {
|
||||
CRGB colour = ColorFromPalette(_sunrise, getPaletteHeatIndex(now), getPaletteBrightness(), LINEARBLEND);
|
||||
byte heatIndex = getPaletteHeatIndex(now);
|
||||
byte brightness = getPaletteBrightness();
|
||||
if (heatIndex != _lastHeatIndex || brightness!=_lastBrightness) {
|
||||
CRGB colour = ColorFromPalette(_sunrise, heatIndex, brightness, LINEARBLEND);
|
||||
|
||||
if (_weather->getCondition() == WeatherCondition::Thunder && millis() >= _nextLightningFlash) {
|
||||
int flashes = random8(2, 8);
|
||||
for (int i = 0; i < flashes; i++) {
|
||||
FastLED.showColor(CRGB::White);
|
||||
delay(random8(10, 20));
|
||||
FastLED.showColor(colour);
|
||||
delay(random8(40, 80));
|
||||
if (_weather->getCondition() == WeatherCondition::Thunder && millis() >= _nextLightningFlash) {
|
||||
int flashes = random8(2, 8);
|
||||
for (int i = 0; i < flashes; i++) {
|
||||
FastLED.showColor(CRGB::White);
|
||||
delay(random8(10, 20));
|
||||
FastLED.showColor(colour);
|
||||
delay(random8(40, 80));
|
||||
}
|
||||
_nextLightningFlash = millis() + (random8(1, 60) * 1000);
|
||||
}
|
||||
_nextLightningFlash = millis() + (random8(1, 60) * 1000);
|
||||
}
|
||||
|
||||
fill_solid(_leds, _ledCount, colour);
|
||||
FastLED.show();
|
||||
fill_solid(_leds, _ledCount, colour);
|
||||
FastLED.show();
|
||||
}
|
||||
_lastHeatIndex = heatIndex;
|
||||
_lastBrightness = brightness;
|
||||
}
|
||||
|
||||
void Lighting::updateWhite(){
|
||||
|
|
|
@ -21,6 +21,7 @@ class Lighting {
|
|||
long _nextLightningFlash = 0;
|
||||
float _heatIndex;
|
||||
float _brightness;
|
||||
byte _lastHeatIndex, _lastBrightness;
|
||||
|
||||
float _currentHeatIndex();
|
||||
float getIndexMultiplier(int now, int startTime, int endTime, bool swap);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include <FastLED.h>
|
||||
#include<FastLED.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Networking.h"
|
||||
|
@ -18,7 +17,7 @@
|
|||
|
||||
#define RGB_PIN D3
|
||||
#define WHITE_PIN D2
|
||||
#define LED_COUNT 39
|
||||
#define LED_COUNT 41
|
||||
#define LATITUDE "20.548103"
|
||||
#define LONGITUDE "96.916835"
|
||||
#define TIMEZONE_OFFSET 30600 // 8.5 hours in seconds
|
||||
|
@ -65,10 +64,11 @@ void doLighting() {
|
|||
}
|
||||
|
||||
EVERY_N_SECONDS(1) {
|
||||
_lighting.update(time(nullptr));
|
||||
publishFloat(LIGHT_INDEX_TOPIC, _lighting.getCurrentHeatIndex());
|
||||
publishFloat(BRIGHTNESS_TOPIC, _lighting.getCurrentBrightness());
|
||||
}
|
||||
|
||||
_lighting.update(time(nullptr));
|
||||
}
|
||||
|
||||
void publishReadings(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue