Skip to content

Other Commands

set_fun_mode

Enable or disable fun mode.

Parameters:

Name Type Description Default
enable bool

Boolean or equivalent, enables (True) or disables (False) fun mode.

False
Source code in src/pypixelcolor/commands/set_fun_mode.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def set_fun_mode(enable : bool = False):
    """
    Enable or disable fun mode.

    Args:
        enable: Boolean or equivalent, enables (True) or disables (False) fun mode.
    """

    # Convert bool
    if isinstance(enable, str):
        enable = enable.lower() in ("true", "1", "yes", "on")

    # Build payload using bytes
    payload = bytes([
        5,                        # Command length
        0,                        # Reserved
        4,                        # Command ID
        1,                        # Command type ID
        1 if bool(enable) else 0  # Fun mode value
    ])

    return single_window_plan("set_fun_mode", payload)

Examples:

# Enable fun mode
client.set_fun_mode(True)

# Disable fun mode
client.set_fun_mode(False)
pypixelcolor -a <MAC_ADDRESS> -c set_fun_mode true

set_pixel

Defines the color of a specific pixel.

Parameters:

Name Type Description Default
x int

X coordinate of the pixel (0-...).

required
y int

Y coordinate of the pixel (0-...).

required
color str

Color in hexadecimal format (e.g., 'FF0000' for red).

required
Source code in src/pypixelcolor/commands/set_fun_mode.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def set_pixel(x: int, y: int, color: str, device_info: Optional[DeviceInfo] = None):
    """
    Defines the color of a specific pixel.

    Args:
        x: X coordinate of the pixel (0-...).
        y: Y coordinate of the pixel (0-...).
        color: Color in hexadecimal format (e.g., 'FF0000' for red).
    """

    # Validate coordinates range if device info is provided
    if device_info and not (0 <= int(x) <= device_info.width - 1 and 0 <= int(y) <= device_info.height - 1):
            raise ValueError(f"Invalid coordinates range. Range are x[0:{device_info.width-1}] y[0:{device_info.height-1}]")

    # Validate color format
    if (not (isinstance(color, str)) 
        and len(color) == 6 
        and all(c in '0123456789abcdefABCDEF' for c in color)):
            raise ValueError("Color must be a 6-character hexadecimal string.")

    # Build payload using bytes
    payload = bytes([
        10,                       # Command length
        0,                        # Reserved
        5,                        # Command ID
        1,                        # Command type ID
        0,                        # Reserved
        int(color[0:2], 16),      # Red
        int(color[2:4], 16),      # Green
        int(color[4:6], 16),      # Blue
        int(x),                   # X coordinate
        int(y)                    # Y coordinate
    ])

    return single_window_plan("set_pixel", payload, requires_ack=False)

Examples:

# Set pixel at coordinates (x=0, y=0) to red (#FF0000)
client.set_pixel(x=0, y=0, color="FF0000")

# Set pixel at coordinates (x=5, y=10) to green (#00FF00)
client.set_pixel(x=5, y=10, color="00FF00")
pypixelcolor -a <MAC_ADDRESS> -c set_pixel x=0 y=0 color=FF0000

set_rhythm_mode

Set the rhythm mode of the device.

Parameters:

Name Type Description Default
style int

The style of the rhythm mode (0-4).

0
l1 int

Level 1 (0-15).

0
l2 int

Level 2 (0-15).

0
l3 int

Level 3 (0-15).

0
l4 int

Level 4 (0-15).

0
l5 int

Level 5 (0-15).

0
l6 int

Level 6 (0-15).

0
l7 int

Level 7 (0-15).

0
l8 int

Level 8 (0-15).

0
l9 int

Level 9 (0-15).

0
l10 int

Level 10 (0-15).

0
l11 int

Level 11 (0-15).

0

Raises:

Type Description
ValueError

If style is not in 0..4 or any level is not in 0..15.

Source code in src/pypixelcolor/commands/set_rhythm_mode.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def set_rhythm_mode(style=0, l1 : int = 0, l2 : int = 0, l3 : int = 0, l4 : int = 0, l5 : int = 0, l6 : int = 0, l7 : int = 0, l8 : int = 0, l9 : int = 0, l10 : int = 0, l11 : int = 0):
    """Set the rhythm mode of the device.

    Args:
        style (int): The style of the rhythm mode (0-4).
        l1 (int): Level 1 (0-15).
        l2 (int): Level 2 (0-15).
        l3 (int): Level 3 (0-15).
        l4 (int): Level 4 (0-15).
        l5 (int): Level 5 (0-15).
        l6 (int): Level 6 (0-15).
        l7 (int): Level 7 (0-15).
        l8 (int): Level 8 (0-15).
        l9 (int): Level 9 (0-15).
        l10 (int): Level 10 (0-15).
        l11 (int): Level 11 (0-15).

    Raises:
        ValueError: If ``style`` is not in 0..4 or any level is not in 0..15.
    """

    # Validation
    if not (0 <= int(style) <= 4):
        raise ValueError(f"rhythm mode style must be between 0 and 4, got {style}")

    levels = [int(v) for v in [l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11]]
    for idx, lv in enumerate(levels, start=1):
        if not (0 <= lv <= 15):
            raise ValueError(f"level {idx} must be between 0 and 15, got {lv}")

    # Build payload
    payload = bytes([
        16,     # Command length
        0,      # Reserved
        1,      # Command ID
        2,      # Command type ID
        int(style),
    ])
    payload += bytes(levels)

    return single_window_plan("set_rhythm_mode", payload, requires_ack=True)

Examples:

# Set rhythm equalizer style 1 with custom level heights (0-15)
client.set_rhythm_mode(
    style=1,
    l1=4, l2=8, l3=12, l4=15, l5=10,
    l6=6, l7=3, l8=8, l9=12, l10=14, l11=5,
)
pypixelcolor -a <MAC_ADDRESS> -c set_rhythm_mode style=1 l1=4 l2=8 l3=12 l4=15 l5=10 l6=6 l7=3 l8=8 l9=12 l10=14 l11=5

set_rhythm_mode_2

Set the rhythm mode of the device (alternative version).

Parameters:

Name Type Description Default
style int

The style of the rhythm mode. Allowed values are 0 or 1.

0
t int

Animation time (0-7).

0

Returns:

Name Type Description
bytes

Byte sequence for the command payload used to set the rhythm mode.

Raises:

Type Description
ValueError

If style is not in 0..1 or t is not in 0..7.

Source code in src/pypixelcolor/commands/set_rhythm_mode.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def set_rhythm_mode_2(style: int = 0, t: int = 0):
    """Set the rhythm mode of the device (alternative version).

    Args:
        style (int): The style of the rhythm mode. Allowed values are 0 or 1.
        t (int): Animation time (0-7).

    Returns:
        bytes: Byte sequence for the command payload used to set the rhythm mode.

    Raises:
        ValueError: If ``style`` is not in 0..1 or ``t`` is not in 0..7.
    """

    # Validation
    if not (0 <= int(style) <= 1):
        raise ValueError(f"rhythm mode style must be between 0 and 1, got {style}")

    if not (0 <= int(t) <= 7):
        raise ValueError(f"Level (t) must be between 0 and 7, got {t}")

    # Build payload using bytes
    payload = bytes([
        6,              # Command length
        0,              # Reserved
        0,              # Command ID
        2,              # Command type ID
        int(t),         # Animation time
        int(style)      # Style
    ])

    return single_window_plan("set_rhythm_mode_2", payload)

Examples:

# Set alternative rhythm mode (style 0 or 1, animation time 0-7)
client.set_rhythm_mode_2(style=1, t=3)
pypixelcolor -a <MAC_ADDRESS> -c set_rhythm_mode_2 style=1 t=3

set_timer

Controls the timer (stopwatch) mode on the device.

Set timer action (start, pause, stop).

Parameters:

Name Type Description Default
action Union[TimerAction, str, int]

TimerAction enum, string ('start', 'pause', 'stop'), or integer (0 = stop, 1 = start, 2 = pause).

required

Returns:

Name Type Description
SendPlan SendPlan

The single window send plan for this command.

Source code in src/pypixelcolor/commands/set_timer.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def set_timer(action: Union[TimerAction, str, int]) -> SendPlan:
    """
    Set timer action (start, pause, stop).

    Args:
        action (Union[TimerAction, str, int]): TimerAction enum, string ('start', 'pause', 'stop'),
            or integer (0 = stop, 1 = start, 2 = pause).

    Returns:
        SendPlan: The single window send plan for this command.
    """
    timer_action = _parse_action(action)

    payload = bytes([
        5,                  # Command length
        0,                  # Reserved
        9,                  # Command ID
        0x80,               # Command type ID
        timer_action.value  # Value: 0 = stop, 1 = start, 2 = pause
    ])
    return single_window_plan("set_timer", payload)

Examples:

from pypixelcolor import TimerAction

# Using Enum
client.set_timer(TimerAction.START)
client.set_timer(TimerAction.PAUSE)
client.set_timer(TimerAction.STOP)

# Using string names
client.set_timer("start")
client.set_timer("pause")
client.set_timer("stop")
pypixelcolor -a <MAC_ADDRESS> -c set_timer start

set_scores

Sets the scoreboard scores for player 1 and player 2 on supported devices.

Set scoreboard scores for player 1 and player 2.

Parameters:

Name Type Description Default
score_p1 Union[int, str]

Score for player 1 (0-99). Defaults to 0.

0
score_p2 Union[int, str]

Score for player 2 (0-99). Defaults to 0.

0

Returns:

Name Type Description
SendPlan SendPlan

The single window send plan for this command.

Source code in src/pypixelcolor/commands/set_scores.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def set_scores(score_p1: Union[int, str] = 0, score_p2: Union[int, str] = 0) -> SendPlan:
    """
    Set scoreboard scores for player 1 and player 2.

    Args:
        score_p1 (Union[int, str]): Score for player 1 (0-99). Defaults to 0.
        score_p2 (Union[int, str]): Score for player 2 (0-99). Defaults to 0.

    Returns:
        SendPlan: The single window send plan for this command.
    """
    p1 = _parse_score(score_p1, "score_p1")
    p2 = _parse_score(score_p2, "score_p2")

    payload = bytes([
        8,      # Command length
        0,      # Reserved
        0x0A,   # Command ID
        0x80,   # Command type ID
        p1,     # Player 1 score
        0,      # Padding
        p2,     # Player 2 score
        0       # Padding
    ])
    return single_window_plan("set_scores", payload)

Examples:

# Set Player 1 to 24 and Player 2 to 18
client.set_scores(score_p1=24, score_p2=18)
pypixelcolor -a <MAC_ADDRESS> -c set_scores score_p1=24 score_p2=18