Remove analog flicker (#678)
* remove analog LED flicker run SetRgbwPwm from main loop and with GetPixelColor(0) to get all effects using fade_out() working. * correct unintended bitwise AND to logical AND * Update analogLastShow * new Arduino Core WaveForm library included * new Arduino Core only for 8266 * correct formating + define for MQTT_KEEP_ALIVE * fix for ESP32 * reduce scope of variable "done" * call analogWrite only if Color or Bri did change * Remove duplicate wifi sleep code Co-authored-by: Aircoookie <cschwinne@gmail.com>
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
#define NpbWrapper_h
|
||||
|
||||
//PIN CONFIGURATION
|
||||
#ifndef LEDPIN
|
||||
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
|
||||
#endif
|
||||
//#define USE_APA102 // Uncomment for using APA102 LEDs.
|
||||
//#define USE_WS2801 // Uncomment for using WS2801 LEDs (make sure you have NeoPixelBus v2.5.6 or newer)
|
||||
//#define USE_LPD8806 // Uncomment for using LPD8806
|
||||
@@ -164,7 +166,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
#else // ESP8266
|
||||
//init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller
|
||||
//init PWM pins
|
||||
pinMode(RPIN, OUTPUT);
|
||||
pinMode(GPIN, OUTPUT);
|
||||
pinMode(BPIN, OUTPUT);
|
||||
@@ -185,9 +187,9 @@ public:
|
||||
void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w, uint8_t w2=0)
|
||||
{
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
ledcWrite(0, r); //RPIN
|
||||
ledcWrite(1, g); //GPIN
|
||||
ledcWrite(2, b); //BPIN
|
||||
ledcWrite(0, r);
|
||||
ledcWrite(1, g);
|
||||
ledcWrite(2, b);
|
||||
switch (_type) {
|
||||
case NeoPixelType_Grb: break;
|
||||
#ifdef WLED_USE_5CH_LEDS
|
||||
@@ -196,7 +198,7 @@ public:
|
||||
case NeoPixelType_Grbw: ledcWrite(3, w); break;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#else // ESP8266
|
||||
analogWrite(RPIN, r);
|
||||
analogWrite(GPIN, g);
|
||||
analogWrite(BPIN, b);
|
||||
@@ -227,11 +229,6 @@ public:
|
||||
switch (_type) {
|
||||
case NeoPixelType_Grb: {
|
||||
_pGrb->SetPixelColor(indexPixel, RgbColor(color.R,color.G,color.B));
|
||||
#ifdef WLED_USE_ANALOG_LEDS
|
||||
if (indexPixel != 0) return; //set analog LEDs from first pixel
|
||||
byte b = _pGrb->GetBrightness();
|
||||
SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case NeoPixelType_Grbw: {
|
||||
@@ -240,28 +237,6 @@ public:
|
||||
#else
|
||||
_pGrbw->SetPixelColor(indexPixel, color);
|
||||
#endif
|
||||
#ifdef WLED_USE_ANALOG_LEDS
|
||||
if (indexPixel != 0) return; //set analog LEDs from first pixel
|
||||
byte b = _pGrbw->GetBrightness();
|
||||
// check color values for Warm / Cold white mix (for RGBW) // EsplanexaDevice.cpp
|
||||
#ifdef WLED_USE_5CH_LEDS
|
||||
if (color.R == 255 & color.G == 255 && color.B == 255 && color.W == 255) {
|
||||
SetRgbwPwm(0, 0, 0, 0, color.W * b / 255);
|
||||
} else if (color.R == 127 & color.G == 127 && color.B == 127 && color.W == 255) {
|
||||
SetRgbwPwm(0, 0, 0, color.W * b / 512, color.W * b / 255);
|
||||
} else if (color.R == 0 & color.G == 0 && color.B == 0 && color.W == 255) {
|
||||
SetRgbwPwm(0, 0, 0, color.W * b / 255, 0);
|
||||
} else if (color.R == 130 & color.G == 90 && color.B == 0 && color.W == 255) {
|
||||
SetRgbwPwm(0, 0, 0, color.W * b / 255, color.W * b / 512);
|
||||
} else if (color.R == 255 & color.G == 153 && color.B == 0 && color.W == 255) {
|
||||
SetRgbwPwm(0, 0, 0, color.W * b / 255, 0);
|
||||
} else { // not only white colors
|
||||
SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, color.W * b / 255);
|
||||
}
|
||||
#else
|
||||
SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, color.W * b / 255);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user