mycontroller-org / mycontroller-v1-legacy

The Open Source Controller
http://www.MyController.org
Apache License 2.0
148 stars 90 forks source link

Update common_services.js #444

Closed giltesa closed 6 years ago

giltesa commented 6 years ago

The rgba2hex function was not returning a valid hexadecimal value, the length must always be 8 characters (#RRGGBBWW). There is a condition that allows to send 4 characters instead of 8 but it is better not to shorten the value to facilitate the work in the program of the Arduino sketch.

Incorrect output: 58097 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=8,sg=0:#3d25a209 58531 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=8,sg=0:#3819be0 60297 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=8,sg=0:#3819bec 61145 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=6,sg=0:#fd16c 61790 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=5,sg=0:#334c

Correct output: 589207 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#07112400 589512 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#181e2900 590118 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#182b5200 590553 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#0e3f9e00 591108 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#229e0e00 591978 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#229e0e2b 592775 TSF:MSG:READ,0-0-5,s=0,c=1,t=41,pt=0,l=9,sg=0:#00080900

PS: The RGB picker works fine, only the RGBW picker failed.

jkandasa commented 6 years ago

@giltesa Thank you for the fix and PR!