Logic Machine Forum
Convert RGBW 1byte in to DT8 object - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Convert RGBW 1byte in to DT8 object (/showthread.php?tid=4721)



Convert RGBW 1byte in to DT8 object - khalil - 18.04.2023

Hello Dears,
I want to create a script that convert 4x1byte objects in to 1 DT8 object.
but how to avoid multiple write to the DALI: like if the 4 RGBW objects changed this will trigger 4 DT8 Commands to the DALI Bus!

Could you share a script considering this case.


RE: Convert RGBW 1byte in to DT8 object - admin - 18.04.2023

Use a single event script for all 4 objects via a common tag. Set execution mode to "Last instance only". Add a small delay before writing to the RGBW object.


RE: Convert RGBW 1byte in to DT8 object - khalil - 18.04.2023

thanks 
could you share a starting example
also how to read the GA name from script?


RE: Convert RGBW 1byte in to DT8 object - admin - 18.04.2023

Adjust sleep time as needed. Higher value will prevent duplicate messages but will add a visible delay to the light changes. Separate script is needed for each R/G/B/W + RGBW objects.
Code for 6 byte DALI RGBW output object:
Code:
os.sleep(0.5)

value = {
  red = grp.getvalue('1/1/1') * 2.55,
  green = grp.getvalue('1/1/2') * 2.55,
  blue = grp.getvalue('1/1/3') * 2.55,
  white = grp.getvalue('1/1/4') * 2.55,
}

grp.write('1/1/5', value)

Use this to find the source object name:
Code:
obj = grp.find(event.dst)
log(obj.name)



RE: Convert RGBW 1byte in to DT8 object - khalil - 18.04.2023

Thank you admin
Very helpful


RE: Convert RGBW 1byte in to DT8 object - khalil - 19.04.2023

Dear admin
If I want to convert from DT8 to R,G,B,W 1byte for status feedback, Should I divide by 2.55?


RE: Convert RGBW 1byte in to DT8 object - admin - 19.04.2023

Yes, if 1 byte objects use scale (0..100) data type.


RE: Convert RGBW 1byte in to DT8 object - khalil - 19.04.2023

(19.04.2023, 07:41)admin Wrote: Yes, if 1 byte objects use scale (0..100) data type.

I use 1byte unsigned integer not scale, so do I need to multiple and divide by 2.55 in both Control and status scripts?
or should I use the scale object instead?


RE: Convert RGBW 1byte in to DT8 object - admin - 19.04.2023

DALI RGBW data type uses 0..255 range for each channel. If you 1 byte objects use the same range then you don't have to divide or multiply.