def set_color(color, state="on"): if not color in functions_optcode.keys(): raise UnknownColor(color) if color in colors_connection.keys(): for connection in colors_connection[color]: Core.send_byte(functions_optcode[connection]["off" if state == "on" else "on"]) Core.send_byte(functions_optcode[color][state])
def set_register(): Core.send_byte(functions_optcode["set"])
def clear_register(): Core.send_byte(functions_optcode["clear"])
def set_register(): '''Function to switch on all the lamps in the installation. ''' for color in functions_optcode.keys(): if color in [ 'set', 'clear' ]: continue if not color in connections_relations.keys(): Core.send_byte( functions_optcode[ color ][ 'on' ] ) else: Core.send_byte( functions_optcode[ color ][ 'off' ] )
def set_color( color, state = 'on' ): '''Function to swicth on or switch off a specific colored region lamps in the installation. :param color: Identifier of the colored region :param state: On or Off (string) ''' if not color in colors_names.keys(): raise Exceptions.UnknownColor( 'color opcode ( %s )' % color ) color = colors_names[ color ] if not color in functions_optcode.keys(): raise Exceptions.UnknownColor( color ) if color in connections_relations.keys(): for primary in connections_relations[ color ]: Core.send_byte( functions_optcode[ primary ][ 'off' ] ) Core.send_byte( functions_optcode[ color ][ state ] ) if color in [ 'red', 'green', 'blue' ] and state == 'off': lights_off()
def clear_register(): '''Function to switch off all the lamps in the installation. ''' Core.send_byte( functions_optcode[ 'clear' ] )
def lights_off(): for color in connections_relations.keys(): Core.send_byte( functions_optcode[ color ][ 'off' ] )