mirror of
https://github.com/wled/WLED.git
synced 2025-07-26 20:26:34 +00:00
Merge pull request #568 from Def3nder/ESP32solidRGB
ESP32 support for solid (analog) RGB(W) stripes
This commit is contained in:
commit
44f4bd6e62
@ -197,7 +197,7 @@ build_flags =
|
|||||||
${common.build_flags}
|
${common.build_flags}
|
||||||
${common:esp8266_1M.build_flags}
|
${common:esp8266_1M.build_flags}
|
||||||
-D WLED_DISABLE_HUESYNC
|
-D WLED_DISABLE_HUESYNC
|
||||||
-D WLED_ENABLE_ANALOG_LEDS
|
-D WLED_USE_ANALOG_LEDS
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ build_flags =
|
|||||||
${common.build_flags}
|
${common.build_flags}
|
||||||
${common:esp8266_1M.build_flags}
|
${common:esp8266_1M.build_flags}
|
||||||
-D WLED_DISABLE_HUESYNC
|
-D WLED_DISABLE_HUESYNC
|
||||||
-D WLED_ENABLE_ANALOG_LEDS
|
-D WLED_USE_ANALOG_LEDS
|
||||||
-D WLED_USE_H801
|
-D WLED_USE_H801
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
@ -226,7 +226,7 @@ build_flags =
|
|||||||
${common.build_flags}
|
${common.build_flags}
|
||||||
${common:esp8266_1M.build_flags}
|
${common:esp8266_1M.build_flags}
|
||||||
-D WLED_DISABLE_HUESYNC
|
-D WLED_DISABLE_HUESYNC
|
||||||
-D WLED_ENABLE_ANALOG_LEDS
|
-D WLED_USE_ANALOG_LEDS
|
||||||
-D WLED_USE_H801
|
-D WLED_USE_H801
|
||||||
-D WLED_ENABLE_5CH_LEDS
|
-D WLED_ENABLE_5CH_LEDS
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
@ -130,30 +130,60 @@ public:
|
|||||||
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, LEDPIN);
|
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, LEDPIN);
|
||||||
#endif
|
#endif
|
||||||
_pGrbw->Begin();
|
_pGrbw->Begin();
|
||||||
|
|
||||||
#ifdef WLED_USE_ANALOG_LEDS
|
|
||||||
pinMode(WPIN, OUTPUT);
|
|
||||||
#ifdef WLED_USE_5CH_LEDS
|
|
||||||
pinMode(W2PIN, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WLED_USE_ANALOG_LEDS
|
#ifdef WLED_USE_ANALOG_LEDS
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
ledcSetup(0, 5000, 8);
|
||||||
|
ledcAttachPin(RPIN, 0);
|
||||||
|
ledcSetup(1, 5000, 8);
|
||||||
|
ledcAttachPin(GPIN, 1);
|
||||||
|
ledcSetup(2, 5000, 8);
|
||||||
|
ledcAttachPin(BPIN, 2);
|
||||||
|
if(_type == NeoPixelType_Grbw)
|
||||||
|
{
|
||||||
|
ledcSetup(3, 5000, 8);
|
||||||
|
ledcAttachPin(WPIN, 3);
|
||||||
|
#ifdef WLED_USE_5CH_LEDS
|
||||||
|
ledcSetup(4, 5000, 8);
|
||||||
|
ledcAttachPin(W2PIN, 4);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else // ESP8266
|
||||||
//init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller
|
//init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller
|
||||||
pinMode(RPIN, OUTPUT);
|
pinMode(RPIN, OUTPUT);
|
||||||
pinMode(GPIN, OUTPUT);
|
pinMode(GPIN, OUTPUT);
|
||||||
pinMode(BPIN, OUTPUT);
|
pinMode(BPIN, OUTPUT);
|
||||||
|
if(_type == NeoPixelType_Grbw)
|
||||||
|
{
|
||||||
|
pinMode(WPIN, OUTPUT);
|
||||||
|
#ifdef WLED_USE_5CH_LEDS
|
||||||
|
pinMode(W2PIN, OUTPUT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
analogWriteRange(255); //same range as one RGB channel
|
analogWriteRange(255); //same range as one RGB channel
|
||||||
analogWriteFreq(880); //PWM frequency proven as good for LEDs
|
analogWriteFreq(880); //PWM frequency proven as good for LEDs
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WLED_USE_ANALOG_LEDS
|
#ifdef WLED_USE_ANALOG_LEDS
|
||||||
void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w, uint8_t w2=0)
|
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
|
||||||
|
switch (_type) {
|
||||||
|
case NeoPixelType_Grb: break;
|
||||||
|
#ifdef WLED_USE_5CH_LEDS
|
||||||
|
case NeoPixelType_Grbw: ledcWrite(3, w); ledcWrite(4, w2); break;
|
||||||
|
#else
|
||||||
|
case NeoPixelType_Grbw: ledcWrite(3, w); break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
analogWrite(RPIN, r);
|
analogWrite(RPIN, r);
|
||||||
analogWrite(GPIN, g);
|
analogWrite(GPIN, g);
|
||||||
analogWrite(BPIN, b);
|
analogWrite(BPIN, b);
|
||||||
@ -165,6 +195,7 @@ public:
|
|||||||
case NeoPixelType_Grbw: analogWrite(WPIN, w); break;
|
case NeoPixelType_Grbw: analogWrite(WPIN, w); break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user