# Analog LED Support

**URL:** <https://wled.discourse.group/t/analog-led-support/55>\
**Category:** Enhancements\
**Created:** [February 5, 2020, 1:01am UTC](https://wled.discourse.group/t/analog-led-support/55 "2020-02-05T01:01:10Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [March 4, 2020, 1:22am UTC](https://wled.discourse.group/t/analog-led-support/55/21 "2020-03-04T01:22:51Z")

</div>

Same with me and I have been as well! 😉

I need to read up on github about pull-requests. Until I figure that out…

It seems that the 8266 may not be up to it, so my code is for the ESP32. It’s currently for 4x RGB channels with the LED pins being `{15,2,4, 5,18,19, 21,22,23, 13,12,14}` or 4x RGBW `{15,2,4,5, 18,19,21,22, 13,12,14,27, 26,25,33,32}`.

Let me know if you want a bin file! I plan on making boards as well.

---

<div class="post-metadata">

**Author:** ![lanman1](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@lanman1](https://wled.discourse.group/u/lanman1)\
**Post date:** [March 25, 2020, 2:31pm UTC](https://wled.discourse.group/t/analog-led-support/55/22 "2020-03-25T14:31:54Z")

</div>

Any updates? What are you guys using to drive the LEDs?

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [March 25, 2020, 3:25pm UTC](https://wled.discourse.group/t/analog-led-support/55/23 "2020-03-25T15:25:19Z")

</div>

It’s working well! I’ve got my own boards that I am working on and I’ve also put wled on a Shelly RGBW2.

I think there is a single-channel BIN file on Git, too.

---

<div class="post-metadata">

**Author:** ![lanman1](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@lanman1](https://wled.discourse.group/u/lanman1)\
**Post date:** [March 26, 2020, 5:09pm UTC](https://wled.discourse.group/t/analog-led-support/55/24 "2020-03-26T17:09:21Z")

</div>

I may just use a high current ws2811 pixel driver board as I will have pixels as well. All of them I can find appear to be out of stock though.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [April 12, 2020, 1:38pm UTC](https://wled.discourse.group/t/analog-led-support/55/25 "2020-04-12T13:38:03Z")

</div>

In the latest source, the analog-led writing was moved _back_ to NpbWrapper.h from FX\_fcn.

Was that on purpose?

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [April 15, 2020, 12:58am UTC](https://wled.discourse.group/t/analog-led-support/55/26 "2020-04-15T00:58:12Z")

</div>

@Def3nder, @Aircoookie comments?

---

<div class="post-metadata">

**Author:** ![Aircoookie](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aircoookie/32/2_2.png) [@Aircoookie](https://wled.discourse.group/u/Aircoookie)\
**Post date:** [April 15, 2020, 10:19pm UTC](https://wled.discourse.group/t/analog-led-support/55/27 "2020-04-15T22:19:17Z")

</div>

Nothing was really moved… But I have to agree the function naming is very confusing, something I hadn’t really noticed before. `setRgbwPwm()` in fx\_fcn.h and `SetRgbwPwm()` both are relevant and implement part of the functionality, but are separate functions that do different thigns. I will rename one of them.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [April 15, 2020, 10:26pm UTC](https://wled.discourse.group/t/analog-led-support/55/28 "2020-04-15T22:26:14Z")

</div>

Okay. I was using a Def3nder branch. It was moved it to try and diminish the flickering.

> **[Def3nder/WLED](https://github.com/Def3nder/WLED/tree/removeAnalogFlicker/wled00)**
>
> Control WS2812B RGB LEDs with an ESP8266 over WiFi! - Def3nder/WLED

---

<div class="post-metadata">

**Author:** ![Def3nder](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/def3nder/32/62_2.png) [@Def3nder](https://wled.discourse.group/u/Def3nder)\
**Post date:** [April 27, 2020, 7:59am UTC](https://wled.discourse.group/t/analog-led-support/55/29 "2020-04-27T07:59:40Z")

</div>

Hi @Aircoookie, the reason of the simmilar (but different) naming was that the one function is public (can be used from other modules wether the other one can only be accessed by the wrapper. I used this style simmilar to the other functions in the wrapper that had the same name but different first-letter-case.

I’m sorry to not find time working on WLED because of personal problems.  
As WLED is my most interesting project I will (re-)start working when time comes …

Greetings from Berlin - stay healthy !

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 4, 2020, 12:55am UTC](https://wled.discourse.group/t/analog-led-support/55/30 "2020-05-04T00:55:28Z")

</div>

Should the above code still work in 0.10?

Not sure if it’s something I introduced, but it’s bombing out and saying it doesn’t know what ‘color’ or ‘b’ is.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 5, 2020, 12:52am UTC](https://wled.discourse.group/t/analog-led-support/55/31 "2020-05-05T00:52:16Z")

</div>

Now with actual error goodness. Kinda looks like what I’ve seen before when I missed a semicolon, closing brace, or mismatched loops. 😮 I can’t find anything like that, though.

sketch\FX\_fcn.cpp: In member function ‘void WS2812FX::setRgbwPwm()’:

FX\_fcn.cpp:859:21: error: ‘color’ was not declared in this scope

```
 bus->SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, color.W * b / 255);

                 ^

```

FX\_fcn.cpp:859:31: error: ‘b’ was not declared in this scope

```
 bus->SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, color.W * b / 255);
```

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 6, 2020, 1:21am UTC](https://wled.discourse.group/t/analog-led-support/55/32 "2020-05-06T01:21:36Z")

</div>

So, I moved the ledcWrite stuff back into NpbWrapper but only some things work. I need to turn up the Master Brightness slider almost all of the way to get the LEDs/relay to turn on, and then only colors with mostly blue work. ☹

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 7, 2020, 12:17pm UTC](https://wled.discourse.group/t/analog-led-support/55/33 "2020-05-07T12:17:02Z")

</div>

Anyone have any ideas on this?

---

<div class="post-metadata">

**Author:** ![huggy-d1](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/huggy-d1/32/51_2.png) [@huggy-d1](https://wled.discourse.group/u/huggy-d1)\
**Post date:** [May 8, 2020, 1:58pm UTC](https://wled.discourse.group/t/analog-led-support/55/34 "2020-05-08T13:58:06Z")

</div>

I thought @Aircookie fixed this issue a couple versions ago.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 8, 2020, 2:02pm UTC](https://wled.discourse.group/t/analog-led-support/55/35 "2020-05-08T14:02:12Z")

</div>

091 is working fine. Something is different in this regard in 010.

---

<div class="post-metadata">

**Author:** ![huggy-d1](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/huggy-d1/32/51_2.png) [@huggy-d1](https://wled.discourse.group/u/huggy-d1)\
**Post date:** [May 8, 2020, 2:28pm UTC](https://wled.discourse.group/t/analog-led-support/55/36 "2020-05-08T14:28:17Z")

</div>

In the current master for FX\_fcn.cpp, line 859 is not the above quoted text. If you update to the current master version, does that fix the problem?

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 8, 2020, 3:49pm UTC](https://wled.discourse.group/t/analog-led-support/55/37 "2020-05-08T15:49:47Z")

</div>

This is about 010 and getting these modifications into it. 😉

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 9, 2020, 3:57pm UTC](https://wled.discourse.group/t/analog-led-support/55/38 "2020-05-09T15:57:48Z")

</div>

I’ve tried going at this several ways and still not having any luck. The closest I’ve been is one of the four outputs working correctly.

Here is the code for one version…

```
void WS2812FX::setRgbwPwm(void) {
  uint32_t nowUp = millis(); // Be aware, millis() rolls over every 49 days
  if (nowUp - _analogLastShow < MIN_SHOW_DELAY) return;
  _analogLastShow = nowUp;

  for (uint16_t i = 0 ; i < 4 ; i++) {   
    RgbwColor color = bus->GetPixelColorRgbw(i);
    byte b = getBrightness();
    if (color == _analogLastColor && b == _analogLastBri){}
    else {
      ledcWrite(i*4+0, color.R*b/255); //RPIN
      ledcWrite(i*4+1, color.G*b/255); //GPIN
      ledcWrite(i*4+2, color.B*b/255); //BPIN
      ledcWrite(i*4+3, color.W*b/255); //BPIN
      _analogLastColor = color;
      _analogLastBri = b;
    }
  }
```

---

<div class="post-metadata">

**Author:** ![huggy-d1](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/huggy-d1/32/51_2.png) [@huggy-d1](https://wled.discourse.group/u/huggy-d1)\
**Post date:** [May 11, 2020, 3:59pm UTC](https://wled.discourse.group/t/analog-led-support/55/39 "2020-05-11T15:59:46Z")

</div>

> [@tonyno](#):
>
> if (color == \_analogLastColor && b == \_analogLastBri){}

This is probably going to make your head explode, but && is performed before == in C’s order of precedence for logical operations.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 11, 2020, 4:28pm UTC](https://wled.discourse.group/t/analog-led-support/55/40 "2020-05-11T16:28:48Z")

</div>

Working fine in 091. 🤷‍♂️

[Previous page](https://wled.discourse.group/t/analog-led-support/55.md?page=1)

[Next page](https://wled.discourse.group/t/analog-led-support/55.md?page=3)
