libretiny: PWM implementation appears broken
Colours are often getting randomly screwed up over PWM.
I’ve been trying to debug this for a while now, and thought ESPHome was transforming colour values somehow before delivering them over PWM to an RGB bulb I had, but after logging inside libretiny_pwm.cpp, I can see that all the duty cycle values are correct, yet somehow the bulb is often the wrong colour or in the wrong state.
Sometimes I can get the bulb in a state where max duty sent to red channel only and others zero will show a bright red light as expected. And other times, the same values sent over PWM will result in the light being off.
Is there some kind of state that’s not being managed in the chipset? I know these chips have on-board PWM - is this not being managed correctly?
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 2
- Comments: 23 (11 by maintainers)
Install Visual Studio Code with PlatformIO add-on. Clone libretiny repository into
~/.platformio/platforms/libretiny(remove it if it’s already there). Create a new PlatformIO project with LibreTiny platform (in VSCode). Add both the LibreTiny directory and the PIO project to a single VSCode workspace, open the workspace. Let it refresh indexes. Copy (or symlink) the.vscode/c_cpp_properties.jsonfile from the PIO project to LibreTiny directory. Make sure to backup your code frequently - PIO might remove/reinstall it if you useversion: dev/recommendedin ESPHome. To be safe, setversion: latestin your YAML. If you don’t have ESPHome yet, git clone it and install withpip install -e .. Then run it as usual:esphome compile xxx.yaml.@szupi-ipuzs: see this: https://github.com/libretiny-eu/libretiny/issues/201
I’m using CB2L Tuya chip, which has
bk7231n: https://developer.tuya.com/en/docs/iot/cb2l-module-datasheet?id=Kai2eku1m3pyl