-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Experimental: H-bridge safe mode for TYPE_ANALOG_2CH (cheap hardware?) #5442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
| uint8_t brightness = w; | ||
|
|
||
| if (level <= 127) { | ||
| _data[0] = (map(level, 0, 127, 255, 0) * brightness) / 255; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of 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; | ||
| } | ||
|
softhack007 marked this conversation as resolved.
Outdated
|
||
| } | ||
| case TYPE_ANALOG_5CH: //RGB + warm white + cold white | ||
|
bsvdoom marked this conversation as resolved.
Outdated
|
||
| if (cctICused) | ||
| _data[4] = Bus::_cct < 0 || Bus::_cct > 255 ? 127 : Bus::_cct; | ||
|
|
@@ -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 | ||
|
|
@@ -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) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@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
I don't see added value for WLED users. Especially when we already have a working solution for H-Bridge in
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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")}, | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
whitefrom auto-white calculation is inw;Bus::_ccthas the color temperature, either in kelvin or directly from the "cct" slider.