vkb.led package

Submodules

vkb.led.effects module

vkb.led.effects.rainbow(dev, led_or_leds)[source]

Device and which LED(s) to make rainbow.

This will yield each color that is set, as it is set. It is up to you to control how quickly to continue the loop, and when to stop, it will loop indefinitely.

Module contents

class vkb.led.ColorMode[source]

Bases: enum.IntEnum

An enumeration.

COLOR1 = 0
COLOR1_d_2 = 2
COLOR1_p_2 = 4
COLOR2 = 1
COLOR2_d_1 = 3
class vkb.led.LEDConfig(led: int, color_mode: int = 0, led_mode: int = 0, color1: str = None, color2: str = None)[source]

Bases: object

An configuration for an LED in a VKB device.

Setting the LEDs consists of a possible 30 LED configs each of which is a 4 byte structure as follows:

byte 0: LED ID bytes 2-4: a 24 bit color config as follows:

000 001 010 011 100 101 110 111
clm lem  b2  g2  r2  b1  g1  r1
color mode (clm):
0 - color1 1 - color2 2 - color1/2 3 - color2/1 4 - color1+2
led mode (lem):
0 - off 1 - constant 2 - slow blink 3 - fast blink 4 - ultra fast
Colors:
VKB uses a simple RGB color configuration for all LEDs. Non-rgb LEDs will not light if you set their primary color to 0 in the color config. The LEDs have a very reduced color range due to VKB using 0-7 to determine the brightness of R, G, and B. LEDConfig takes in a standard hex color code and converts it into this smaller range, so color reproduction will not be accurate.
Bytes:

Convert the LEDConfig to an appropriate binary representation by using bytes:

>>> led1 = LEDConfig(led=1, led_mode=LEDMode.CONSTANT)
>>> bytes(led1)

b’x01x07px04’

Parameters:
  • ledint ID of the LED to control
  • color_modeint color mode, see ColorMode
  • led_modeint LED mode, see LEDMode
  • color1str hex color code for use as color1
  • color2str hex color code for use as color2
classmethod frombytes(buf)[source]

Creates an LEDConfig from a bytes object

class vkb.led.LEDMode[source]

Bases: enum.IntEnum

An enumeration.

CONSTANT = 1
OFF = 0
vkb.led.get_led_configs(dev: <sphinx.ext.autodoc.importer._MockObject object at 0x7f241205e390>)[source]

Returns a list of LEDConfig`s that have currently been set on the given `dev HidDevice.

Warning

This will only return LED configs that have been set into the device. Either with this library or with the test LED tool in VKBDevCfg. LED profiles that are configured normally are not retrieved in this manor and not configured the same way.

vkb.led.hex_color_to_vkb_color(hex_code: str) → [<class 'int'>][source]

Takes a hex formatted color and converts it to VKB color format.

>>> hex_color_to_led("#FF3300")
[7, 1, 0]
Parameters:hex_code – Hex color code string to be converted to a VKB color code
Returns:List of integers in a VKB LED color code format, [R, G, B]
vkb.led.set_leds(dev: <sphinx.ext.autodoc.importer._MockObject object at 0x7f241205e390>, led_configs: [<class 'vkb.led.LEDConfig'>])[source]
vkb.led.vkb_color_to_hex_color(vkb_color_code: [<class 'int'>]) → str[source]

Takes a VKB color code [R, G, B] and converts it into a hex code string