Skip to content

led_sdk

Functions:

Name Description
logi_led_flash_lighting

Save the current lighting, plays the flashing effect on the targeted devices.

logi_led_init

Make sure there isn't already another instance running and then makes the necessary initializations.

logi_led_init_with_name

Make sure there isn't already another instance running and then makes the necessary initializations.

logi_led_pulse_lighting

Save the current lighting, plays the pulsing effect on the targeted devices.

logi_led_restore_lighting

Restore the last saved lighting.

logi_led_save_current_lighting

Save the current lighting so that it can be restored after a temporary effect is finished.

logi_led_set_lighting

Set the lighting on connected and supported devices.

logi_led_set_target_device

Set the target device type for future calls.

logi_led_shutdown

Restore the last saved lighting and frees memory used by the SDK.

logi_led_stop_effects

Stop any of the preset effect.

start_led_pulse

Start the pulsing red effect in the thread on the keyboard.

logi_led_flash_lighting

logi_led_flash_lighting(
    rgb: tuple[int, int, int], duration: int, interval: int
) -> bool

Save the current lighting, plays the flashing effect on the targeted devices.

Finally, restores the saved lighting.

Parameters:

Name Type Description Default

rgb

tuple[int, int, int]

Tuple with integer range 0 to 100 as an amount of red, green, blue

required

duration

int

Parameter can be set (in millisecond) to LOGI_LED_DURATION_INFINITE to make the effect run until stopped with logi_led_stop_effects()

required

interval

int

Duration of the flashing interval in millisecond

required

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def logi_led_flash_lighting(rgb: tuple[int, int, int], duration: int, interval: int) -> bool:
    """
    Save the current lighting, plays the flashing effect on the targeted devices.

    Finally, restores the saved lighting.
    :param rgb: Tuple with integer range 0 to 100 as an amount of red, green, blue
    :param duration: Parameter can be set (in millisecond) to LOGI_LED_DURATION_INFINITE
                     to make the effect run until stopped with logi_led_stop_effects()
    :param interval: Duration of the flashing interval in millisecond
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedFlashLighting(*rgb, duration, interval)  # type: ignore[attr-defined]
    return False

logi_led_init

logi_led_init() -> bool

Make sure there isn't already another instance running and then makes the necessary initializations.

It saves the current lighting for all connected and supported devices. This function will also stop any effect currently going on the connected devices.

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
16
17
18
19
20
21
22
23
24
25
26
def logi_led_init() -> bool:
    """
    Make sure there isn't already another instance running and then makes the necessary initializations.

    It saves the current lighting for all connected and supported devices. This function will also stop any effect
    currently going on the connected devices.
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedInit()  # type: ignore[attr-defined]
    return False

logi_led_init_with_name

logi_led_init_with_name(name: str) -> bool

Make sure there isn't already another instance running and then makes the necessary initializations.

It saves the current lighting for all connected and supported devices. This function will also stop any effect currently going on the connected devices. Passing a name into this function will make the integration show up with a given custom name. The name is set only once, the first time this function or logi_led_init() is called.

Parameters:

Name Type Description Default

name

str

The referred name for this integration to show u as

required

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def logi_led_init_with_name(name: str) -> bool:
    """
    Make sure there isn't already another instance running and then makes the necessary initializations.

    It saves the current lighting for all connected and supported devices.
    This function will also stop any effect currently going on the connected devices. Passing a name into this
    function will make the integration show up with a given custom name. The name is set only once, the first
    time this function or logi_led_init() is called.
    :param name: The referred name for this integration to show u as
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedInitWithName(FFI().new('wchar_t[]', name))  # type: ignore[attr-defined]
    return False

logi_led_pulse_lighting

logi_led_pulse_lighting(
    rgb: tuple[int, int, int], duration: int, interval: int
) -> bool

Save the current lighting, plays the pulsing effect on the targeted devices.

Finally, restores the saved lighting.

Parameters:

Name Type Description Default

rgb

tuple[int, int, int]

Tuple with integer values range 0 to 100 as an amount of red, green, blue.

required

duration

int

Parameter can be set (in millisecond) to LOGI_LED_DURATION_INFINITE to make the effect run until stopped with logi_led_stop_effects().

required

interval

int

Duration of the flashing interval in millisecond.

required

Returns:

Type Description
bool

A result of execution.

Source code in src/dcspy/sdk/led_sdk.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def logi_led_pulse_lighting(rgb: tuple[int, int, int], duration: int, interval: int) -> bool:
    """
    Save the current lighting, plays the pulsing effect on the targeted devices.

    Finally, restores the saved lighting.
    :param rgb: Tuple with integer values range 0 to 100 as an amount of red, green, blue.
    :param duration: Parameter can be set (in millisecond) to LOGI_LED_DURATION_INFINITE
                     to make the effect run until stopped with logi_led_stop_effects().
    :param interval: Duration of the flashing interval in millisecond.
    :return: A result of execution.
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedPulseLighting(*rgb, duration, interval)  # type: ignore[attr-defined]
    return False

logi_led_restore_lighting

logi_led_restore_lighting() -> bool

Restore the last saved lighting.

It should be called after a temporary effect is finished. For example, if flashing a red warning sign for a few seconds, you would call this function right after the warning effect is finished.

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
73
74
75
76
77
78
79
80
81
82
83
84
def logi_led_restore_lighting() -> bool:
    """
    Restore the last saved lighting.

    It should be called after a temporary effect is finished.
    For example, if flashing a red warning sign for a few seconds, you would call this function right
    after the warning effect is finished.
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedRestoreLighting()  # type: ignore[attr-defined]
    return False

logi_led_save_current_lighting

logi_led_save_current_lighting() -> bool

Save the current lighting so that it can be restored after a temporary effect is finished.

For example, if flashing a red warning sign for a few seconds, you would call the logi_led_save_current_lighting() function just before starting the warning effect.

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
60
61
62
63
64
65
66
67
68
69
70
def logi_led_save_current_lighting() -> bool:
    """
    Save the current lighting so that it can be restored after a temporary effect is finished.

    For example, if flashing a red warning sign for a few seconds, you would call the logi_led_save_current_lighting()
    function just before starting the warning effect.
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedSaveCurrentLighting()  # type: ignore[attr-defined]
    return False

logi_led_set_lighting

logi_led_set_lighting(rgb: tuple[int, int, int]) -> bool

Set the lighting on connected and supported devices.

Do not call this function immediately after logi_led_init(), instead of wait a little of time after logi_led_init(). For devices that only support a single color, the highest percentage value given of the three colors will define the intensity. For monochrome device, Logitech Gaming Software will proportionally reduce the value of the highest color, according to the user hardware brightness setting.

Parameters:

Name Type Description Default

rgb

tuple[int, int, int]

Tuple with integer range 0 to 100 as an amount of red, green, blue

required

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def logi_led_set_lighting(rgb: tuple[int, int, int]) -> bool:
    """
    Set the lighting on connected and supported devices.

    Do not call this function immediately after logi_led_init(), instead of wait a little of time after logi_led_init().
    For devices that only support a single color, the highest percentage value given of the three colors will
    define the intensity. For monochrome device, Logitech Gaming Software will proportionally reduce
    the value of the highest color, according to the user hardware brightness setting.

    :param rgb: Tuple with integer range 0 to 100 as an amount of red, green, blue
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedSetLighting(*rgb)  # type: ignore[attr-defined]
    return False

logi_led_set_target_device

logi_led_set_target_device(
    target_device: LedConstants,
) -> bool

Set the target device type for future calls.

The default target device is LOGI_DEVICETYPE_ALL, therefore, if no call is made to LogiLedSetTargetDevice the SDK will apply any function to all the connected devices.

Parameters:

Name Type Description Default

target_device

LedConstants

One or a combination of the following values: LOGI_DEVICETYPE_MONOCHROME, LOGI_DEVICETYPE_RGB, LOGI_DEVICETYPE_ALL

required

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
45
46
47
48
49
50
51
52
53
54
55
56
57
def logi_led_set_target_device(target_device: LedConstants) -> bool:
    """
    Set the target device type for future calls.

    The default target device is LOGI_DEVICETYPE_ALL, therefore, if no call is made to LogiLedSetTargetDevice
    the SDK will apply any function to all the connected devices.
    :param target_device: One or a combination of the following values:
                          LOGI_DEVICETYPE_MONOCHROME, LOGI_DEVICETYPE_RGB, LOGI_DEVICETYPE_ALL
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedSetTargetDevice(target_device.value)  # type: ignore[attr-defined]
    return False

logi_led_shutdown

logi_led_shutdown() -> None

Restore the last saved lighting and frees memory used by the SDK.

Source code in src/dcspy/sdk/led_sdk.py
148
149
150
151
def logi_led_shutdown() -> None:
    """Restore the last saved lighting and frees memory used by the SDK."""
    with suppress(AttributeError):
        LED_DLL.LogiLedShutdown()  # type: ignore[attr-defined]

logi_led_stop_effects

logi_led_stop_effects() -> bool

Stop any of the preset effect.

Started from logi_led_flash_lighting() or logi_led_pulse_lighting().

Returns:

Type Description
bool

A result of execution

Source code in src/dcspy/sdk/led_sdk.py
136
137
138
139
140
141
142
143
144
145
def logi_led_stop_effects() -> bool:
    """
    Stop any of the preset effect.

    Started from logi_led_flash_lighting() or logi_led_pulse_lighting().
    :return: A result of execution
    """
    with suppress(AttributeError):
        return LED_DLL.LogiLedStopEffects()  # type: ignore[attr-defined]
    return False

start_led_pulse

start_led_pulse(
    rgb: tuple[int, int, int],
    duration: int,
    interval: int,
    event: Event,
) -> None

Start the pulsing red effect in the thread on the keyboard.

Parameters:

Name Type Description Default

rgb

tuple[int, int, int]

Tuple with integer values range 0 to 100 as an amount of red, green, blue.

required

duration

int

Parameter can be set (in millisecond) to 0 (zero) to make the effect run until an event is set.

required

interval

int

Flashing interval in a millisecond.

required

event

Event

Stop event for infinite loop.

required
Source code in src/dcspy/sdk/led_sdk.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
def start_led_pulse(rgb: tuple[int, int, int], duration: int, interval: int, event: Event) -> None:
    """
    Start the pulsing red effect in the thread on the keyboard.

    :param rgb: Tuple with integer values range 0 to 100 as an amount of red, green, blue.
    :param duration: Parameter can be set (in millisecond) to 0 (zero) to make the effect run until an event is set.
    :param interval: Flashing interval in a millisecond.
    :param event: Stop event for infinite loop.
    """
    LOG.debug('Start LED thread')
    logi_led_init()
    sleep(0.05)
    logi_led_set_target_device(LedConstants.LOGI_DEVICETYPE_ALL)
    sleep_time = duration + 0.2
    logi_led_pulse_lighting(rgb, duration, interval)
    sleep(sleep_time)
    while not event.is_set():
        sleep(0.2)
    logi_led_shutdown()
    LOG.debug('Stop LED thread')