Browse Source

Option to disable continuous light color saving, avoiding flickering

fastled
Xose Pérez 7 years ago
parent
commit
b07660c3d7
3 changed files with 22 additions and 3 deletions
  1. +4
    -0
      code/espurna/config/general.h
  2. +11
    -3
      code/espurna/light.ino
  3. +7
    -0
      code/espurna/web.ino

+ 4
- 0
code/espurna/config/general.h View File

@ -486,6 +486,10 @@ PROGMEM const char* const custom_reset_string[] = {
// 4 channels => RGBW // 4 channels => RGBW
// 5 channels => RGBWW // 5 channels => RGBWW
#ifndef LIGHT_SAVE_ENABLED
#define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
#endif
#define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
#define LIGHT_PWM_FREQUENCY 1000 // PWM frequency #define LIGHT_PWM_FREQUENCY 1000 // PWM frequency
#define LIGHT_MAX_PWM 4095 // Maximum PWM value #define LIGHT_MAX_PWM 4095 // Maximum PWM value


+ 11
- 3
code/espurna/light.ino View File

@ -272,7 +272,7 @@ void _lightColorSave() {
void _lightColorRestore() { void _lightColorRestore() {
for (unsigned int i=0; i < _channels.size(); i++) { for (unsigned int i=0; i < _channels.size(); i++) {
_channels[i].value = getSetting("ch", i, 0).toInt();
_channels[i].value = getSetting("ch", i, i==0 ? 255 : 0).toInt();
} }
_brightness = getSetting("brightness", LIGHT_MAX_BRIGHTNESS).toInt(); _brightness = getSetting("brightness", LIGHT_MAX_BRIGHTNESS).toInt();
lightUpdate(false, false); lightUpdate(false, false);
@ -415,11 +415,19 @@ void lightUpdate(bool save, bool forward) {
} }
#endif #endif
// Delay saving to EEPROM 5 seconds to avoid wearing it out unnecessarily
if (save) colorTicker.once(LIGHT_SAVE_DELAY, _lightColorSave);
#if LIGHT_SAVE_ENABLED
// Delay saving to EEPROM 5 seconds to avoid wearing it out unnecessarily
if (save) colorTicker.once(LIGHT_SAVE_DELAY, _lightColorSave);
#endif
}; };
#if LIGHT_SAVE_ENABLED == 0
void lightSave() {
_lightColorSave();
}
#endif
void lightState(bool state) { void lightState(bool state) {
_lightState = state; _lightState = state;
} }


+ 7
- 0
code/espurna/web.ino View File

@ -428,6 +428,13 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
#if POWER_PROVIDER != POWER_PROVIDER_NONE #if POWER_PROVIDER != POWER_PROVIDER_NONE
powerConfigure(); powerConfigure();
#endif #endif
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
#if LIGHT_SAVE_ENABLED == 0
lightSave();
#endif
#endif
#if NTP_SUPPORT #if NTP_SUPPORT
if (changedNTP) ntpConnect(); if (changedNTP) ntpConnect();
#endif #endif


Loading…
Cancel
Save