openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.43k stars 253 forks source link

Unable to control LED dimmer, channel value rises absurdly high by itself #1190

Open tobiaspc opened 5 months ago

tobiaspc commented 5 months ago

Describe the bug LED dimmer can not be controlled after some time, since the dimmer value rises to absurd values. "Smooth transitions for LED" (Flag 18) is enabled.

Firmware:

To Reproduce Steps to reproduce the behavior:

  1. Power on, use / toggle the light normally
  2. After extended power on time (days), LED channel value rises to absurd values (i.e., over 100.00), and keeps rising by itself, see first screenshot.
  3. Cut the power, turn on again
  4. Value rises very fast, exceeding the upper limit of 100 (second screenshot)
  5. Software thinks light is "off" (red button color), despite it being already (physically) on
  6. Press Toggle Light button
  7. Press Toggle Light button again, LED dimmer value decreases, reaching 0 after some time.
  8. From there on, normal operation, i.e., LED values are clamped at 0 and 100.

This bug is not deterministic, sometimes it appears after a few hours, sometimes after days. Manually setting the brightness to 0 or 100 does not work, neither via "normal" web-UI, nor via "Web Application". Only way to workaround is cutting the power and quickly toggling the light twice, as described above.

Screenshots Bug during operation: 2024-04-30-222154_844x1008_grim

Bug after reboot: 2024-04-30-222332_852x1007_grim

Additional context

openshwprojects commented 5 months ago

Hello, can you try to narrow down the issue, what happens if you try the same without smooth led transitions, etc?

tobiaspc commented 5 months ago

Thanks for the idea. Just disabled Flag 18, will see how it behaves over the next few days and report back.

Interestingly, the maximum value should be capped in Line 84 src/hal/bl602/hal_pins_bl602.c:

if(value>100)
    value = 100;
duty = value;
tobiaspc commented 5 months ago

The issue did not occur since I turned off the smooth transition feature, so I guess this is the cause. Any idea on how I could debug this further?