Changeset - ba2f00912e20
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 8 months ago 2024-05-19 05:43:43
drewp@bigasterisk.com
fix white output on RGBW devices
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/light9/collector/device.py
Show inline comments
 
@@ -89,100 +89,102 @@ def toOutputAttrs(
 

	
 
def untype_toOutputAttrs(deviceType, deviceAttrSettings) -> Dict[URIRef, int]:
 
    """
 
    Given device attr settings like {L9['color']: Literal('#ff0000')},
 
    return a similar dict where the keys are output attrs (like
 
    L9['red']) and the values are suitable for Collector.setAttr
 

	
 
    :outputAttrRange happens before we get here.
 
    """
 

	
 
    def floatAttr(attr, default=0):
 
        out = deviceAttrSettings.get(attr)
 
        if out is None:
 
            return default
 
        return float(out.toPython()) if isinstance(out, Literal) else out
 

	
 
    def rgbAttr(attr):
 
        color = deviceAttrSettings.get(attr, '#000000')
 
        r, g, b = hex_to_rgb(color)
 
        return r, g, b
 

	
 
    def cmyAttr(attr):
 
        rgb = sRGBColor.new_from_rgb_hex(deviceAttrSettings.get(attr, '#000000'))
 
        out = colormath.color_conversions.convert_color(rgb, CMYColor)
 
        return (_8bit(out.cmy_c), _8bit(out.cmy_m), _8bit(out.cmy_y))
 

	
 
    def fine16Attr(attr, scale=1.0):
 
        x = floatAttr(attr) * scale
 
        hi = _8bit(x)
 
        lo = _8bit((x * 255) % 1.0)
 
        return hi, lo
 

	
 
    def choiceAttr(attr):
 
        # todo
 
        if deviceAttrSettings.get(attr) == L9['g1']:
 
            return 3
 
        if deviceAttrSettings.get(attr) == L9['g2']:
 
            return 10
 
        return 0
 

	
 
    if deviceType == L9['ChauvetColorStrip']:
 
        r, g, b = rgbAttr(L9['color'])
 
        return {L9['mode']: 215, L9['red']: r, L9['green']: g, L9['blue']: b}
 
    elif deviceType == L9['Bar612601d']:
 
        r, g, b = rgbAttr(L9['color'])
 
        return {L9['red']: r, L9['green']: g, L9['blue']: b}
 
    elif deviceType == L9['LedPar90']:
 
        r, g, b = rgbAttr(L9['color'])
 
        return {L9['master']: 255, L9['red']: r, L9['green']: g, L9['blue']: b, L9['white']: 0}
 
        w = _8bit(floatAttr(L9['white']))
 
        return {L9['master']: 255, L9['red']: r, L9['green']: g, L9['blue']: b, L9['white']: w}
 
    elif deviceType == L9['LedPar54']:
 
        r, g, b = rgbAttr(L9['color'])
 
        return {L9['master']: 255, L9['red']: r, L9['green']: g, L9['blue']: b, L9['white']: 0, L9['strobe']: 0}
 
        w = _8bit(floatAttr(L9['white']))
 
        return {L9['master']: 255, L9['red']: r, L9['green']: g, L9['blue']: b, L9['white']: w, L9['strobe']: 0}
 
    elif deviceType == L9['SimpleDimmer']:
 
        return {L9['level']: _8bit(floatAttr(L9['brightness']))}
 
    elif deviceType == L9['MegaFlash']:
 
        return {
 
            L9['brightness']: _8bit(floatAttr(L9['brightness'])),
 
            L9['strobeSpeed']: _8bit(floatAttr(L9['strobeSpeed'])),
 
        }
 
    elif deviceType == L9['Mini15']:
 
        out = {
 
            L9['rotationSpeed']: 0,  # seems to have no effect
 
            L9['dimmer']: 255,
 
            L9['colorChange']: 0,
 
            L9['colorSpeed']: 0,
 
            L9['goboShake']: _8bit(floatAttr(L9['goboShake'])),
 
        }
 

	
 
        out[L9['goboChoose']] = {
 
            L9['open']: 0,
 
            L9['mini15Gobo1']: 10,
 
            L9['mini15Gobo2']: 20,
 
            L9['mini15Gobo3']: 30,
 
        }[deviceAttrSettings.get(L9['mini15GoboChoice'], L9['open'])]
 

	
 
        out[L9['red']], out[L9['green']], out[L9['blue']] = rgbAttr(L9['color'])
 
        out[L9['xRotation']], out[L9['xFine']] = fine16Attr(L9['rx'], 1 / 540)
 
        out[L9['yRotation']], out[L9['yFine']] = fine16Attr(L9['ry'], 1 / 240)
 
        # didn't find docs on this, but from tests it looks like 64 fine steps takes you to the next coarse step
 

	
 
        return out
 
    elif deviceType == L9['ChauvetHex12']:
 
        out = {}
 
        out[L9['red']], out[L9['green']], out[L9['blue']] = r, g, b = rgbAttr(L9['color'])
 
        out[L9['amber']] = 0
 
        out[L9['white']] = min(r, g, b)
 
        out[L9['uv']] = _8bit(floatAttr(L9['uv']))
 
        return out
 
    elif deviceType == L9['Source4LedSeries2']:
 
        out = {}
 
        out[L9['red']], out[L9['green']], out[L9['blue']] = rgbAttr(L9['color'])
 
        out[L9['strobe']] = 0
 
        out[L9['fixed255']] = 255
 
        for num in range(7):
 
            out[L9['fixed128_%s' % num]] = 128
 
        return out
 
    elif deviceType == L9['MacAura']:
 
        out = {
 
            L9['shutter']: 22,
 
            L9['dimmer']: 255,
0 comments (0 inline, 0 general)