Aller au contenu

Gestion des données

Précaution

L'utilisation des slots peut entraîner des bootloops si la commande envoyer contient des données corrompues. Avant d'envoyer des données à un slot, assurez-vous que l'envoi fonctionne correctement sans utiliser de slots.

L'appareil fournit des "slots" pour stocker les données de texte et d'image. Emplacements des données

L'enregistrement de contenu (texte ou image) dans ces emplacements se fait via l'argument save_slot= dans leurs commandes respectives. Cela permet un accès plus rapide et réduit le temps nécessaire pour afficher le contenu sur la matrice LED.

clear

Clears the ROM data on the device.

Note

This command removes all stored content from the device's memory, including device settings.

Source code in src/pypixelcolor/commands/clear.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def clear():
    """
    Clears the ROM data on the device.

    Note:
        This command removes all stored content from the device's memory, including device settings.
    """
    cmd = bytes([
        4,     # Command length
        0,     # Reserved
        3,     # Command ID
        0x80,  # Command type ID
    ])
    return single_window_plan("clear", cmd)

show_slot

Shows the specified slot on the device.

Parameters:

Name Type Description Default
number int

The slot number to display.

required
Note

If the slot is empty, the device will cycle through available slots.

Source code in src/pypixelcolor/commands/show_slot.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def show_slot(number: int):
    """
    Shows the specified slot on the device.

    Args:
        number: The slot number to display.

    Note:
        If the slot is empty, the device will cycle through available slots.
    """
    cmd = bytes([
        0x07,
        0x00,
        0x08,
        0x80,
        0x01,
        0x00,
        int(number) & 0xFF,
    ])
    return single_window_plan("show_slot", cmd)

delete

Delete a specific slot by its index.

Parameters:

Name Type Description Default
n int

Index of the slot to delete.

required
Source code in src/pypixelcolor/commands/delete.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def delete(n: int):
    """
    Delete a specific slot by its index.

    Args:
        n: Index of the slot to delete.
    """
    if not (0 <= int(n) <= 255):
        raise ValueError("Slot index must be between 0 and 255")
    cmd = bytes([
        7,      # Command length
        0,      # Reserved
        2,      # Command ID
        1,      # Command type ID
        1,      # Reserved
        0,      # Reserved
        int(n)  # Slot index
    ])
    return single_window_plan("delete_slot", cmd)