Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,19 @@ void BusPwm::setPixelColor(unsigned pix, uint32_t c) {
Bus::calculateCCT(c, _data[0], _data[1]);
}
break;
case TYPE_ANALOG_2CH_HBRIDGE: //warm white + cold white, relies on auto white calculation, uses H-bridge for better dimming performance at low brightness
{
uint8_t level = (Bus::_cct < 0 || Bus::_cct > 255) ? 127 : Bus::_cct;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int16_t Bus::_cct = -1;     // -1 means use approximateKelvinFromRGB(), 0-255 is standard, >1900 use colorBalanceFromKelvin()

The white from auto-white calculation is in w; Bus::_cct has the color temperature, either in kelvin or directly from the "cct" slider.

uint8_t brightness = w;

if (level <= 127) {
_data[0] = (map(level, 0, 127, 255, 0) * brightness) / 255;
Copy link
Copy Markdown
Member

@softhack007 softhack007 Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of map() is not ideal here, because it leads to jumps in the final brightness result that can be avoided:

   if (level <= 127) { 
        data[0] = (127-level) * brightness) / 127;   // ramp down, brightest at 0
[...]
   } else {
        data[1] = ((level-128) * brightness) / 127;  // ramp up, brightest at 255
[...]
   }

EDIT: I've initially overlooked the direction of your "map". I've corrected my proposal accordingly.

_data[1] = 0;
} else {
_data[0] = 0;
_data[1] = (map(level, 128, 255, 0, 255) * brightness) / 255;
}
Comment thread
softhack007 marked this conversation as resolved.
Outdated
}
case TYPE_ANALOG_5CH: //RGB + warm white + cold white
Comment thread
bsvdoom marked this conversation as resolved.
Outdated
if (cctICused)
_data[4] = Bus::_cct < 0 || Bus::_cct > 255 ? 127 : Bus::_cct;
Expand All @@ -475,6 +488,7 @@ uint32_t BusPwm::getPixelColor(unsigned pix) const {
case TYPE_ANALOG_1CH: //one channel (white), relies on auto white calculation
return RGBW32(0, 0, 0, _data[0]);
case TYPE_ANALOG_2CH: //warm white + cold white
case TYPE_ANALOG_2CH_HBRIDGE: //warm white + cold white, relies on auto white calculation, uses H-bridge for better dimming performance at low brightness
if (cctICused) return RGBW32(0, 0, 0, _data[0]);
else return RGBW32(0, 0, 0, _data[0] + _data[1]);
case TYPE_ANALOG_5CH: //RGB + warm white + cold white
Expand Down Expand Up @@ -525,7 +539,7 @@ void BusPwm::show() {
unsigned duty = (_data[i] * pwmBri) / 255;
unsigned deadTime = 0;

if (_type == TYPE_ANALOG_2CH && Bus::_cctBlend == 0) {
if ((_type == TYPE_ANALOG_2CH || _type == TYPE_ANALOG_2CH_HBRIDGE) && Bus::_cctBlend == 0) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what I meant, you add a new type that is already supported by simply setting cctblend=0.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of setting cctblend=0, the signal on the tow outputs (A and B) are not a complimentary inverted signal that could drive a H-bridge, the truth table is not satisfied.
kép

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are complementary, I spent quite a few hours writing that code. If they are not complementary for the C6, changing setpixelcolor() will not make it so, you need to implement/change the driver.

Copy link
Copy Markdown
Member

@softhack007 softhack007 Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of setting cctblend=0

@bsvdoom did you test the settings suggested by @DedeHai? Did you measure (logic analyzer needed) how it behaves with respect to avoiding shot-through?

@DedeHai I'd say lets short the discussion - my understanding is

  • PWM output on C6 (and C5, too) needs a complete re-write due to major changes in esp-idf. Building anything on top of the broken "V5-C6" analog driver code is like building a house in quicksand - wasted effort.
  • I'm not sure about the specifics of H-Bridges, but the code in this PR just changes the color temperature slider into a left-or-right slider for two LEDs.
  • The output will be BLACK in the middle values, Left = 100% WW, right = 100% CW.
  • Advanced white handling is not supported.

I don't see added value for WLED users. Especially when we already have a working solution for H-Bridge in main.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, as with all C6 / V5 code, it should be done properly to avoid a patchwork of fixes that then have to be re-adjusted later. By properly I mean write a driver that does the same as current main.

// add dead time between signals (when using dithering, two full 8bit pulses are required)
deadTime = (1+dithering) << bitShift;
// we only need to take care of shortening the signal at (almost) full brightness otherwise pulses may overlap
Expand Down Expand Up @@ -579,6 +593,7 @@ std::vector<LEDType> BusPwm::getLEDTypes() {
return {
{TYPE_ANALOG_1CH, "A", PSTR("PWM White")},
{TYPE_ANALOG_2CH, "AA", PSTR("PWM CCT")},
{TYPE_ANALOG_2CH_HBRIDGE, "AA", PSTR("PWM CCT (H-bridge)")},
{TYPE_ANALOG_3CH, "AAA", PSTR("PWM RGB")},
{TYPE_ANALOG_4CH, "AAAA", PSTR("PWM RGBW")},
{TYPE_ANALOG_5CH, "AAAAA", PSTR("PWM RGB+CCT")},
Expand Down
3 changes: 2 additions & 1 deletion wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ class Bus {
}
static constexpr bool hasCCT(uint8_t type) {
return type == TYPE_WS2812_2CH_X3 || type == TYPE_WS2812_WWA ||
type == TYPE_ANALOG_2CH || type == TYPE_ANALOG_5CH ||
type == TYPE_ANALOG_2CH || type == TYPE_ANALOG_2CH_HBRIDGE ||
type == TYPE_ANALOG_5CH ||
type == TYPE_FW1906 || type == TYPE_WS2805 ||
type == TYPE_SM16825;
}
Expand Down
1 change: 1 addition & 0 deletions wled00/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ static_assert(WLED_MAX_BUSSES <= 32, "WLED_MAX_BUSSES exceeds hard limit");
#define TYPE_ANALOG_MIN 41 // first usable analog type
#define TYPE_ANALOG_1CH 41 //single channel PWM. Uses value of brightest RGBW channel
#define TYPE_ANALOG_2CH 42 //analog WW + CW
#define TYPE_ANALOG_2CH_HBRIDGE 96 //analog WW + CW, relies on auto white calculation, uses H-bridge for better dimming performance at low brightness
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
#define TYPE_ANALOG_3CH 43 //analog RGB
#define TYPE_ANALOG_4CH 44 //analog RGBW
#define TYPE_ANALOG_5CH 45 //analog RGB + WW + CW
Expand Down
Loading