Example #1
0
    def set_led_color(self, leds, color='ffffff'):
        """ Set the color of a single LED """
        if not isinstance(leds, list):
            leds = [leds]

        theme_string = ''
        off_color = tohex('000000')
        on_color = tohex(color)
        for index in range(1, self.total_leds + 1):
            if index in leds:
                theme_string += on_color
            else:
                theme_string += off_color
        self.set_theme(theme_string)
Example #2
0
    def mode_breath(self, colors=None):
        """ Set mode to breath """
        local_mode_file = self.mode_file.format('breath')

        send = None
        if not colors:
            send = Keyboard.ENABLE

        elif len(colors) == 1:
            send = tohex(colors[0])

        elif len(colors) == 2:
            send = ''.join([tohex(color) for color in colors])

        write_file(local_mode_file, send)
Example #3
0
    def mode_starlight(self, colors=None):
        """ set the keyboard to starlight mode """
        local_mode_file = self.mode_file.format('starlight')

        send = None
        if not colors:
            send = '\x01'

        elif len(colors) == 1:
            send = '\x02' + tohex(colors[0])

        elif len(colors) == 2:
            send = '\x03' + ''.join([tohex(color) for color in colors])

        write_file(local_mode_file, send)
Example #4
0
    def all_keys_off(self, color='000000'):
        """ Turn all the keys off(black) for custom mode """
        total_keys = self.rows * self.columns
        off_color = tohex(color)
        all_off = off_color * total_keys

        write_file(self.set_keys_color, all_off)
Example #5
0
 def set_color(self, key_name, key_color):
     """ Set the color for a key_name """
     key_name = key_name.lower()
     self.keys[key_name] = tohex(key_color)
Example #6
0
 def mode_reactive(self, color):
     """ Set the keyboard to reactive mode """
     local_mode_file = self.mode_file.format('reactive')
     hexcolor = '\x02' + tohex(color)
     write_file(local_mode_file, hexcolor)
Example #7
0
 def mode_static(self, color='00FF00'):
     """ Set all the keyboard backlights to a single color"""
     local_mode_file = self.mode_file.format('static')
     hexcolor = tohex(color)
     write_file(local_mode_file, hexcolor)
Example #8
0
def test_tohex(name, hexcolor):
    assert common.tohex(name) == hexcolor