Skip to content

Device Settings

set_power

Set the power state of the device.

Parameters:

Name Type Description Default
on bool

True to turn on, False to turn off.

True
Source code in src/pypixelcolor/commands/set_power.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def set_power(on: bool = True):
    """
    Set the power state of the device.

    Args:
        on: True to turn on, False to turn off.
    """
    if isinstance(on, str):
        on = on.lower() in ("true", "1", "yes", "on")

    # Build command
    cmd = bytes([
        5,              # Command length
        0,              # Reserved
        7,              # Command ID
        1,              # Command type ID
        1 if on else 0  # Power state
    ])
    return single_window_plan("set_power", cmd)

set_brightness

Set the brightness of the device.

Parameters:

Name Type Description Default
level int

Brightness level (0-100).

required
Source code in src/pypixelcolor/commands/set_brightness.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def set_brightness(level: int):
    """
    Set the brightness of the device.

    Args:
        level (int): Brightness level (0-100).
    """
    if (0 > int(level)) or (int(level) > 100):
        raise ValueError("Brightness level must be between 0 and 100")
    payload = bytes([
        5,          # Command length
        0,          # Reserved
        4,          # Command ID
        0x80,       # Command type ID
        int(level)  # Brightness value
    ])
    return single_window_plan("set_brightness", payload)

set_orientation

Set the orientation of the device.

Parameters:

Name Type Description Default
orientation int

The orientation value to set (0-3).

0
Source code in src/pypixelcolor/commands/set_orientation.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def set_orientation(orientation: int = 0):
    """
    Set the orientation of the device.

    Args:
        orientation (int): The orientation value to set (0-3).
    """

    if (int(orientation) < 0 or int(orientation) > 3):
        raise ValueError("Orientation must be between 0 and 3")

    payload = bytes([
        5,                  # Command length
        0,                  # Reserved  
        6,                  # Command ID
        0x80,               # Command type ID
        int(orientation)    # Orientation value
    ])
    return single_window_plan("set_orientation", payload)