Browse Source

Option to prevent 100% PWM output

fastled
Xose Pérez 7 years ago
parent
commit
6e809c7baf
3 changed files with 18 additions and 2 deletions
  1. +2
    -0
      README.md
  2. +14
    -0
      code/espurna/config/general.h
  3. +2
    -2
      code/espurna/light.ino

+ 2
- 0
README.md View File

@ -112,6 +112,8 @@ Here is the list of supported hardware. For more information please refer to the
|![EXS Wifi Relay v3.1](images/devices/exs-wifi-relay-v31.jpg)|||
|**EXS Wifi Relay v3.1**|||
**Other supported boards:** Itead Sonoff LED, Huacanxing H802, WiOn 50055, ManCaveMade ESP-Live, InterMitTech QuinLED 2.6, Arilux AL-LC06, Xenon SM-PW702U, Authometion LYT8266.
## License
Copyright (C) 2016-2017 by Xose Pérez (@xoseperez)


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

@ -491,9 +491,23 @@ PROGMEM const char* const custom_reset_string[] = {
#endif
#define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
#ifndef LIGHT_PWM_FREQUENCY
#define LIGHT_PWM_FREQUENCY 1000 // PWM frequency
#endif
#ifndef LIGHT_MAX_PWM
#define LIGHT_MAX_PWM 4095 // Maximum PWM value
#endif
#ifndef LIGHT_LIMIT_PWM
#define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
#endif
#ifndef LIGHT_MAX_VALUE
#define LIGHT_MAX_VALUE 255 // Maximum light value
#endif
#define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
#define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
#define LIGHT_USE_WHITE 0 // Use white channel whenever RGB have the same value


+ 2
- 2
code/espurna/light.ino View File

@ -197,8 +197,8 @@ void _fromMireds(unsigned long mireds) {
unsigned int _toPWM(unsigned long value, bool bright, bool gamma, bool reverse) {
value = constrain(value, 0, LIGHT_MAX_VALUE);
if (bright) value *= ((float) _brightness / LIGHT_MAX_BRIGHTNESS);
unsigned int pwm = gamma ? gamma_table[value] : map(value, 0, LIGHT_MAX_VALUE, 0, LIGHT_MAX_PWM);
if (reverse) pwm = LIGHT_MAX_PWM - pwm;
unsigned int pwm = gamma ? gamma_table[value] : map(value, 0, LIGHT_MAX_VALUE, 0, LIGHT_LIMIT_PWM);
if (reverse) pwm = LIGHT_LIMIT_PWM - pwm;
return pwm;
}


Loading…
Cancel
Save