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.4k stars 245 forks source link

scripting RGB colours #1308

Open rew1ndustry opened 1 month ago

rew1ndustry commented 1 month ago

am trying to write a simple script that cycles through my lamp colours, but am stuck because it seems that the color and led_basecolor_rgb commands both require a hex string, and will accept nothing else.

how do we convert from channel values to a hex string?

this is my script, so far - how do i make setrgb work?

setChannel 11 1 // phase setChannel 12 255 // red setChannel 13 0 // green setChannel 14 0 // blue

power on

alias setrgb backlog led_basecolor_rgb $CH12 $CH13 $CH14; delay_ms 10 alias phase1 backlog addChannel 12 -1; addChannel 13 1; setrgb; if $CH12==0 then setChannel 11 2 alias phase2 backlog addChannel 13 -1; addChannel 14 1; setrgb; if $CH13==0 then setChannel 11 3 alias phase3 backlog addChannel 14 -1; addChannel 12 1; setrgb; if $CH14==0 then setChannel 11 1

loop: if $CH11==1 then phase1 if $CH11==2 then phase2 if $CH11==3 then phase3 goto loop

DeDaMrAzR commented 3 weeks ago

There is an interesting read where you can get to know commands a bit better:

https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md

if you search for setChannel command you will find this text:

Sets a raw channel to given value. Relay channels are using 1 and 0 values. PWM channels are within [0,100] range. Do not use this for LED control, because there is a better and more advanced LED driver with dimming and configuration memory (remembers setting after on/off), LED driver commands has 'led_' prefix.

If you can provide a bit more information on your project we might be able to support you more, like what is the driver you are using, what module, overall a bit more info and we will dive into this and get you through to the solution.