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
|
@ -42,7 +42,10 @@ 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);
|
||||
|
@ -58,6 +61,9 @@ void Lighting::updateRGB(int now) {
|
|||
fill_solid(_leds, _ledCount, colour);
|
||||
FastLED.show();
|
||||
}
|
||||
_lastHeatIndex = heatIndex;
|
||||
_lastBrightness = brightness;
|
||||
}
|
||||
|
||||
void Lighting::updateWhite(){
|
||||
float brightness = (_heatIndex - 0.5) / 0.5;
|
||||
|
|
|
@ -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,4 +1,3 @@
|
|||
|
||||
#include<FastLED.h>
|
||||
#include <time.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