### Start WebSocket Server Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Start a WebSocket server for real-time remote control of the device. Specify the device MAC address when starting. ```bash # Start WebSocket server on default port (4444) python -m pypixelcolor.websocket -a 30:E1:AF:BD:5F:D0 ``` -------------------------------- ### Install pypixelcolor Source: https://github.com/lucagoc/pypixelcolor/blob/main/README.md Install the library using pip. ```bash pip install pypixelcolor ``` -------------------------------- ### Setup development environment Source: https://github.com/lucagoc/pypixelcolor/blob/main/README.md Commands for managing the development environment using Hatch. ```bash hatch env create ``` ```bash hatch shell ``` ```bash hatch run pip install -e '.[dev]' ``` ```bash hatch run pytest ``` ```bash hatch build ``` -------------------------------- ### Start WebSocket Server Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/websocket.md Use this command to start the WebSocket server. Replace with your device's MAC address. The server defaults to localhost:4444. ```bash python -m pypixelcolor.websocket -a ``` -------------------------------- ### Install pypixelcolor from source Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/installation.md Install the pypixelcolor package using pip after cloning the repository. This command installs the package from the local source code. ```bash pip install . ``` -------------------------------- ### Start WebSocket server Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Launch the WebSocket server to enable real-time device control. Specify host and port if needed. ```bash python -m pypixelcolor.websocket -a ``` ```bash python -m pypixelcolor.websocket -a --host 0.0.0.0 --port 4444 ``` -------------------------------- ### Verify pypixelcolor installation Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/installation.md Run this command in your terminal after installation to check the installed version of pypixelcolor. This confirms the installation was successful. ```bash pypixelcolor --version ``` -------------------------------- ### Run WebSocket Server via CLI Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Start the WebSocket server with a custom host and port for a specific device. ```bash python -m pypixelcolor.websocket -a 30:E1:AF:BD:5F:D0 --host 0.0.0.0 --port 8080 ``` -------------------------------- ### WebSocket Server Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Start a WebSocket server for real-time remote control of the device. ```APIDOC ## WebSocket Server ### Description Start a WebSocket server for real-time remote control of the device. ### Method Command Line Interface (CLI) ### Endpoint Not applicable (runs as a server process). ### Parameters #### Command Line Arguments - **-a** or **--address** (string) - Required - The MAC address of the device to control. - **-p** or **--port** (integer) - Optional - The port to run the WebSocket server on (default: 4444). ### Request Example ```bash python -m pypixelcolor.websocket -a 30:E1:AF:BD:5F:D0 python -m pypixelcolor.websocket -a 30:E1:AF:BD:5F:D0 -p 8080 ``` ### Response This is a server process and does not return a typical API response. It listens for WebSocket connections. ``` -------------------------------- ### Start WebSocket Server with Custom Host and Port Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/websocket.md Specify a custom host and port for the WebSocket server using the --host and --port options. Ensure the MAC address is provided. ```bash python -m pypixelcolor.websocket -a --host 0.0.0.0 --port 4444 ``` -------------------------------- ### Example scan output Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/cli.md Sample output showing the format of discovered devices. ```txt % pypixelcolor --scan ℹ️ [2025-11-18 21:07:35] [pypixelcolor.cli] Scanning for Bluetooth devices... ℹ️ [2025-11-18 21:07:40] [pypixelcolor.cli] Found 1 device(s): ℹ️ [2025-11-18 21:07:40] [pypixelcolor.cli] - LED_BLE_E1BD5C80 (30:E1:AF:BD:5F:D0) ``` -------------------------------- ### Navigate to pypixelcolor directory Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/installation.md Change your current directory to the cloned pypixelcolor repository folder. This is a necessary step before installing from source. ```bash cd pypixelcolor ``` -------------------------------- ### Clone pypixelcolor repository Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/getting_started/installation.md Clone the pypixelcolor source code from GitHub to install it from source. This requires Git to be installed. ```bash git clone https://github.com/lucagoc/pypixelcolor.git ``` -------------------------------- ### WebSocket JSON command payload Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Example JSON structure for sending commands to the WebSocket server. ```json { "command": "send_text", "params": [ "text=Hello from WebSocket", "animation=1", "speed=100" ] } ``` -------------------------------- ### Initialize and Connect Synchronous Client (Python) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Use the synchronous Client class for basic Python scripts. Instantiate the client with the device's MAC address and establish a connection. ```python import pypixelcolor # Create client with device MAC address device = pypixelcolor.Client("30:E1:AF:BD:5F:D0") # Connect to device device.connect() # Get device information info = device.get_device_info() print(f"Device: {info.width}x{info.height}") ``` -------------------------------- ### Control multiple devices with Python Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Manage multiple device instances by iterating through a list of clients. ```python import pypixelcolor devices = [ pypixelcolor.Client("30:E1:AF:BD:5F:D0"), pypixelcolor.Client("30:E1:AF:BD:20:A9") ] for device in devices: device.connect() for device in devices: device.send_text("Hello from Python!", animation=1, speed=100) for device in devices: device.disconnect() ``` -------------------------------- ### Configure iPixel Device Settings (CLI) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Adjust device settings such as brightness, power state, and orientation. Brightness ranges from 0 to 100. ```bash # Set brightness (0-100) pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_brightness 50 ``` ```bash # Turn device off pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_power false ``` ```bash # Turn device on pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_power true ``` ```bash # Set orientation (0-3 for 0°, 90°, 180°, 270°) pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_orientation 2 ``` -------------------------------- ### Controlling Multiple Devices Synchronously Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Manage multiple LED matrix devices by iterating through a list of clients. ```python import pypixelcolor # Define device addresses addresses = [ "30:E1:AF:BD:5F:D0", "30:E1:AF:BD:20:A9" ] # Create and connect to all devices devices = [pypixelcolor.Client(addr) for addr in addresses] for device in devices: device.connect() # Send same content to all devices for device in devices: device.send_text("Sync!", animation=1, speed=100) # Set same brightness on all for device in devices: device.set_brightness(50) # Disconnect all devices for device in devices: device.disconnect() ``` -------------------------------- ### Retrieve Device Information Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Use the Client class to connect to a device and access its hardware capabilities and screen dimensions. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Get device information (retrieved during connect) info = device.get_device_info() print(f"Device Type: {info.device_type}") print(f"LED Type: {info.led_type}") print(f"Screen Size: {info.width}x{info.height}") print(f"MCU Version: {info.mcu_version}") print(f"WiFi Version: {info.wifi_version}") print(f"Has WiFi: {info.has_wifi}") print(f"Password Flag: {info.password_flag}") # Use dimensions for conditional logic if info.height == 32: device.send_text("32px height!", animation=3) else: device.send_text("Other size", animation=1) ``` -------------------------------- ### Configure Rhythm Mode Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Set up audio visualization and rhythm display modes. Supports different styles and level bar configurations, as well as an alternative rhythm mode with animation time. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Set rhythm mode style (0-4) device.set_rhythm_mode(style=1) # Set rhythm mode with level bars (l1-l11, values 0-15) device.set_rhythm_mode( style=2, l1=5, l2=8, l3=12, l4=15, l5=10, l6=8, l7=6, l8=4, l9=3, l10=2, l11=1 ) # Alternative rhythm mode (style 0-1, animation time 0-7) device.set_rhythm_mode_2(style=0, t=3) ``` -------------------------------- ### Scan for Bluetooth devices via CLI Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Use this command to discover nearby iPixel Color devices and retrieve their MAC addresses. ```bash pypixelcolor --scan ``` -------------------------------- ### Configure Clock Mode on iPixel Device (CLI) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Enable and customize the clock mode on the LED matrix. Options include style, 12/24 hour format, and date display. Device time can also be set manually. ```bash # Enable clock mode with default style pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_clock_mode ``` ```bash # Enable clock mode with specific style (0-8) pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_clock_mode style=3 ``` ```bash # Clock mode with 12-hour format pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_clock_mode format_24=false ``` ```bash # Clock mode without date display pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_clock_mode show_date=false ``` ```bash # Set device time manually pypixelcolor -a 30:E1:AF:BD:5F:D0 -c set_time hour=14 minute=30 second=0 ``` -------------------------------- ### Send Image or GIF to iPixel Device (CLI) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Display images (PNG) or animated GIFs on the LED matrix. Supports automatic resizing and saving to device slots. Use 'fit' mode to add padding. ```bash # Send a PNG image pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_image ./logo.png ``` ```bash # Send an animated GIF pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_image ./animation.gif ``` ```bash # Send image with fit mode (adds black padding) pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_image ./image.png resize_method=fit ``` ```bash # Send image and save to slot pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_image ./image.png save_slot=2 ``` -------------------------------- ### Control device using Python library Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Basic usage of the pypixelcolor library to connect and send text to a device. ```python import pypixelcolor # Create a PixelColor device instance device = pypixelcolor.Client("30:E1:AF:BD:5F:D0") # Connect to the device device.connect() # Send a text message to the device device.send_text("Hello from Python!", animation=1, speed=100) # Disconnect from the device device.disconnect() ``` -------------------------------- ### Basic Device Operations Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Common commands for interacting with a connected LED matrix device. ```python # Send text with animation device.send_text("Hello from Python!", animation=1, speed=100) # Send text with custom color device.send_text("Red Text", color="ff0000") # Send an image device.send_image("./logo.png") # Set brightness device.set_brightness(75) # Enable clock mode device.set_clock_mode(style=2, format_24=True) # Disconnect when done device.disconnect() ``` -------------------------------- ### Asynchronous Client with Context Manager Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Use an async context manager for cleaner resource management in asynchronous workflows. ```python import asyncio import pypixelcolor async def main(): # Using async context manager async with pypixelcolor.AsyncClient("30:E1:AF:BD:5F:D0") as device: # Send image with resize method await device.send_image("./image.png", resize_method="fit") # Enable clock mode await device.set_clock_mode(style=1, show_date=True) # Set power state await device.set_power(True) asyncio.run(main()) ``` -------------------------------- ### AsyncClient Usage Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/reference/async_client.fr.md This section covers the asynchronous client for Pypixelcolor, detailing its methods and usage patterns. ```APIDOC ## AsyncClient ### Description The `AsyncClient` class provides an asynchronous interface for interacting with the Pypixelcolor library. It allows for non-blocking operations, making it suitable for applications that require high concurrency. ### Methods #### `__init__` Initializes the `AsyncClient`. #### `get_image` Fetches an image from a given URL asynchronously. - **url** (str) - Required - The URL of the image to fetch. #### `get_image_from_bytes` Processes image data from bytes asynchronously. - **image_bytes** (bytes) - Required - The raw bytes of the image. #### `close` Closes the asynchronous client and releases any resources. ### Request Example ```python import asyncio from pypixelcolor.client import AsyncClient async def main(): async with AsyncClient() as client: # Example usage of get_image image_url = "http://example.com/image.jpg" image_data = await client.get_image(image_url) print(f"Fetched image data: {len(image_data)} bytes") # Example usage of get_image_from_bytes (assuming you have image bytes) # with open("local_image.jpg", "rb") as f: # image_bytes = f.read() # image_data_from_bytes = await client.get_image_from_bytes(image_bytes) # print(f"Processed image from bytes: {len(image_data_from_bytes)} bytes") if __name__ == "__main__": asyncio.run(main()) ``` ### Response #### Success Response (200) - **image_data** (bytes) - The raw bytes of the image fetched or processed. #### Response Example ``` # Example output when fetching an image: # Fetched image data: 12345 bytes ``` ``` -------------------------------- ### Control Device Power, Brightness, and Orientation Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Manage device power state, set brightness levels (0-100), and control screen orientation (0°, 90°, 180°, 270°). ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Brightness: 0-100 device.set_brightness(100) # Full brightness device.set_brightness(25) # Dim device.set_brightness(0) # Off (display dark) # Power control device.set_power(True) # Turn on device.set_power(False) # Turn off (standby) # Orientation: 0-3 (0°, 90°, 180°, 270° rotation) device.set_orientation(0) # Normal device.set_orientation(2) # Upside down ``` -------------------------------- ### Device Settings Functions Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Control device power, brightness, and screen orientation. ```APIDOC ## Device Settings Functions ### Description Control device power, brightness, and screen orientation. ### Methods #### set_brightness - **Method**: POST (implied) - **Endpoint**: `/api/device/brightness` (hypothetical) - **Parameters**: - **brightness** (integer) - Required - Brightness level (0-100). #### set_power - **Method**: POST (implied) - **Endpoint**: `/api/device/power` (hypothetical) - **Parameters**: - **state** (boolean) - Required - Power state (True for on, False for off). #### set_orientation - **Method**: POST (implied) - **Endpoint**: `/api/device/orientation` (hypothetical) - **Parameters**: - **orientation** (integer) - Required - Orientation (0, 1, 2, 3 for 0°, 90°, 180°, 270°). ### Request Example ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: device.set_brightness(100) device.set_brightness(25) device.set_brightness(0) device.set_power(True) device.set_power(False) device.set_orientation(0) device.set_orientation(2) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Manage iPixel Device Data Slots (CLI) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Manage content stored on the device's internal slots. View content, delete specific slots, or clear all stored data. ```bash # Show content from a specific slot pypixelcolor -a 30:E1:AF:BD:5F:D0 -c show_slot 1 ``` ```bash # Delete a specific slot pypixelcolor -a 30:E1:AF:BD:5F:D0 -c delete 1 ``` ```bash # Clear all device ROM data (including settings) pypixelcolor -a 30:E1:AF:BD:5F:D0 -c clear ``` -------------------------------- ### Verify Android device connection Source: https://github.com/lucagoc/pypixelcolor/wiki/Tutorials Use this command to confirm that the Android device is correctly recognized by the computer via ADB. ```bash adb devices ``` -------------------------------- ### Pypixelcolor Sync Client Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/reference/sync_client.md This section provides documentation for the synchronous client of the pypixelcolor library. ```APIDOC ## Client Class ### Description Represents the synchronous client for interacting with pypixelcolor functionalities. ### Class `pypixelcolor.client.Client` ### Methods (Details of methods would be listed here if available in the source text) ### Usage Example ```python from pypixelcolor.client import Client # Instantiate the client client = Client() # Example usage of a method (if known) # result = client.some_method(param1='value') ``` ``` -------------------------------- ### Set Rhythm Mode (Alternative) Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands An alternative version for setting the rhythm mode, accepting a style (0 or 1) and animation time. Raises ValueError for invalid style or time inputs. ```python def set_rhythm_mode_2(style: int = 0, t: int = 0) ``` -------------------------------- ### Synchronous Client with Context Manager Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Use the context manager to ensure the device connection is automatically closed after operations. ```python import pypixelcolor # Using context manager for automatic connection management with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Send text message device.send_text("Context Manager!", animation=1, speed=80) # Set brightness device.set_brightness(50) # Get device info info = device.get_device_info() print(f"Connected to {info.width}x{info.height} display") # Connection is automatically closed when exiting the with block ``` -------------------------------- ### Asynchronous concurrent device control Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Use AsyncClient and asyncio to send commands to multiple devices concurrently. Note that heavy operations may be unstable. ```python import asyncio import pypixelcolor async def main(): addresses = [ "30:E1:AF:BD:5F:D0", "30:E1:AF:BD:20:A9", ] # Create clients and connect sequentially (safe for common backends) devices = [] for addr in addresses: client = pypixelcolor.AsyncClient(addr) await client.connect() devices.append(client) if not devices: return # Launch sends concurrently across all connected devices tasks = [asyncio.create_task(d.send_image("./python.png")) for d in devices] await asyncio.gather(*tasks) # Disconnect all for d in devices: await d.disconnect() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Send Text to iPixel Device (CLI) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Send text messages to the LED matrix. Customize animation, speed, color, and background color. Text can also be saved to a device slot. ```bash # Send basic text message pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_text "Hello World" ``` ```bash # Send text with animation and speed pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_text "Hello pypixelcolor" animation=1 speed=100 ``` ```bash # Send text with custom color (hex RGB) pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_text "Red Text" color=ff0000 ``` ```bash # Send text with rainbow mode pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_text "Rainbow!" rainbow_mode=1 ``` ```bash # Send text with background color pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_text "Highlighted" bg_color=0000ff ``` ```bash # Send text and save to slot for later recall pypixelcolor -a 30:E1:AF:BD:5F:D0 -c send_text "Saved Message" save_slot=1 ``` -------------------------------- ### Rhythm Mode Functions Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Configure audio visualization/rhythm display modes. ```APIDOC ## Rhythm Mode Functions ### Description Configure audio visualization/rhythm display modes. ### Methods #### set_rhythm_mode - **Method**: POST (implied) - **Endpoint**: `/api/device/rhythm_mode` (hypothetical) - **Parameters**: - **style** (integer) - Required - Rhythm mode style (0-4). - **l1** to **l11** (integer) - Optional - Level values for each bar (0-15). #### set_rhythm_mode_2 - **Method**: POST (implied) - **Endpoint**: `/api/device/rhythm_mode_2` (hypothetical) - **Parameters**: - **style** (integer) - Required - Rhythm mode style (0-1). - **t** (integer) - Required - Animation time (0-7). ### Request Example ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: device.set_rhythm_mode(style=1) device.set_rhythm_mode( style=2, l1=5, l2=8, l3=12, l4=15, l5=10, l6=8, l7=6, l8=4, l9=3, l10=2, l11=1 ) device.set_rhythm_mode_2(style=0, t=3) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Show Slot Command Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/data.md The `show_slot` command is used to display content stored in a specific slot. Refer to the pypixelcolor.commands.show_slot.show_slot documentation for details. ```APIDOC ## `show_slot` Command ### Description Displays content stored in a specific slot. ### Method (Assumed to be a command-line or API call, specific method not detailed in source) ### Endpoint (Not applicable for command-line interface) ### Parameters #### Query Parameters - **slot_id** (int) - Required - The identifier of the slot to display. ### Request Example ``` show_slot(slot_id=1) ``` ### Response (No specific response details provided in source) ``` -------------------------------- ### Data Slots Overview Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/data.md The device provides 'slots' to store text and image data. Saving content in these slots is done via the `save_slot=` argument in their respective commands. This allows for faster access and reduces the time needed to display the content on the LED matrix. Warning: Using slots can cause bootloops if the send command contains corrupted data. Ensure sending works correctly without using slots before enabling them. ```APIDOC ## Data Slots ### Description Slots are used to store text and image data for faster access and reduced display times on the LED matrix. Content is saved using the `save_slot=` argument. ### Warning Using slots can cause bootloops if the send command contains corrupted data. Always test sending without slots first. ``` -------------------------------- ### Concurrent Control with AsyncClient Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Execute commands across multiple devices concurrently using asyncio tasks. ```python import asyncio import pypixelcolor async def main(): addresses = [ "30:E1:AF:BD:5F:D0", "30:E1:AF:BD:20:A9", ] # Connect to devices sequentially (safe for Bluetooth backend) devices = [] for addr in addresses: client = pypixelcolor.AsyncClient(addr) await client.connect() devices.append(client) # Send commands concurrently to all devices tasks = [ asyncio.create_task(d.send_text("Hello!", animation=1)) for d in devices ] await asyncio.gather(*tasks) # Disconnect all devices for d in devices: await d.disconnect() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Downgrade bleak library version Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/troubleshooting/bluetooth_connection.md Use this command sequence to revert to a stable version of bleak if connection issues persist. ```bash pip uninstall bleak pip install bleak==1.1.1 ``` -------------------------------- ### AsyncClient Overview Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/reference/async_client.md The AsyncClient class provides an asynchronous interface for interacting with the pypixelcolor functionalities. It is designed to be used within an asyncio event loop. ```APIDOC ## AsyncClient ### Description Provides an asynchronous interface for pypixelcolor functionalities. ### Usage ```python import asyncio from pypixelcolor.client import AsyncClient async def main(): async with AsyncClient() as client: # Use client methods here pass if __name__ == "__main__": asyncio.run(main()) ``` ### Methods (Specific methods would be detailed here if available in the source text) ``` -------------------------------- ### Set Device Power State Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Controls the power state of the device, turning it on or off. Defaults to turning the device on. ```python def set_power(on: bool = True) ``` -------------------------------- ### Customizing send_text Function Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Demonstrates various parameters for text display including animation, color, fonts, and saving to slots. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Basic text device.send_text("Hello World") # Text with animation (0-7, except 3 and 4 on non-32x32 devices) # 0=static, 1=scroll left, 2=scroll right, 5=flash, 6=fade, 7=expand device.send_text("Scrolling", animation=1, speed=80) # Rainbow mode (0-9) device.send_text("Rainbow!", rainbow_mode=3) # Custom text and background color (hex RGB) device.send_text("Colored", color="ff0000", bg_color="0000ff") # Different built-in fonts: CUSONG, SIMSUN, VCR_OSD_MONO device.send_text("Font Test", font="VCR_OSD_MONO") # Save to device slot (1-10) for quick recall device.send_text("Saved!", save_slot=5) ``` -------------------------------- ### Clear Command Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/data.md The `clear` command is used to clear content from the device. Refer to the pypixelcolor.commands.clear.clear documentation for details. ```APIDOC ## `clear` Command ### Description Clears content from the device. ### Method (Assumed to be a command-line or API call, specific method not detailed in source) ### Endpoint (Not applicable for command-line interface) ### Parameters (No specific parameters detailed in source for the `clear` command itself, beyond the general `save_slot` argument mentioned in the overview) ### Request Example ``` clear() ``` ### Response (No specific response details provided in source) ``` -------------------------------- ### WebSocket Command API Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Endpoints for controlling the LED matrix device via WebSocket JSON commands. ```APIDOC ## POST /websocket ### Description Send commands to the LED matrix device via WebSocket connection. ### Method POST ### Request Body - **command** (string) - Required - The action to perform (e.g., "send_text", "send_image", "set_brightness", "set_clock_mode") - **params** (array) - Required - A list of parameters specific to the command. ### Request Example { "command": "send_text", "params": ["text=Hello WebSocket", "animation=1", "speed=100"] } ### Supported Commands - **send_text**: Requires parameters for text, animation, and speed. - **send_image**: Requires a path parameter to the image file. - **set_brightness**: Requires a single integer parameter (0-100). - **set_clock_mode**: Requires style and format_24 parameters. ``` -------------------------------- ### Set Orientation Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/settings.md Sets the display orientation of the device. ```APIDOC ## set_orientation ### Description Sets the display orientation of the device. ### Method POST ### Endpoint /device/orientation ### Parameters #### Request Body - **orientation** (string) - Required - The desired orientation ('portrait', 'landscape', 'portrait_upside_down', 'landscape_upside_down'). ### Request Example { "orientation": "landscape" } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation ('success' or 'error'). #### Response Example { "status": "success" } ``` -------------------------------- ### Fun Mode and Pixel Control Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Enable fun mode for individual pixel control. ```APIDOC ## Fun Mode and Pixel Control ### Description Enable fun mode for individual pixel control. ### Methods #### set_fun_mode - **Method**: POST (implied) - **Endpoint**: `/api/device/fun_mode` (hypothetical) - **Parameters**: - **enabled** (boolean) - Required - Whether to enable fun mode. #### set_pixel - **Method**: POST (implied) - **Endpoint**: `/api/device/pixel` (hypothetical) - **Parameters**: - **x** (integer) - Required - X-coordinate of the pixel. - **y** (integer) - Required - Y-coordinate of the pixel. - **color** (string) - Required - Color in hexadecimal format (e.g., 'ff0000'). ### Request Example ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: device.set_fun_mode(True) device.set_pixel(x=0, y=0, color="ff0000") device.set_pixel(x=15, y=15, color="00ff00") device.set_pixel(x=31, y=31, color="0000ff") device.set_fun_mode(False) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Device Control Functions Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Functions for managing basic device states like power, brightness, orientation, and memory clearing. ```APIDOC ## clear ### Description Clears the EEPROM. ## set_brightness ### Description Set the brightness of the device. ### Parameters - **level** (int) - Required - Brightness level (0-100). ## set_orientation ### Description Set the orientation of the device. ### Parameters - **orientation** (int) - Optional - The orientation value to set (0-3). Defaults to 0. ## set_power ### Description Set the power state of the device. ### Parameters - **on** (bool) - Optional - True to turn on, False to turn off. Defaults to True. ``` -------------------------------- ### Execute multiple CLI commands Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Chain multiple operations in a single command execution. ```bash pypixelcolor -a -c clear -c set_brightness 0 -c set_clock_mode ``` -------------------------------- ### Error message for bleak 2.0.x connection failure Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/troubleshooting/bluetooth_connection.md This error occurs when attempting to enable response notifications with incompatible versions of bleak. ```txt Failed to enable response notifications: [org.freedesktop.DBus.Error.UnknownObject] Method "AcquireNotify" with signature "a{sv}" on interface "org.bluez.GattCharacteristic1" doesn't exist ``` -------------------------------- ### Execute Multiple Commands (CLI) Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Chain multiple commands in a single CLI invocation to improve efficiency. Options for disabling emojis and enabling debug logging are also shown. ```bash # Chain multiple commands: clear, set brightness, then clock mode pypixelcolor -a 30:E1:AF:BD:5F:D0 -c clear -c set_brightness 0 -c set_clock_mode ``` ```bash # Disable emojis in output for terminals without emoji support pypixelcolor --noemojis -a 30:E1:AF:BD:5F:D0 -c send_text "Hello" ``` ```bash # Enable debug logging for troubleshooting pypixelcolor --loglevel DEBUG -a 30:E1:AF:BD:5F:D0 -c send_text "Debug Mode" ``` -------------------------------- ### Display and Mode Functions Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Functions for configuring clock modes, rhythm modes, fun modes, and pixel manipulation. ```APIDOC ## delete ### Description Delete a specific screen by its index. ### Parameters - **n** (int) - Required - Index of the screen to delete. ## set_clock_mode ### Description Set the clock mode of the device. ### Parameters - **style** (int) - Optional - The clock style (0-8). Defaults to 1. - **date** (str) - Optional - The date to display (DD/MM/YYYY). Defaults to today. - **show_date** (bool) - Optional - Whether to show the date. Defaults to True. - **format_24** (bool) - Optional - Whether to use 24-hour format. Defaults to True. ## set_fun_mode ### Description Enable or disable fun mode. ### Parameters - **enable** (bool) - Optional - Enables (True) or disables (False) fun mode. Defaults to False. ## set_pixel ### Description Defines the color of a specific pixel. ### Parameters - **x** (int) - Required - X coordinate of the pixel. - **y** (int) - Required - Y coordinate of the pixel. - **color** (str) - Required - Color in hexadecimal format (e.g., 'FF0000'). ## set_rhythm_mode ### Description Set the rhythm mode of the device. ### Parameters - **style** (int) - Required - The style of the rhythm mode (0-4). - **l1-l11** (int) - Optional - Levels 1-11 (0-15). ``` -------------------------------- ### Set Rhythm Mode Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Configures the rhythm mode of the device with a style and multiple level parameters. Raises ValueError for invalid style or level inputs. ```python 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) ``` -------------------------------- ### Enable Fun Mode and Control Pixels Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Enable fun mode to control individual pixels by their coordinates (x, y) and color. Supports disabling fun mode afterwards. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Enable fun mode (required for set_pixel) device.set_fun_mode(True) # Set individual pixels by coordinates and color device.set_pixel(x=0, y=0, color="ff0000") # Red at top-left device.set_pixel(x=15, y=15, color="00ff00") # Green at (15,15) device.set_pixel(x=31, y=31, color="0000ff") # Blue at (31,31) # Disable fun mode device.set_fun_mode(False) ``` -------------------------------- ### Define image resize modes Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Enumeration for specifying how images are scaled to fit the device display. ```python class ResizeMethod(Enum) ``` -------------------------------- ### Send text messages via CLI Source: https://github.com/lucagoc/pypixelcolor/wiki/Home Commands to send text to a specific device, with optional animation and speed parameters. ```bash pypixelcolor -a -c send_text "Hello pypixelcolor" ``` ```bash pypixelcolor -a -c send_text "Hello pypixelcolor" animation=1 speed=100 ``` -------------------------------- ### Configure Clock Mode Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Display time on the device with customizable clock face styles, date display, and 12/24 hour format. Allows setting a specific date. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Enable clock mode with defaults device.set_clock_mode() # Clock style 0-8 (different visual designs) device.set_clock_mode(style=3) # 12-hour format device.set_clock_mode(format_24=False) # Hide date display device.set_clock_mode(show_date=False) # Set specific date (DD/MM/YYYY format) device.set_clock_mode(style=1, date="25/12/2024") # Full customization device.set_clock_mode( style=2, date="01/01/2025", show_date=True, format_24=True ) ``` -------------------------------- ### Manually Set Device Time Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Manually set the device's internal clock by specifying hour, minute, and second. Can also sync to the current system time. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Set time to 14:30:00 device.set_time(hour=14, minute=30, second=0) # Set only hour (others use current time) device.set_time(hour=12) # Sync to current system time (default if no args) device.set_time() ``` -------------------------------- ### Delete Command Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/data.md The `delete` command is used to delete content from the device. Refer to the pypixelcolor.commands.delete.delete documentation for details. ```APIDOC ## `delete` Command ### Description Deletes content from the device. ### Method (Assumed to be a command-line or API call, specific method not detailed in source) ### Endpoint (Not applicable for command-line interface) ### Parameters (No specific parameters detailed in source for the `delete` command itself, beyond the general `save_slot` argument mentioned in the overview) ### Request Example ``` delete() ``` ### Response (No specific response details provided in source) ``` -------------------------------- ### Set Power Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/settings.md Controls the power state of the device. ```APIDOC ## set_power ### Description Sets the power state of the device. ### Method POST ### Endpoint /device/power ### Parameters #### Request Body - **state** (string) - Required - The desired power state ('on' or 'off'). ### Request Example { "state": "on" } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation ('success' or 'error'). #### Response Example { "status": "success" } ``` -------------------------------- ### Send Images with pypixelcolor Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Send static or animated images to the device. Supports automatic resizing, cropping, fitting, and saving to slots. Formats include PNG, JPG, GIF, WEBP, BMP, TIFF, and HEIC/HEIF with pillow-heif. ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: # Send PNG image (auto-resized to device dimensions) device.send_image("./logo.png") # Send animated GIF device.send_image("./animation.gif") # Resize with crop (fills display, crops excess) - default device.send_image("./photo.jpg", resize_method="crop") # Resize with fit (maintains aspect ratio, adds black padding) device.send_image("./photo.jpg", resize_method="fit") # Save image to slot for later display device.send_image("./icon.png", save_slot=3) # Supported formats: PNG, JPG, JPEG, GIF, WEBP, BMP, TIFF # HEIC/HEIF supported with pillow-heif installed ``` -------------------------------- ### send_image Function Source: https://context7.com/lucagoc/pypixelcolor/llms.txt Send static images or animated GIFs with automatic resizing to match device dimensions. ```APIDOC ## send_image Function ### Description Send static images or animated GIFs with automatic resizing to match device dimensions. ### Method POST (implied by sending data) ### Endpoint `/api/device/image` (hypothetical endpoint for illustration) ### Parameters #### Path Parameters None #### Query Parameters - **resize_method** (string) - Optional - Method for resizing images. Options: 'crop' (default), 'fit'. - **save_slot** (integer) - Optional - Slot number to save the image to. #### Request Body - **image_data** (file) - Required - The image file (PNG, JPG, GIF, WEBP, BMP, TIFF, HEIC/HEIF with pillow-heif). ### Request Example ```python import pypixelcolor with pypixelcolor.Client("30:E1:AF:BD:5F:D0") as device: device.send_image("./logo.png") device.send_image("./animation.gif") device.send_image("./photo.jpg", resize_method="crop") device.send_image("./photo.jpg", resize_method="fit") device.send_image("./icon.png", save_slot=3) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### set_fun_mode Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/other.fr.md Sets the device to a specific 'fun' mode. ```APIDOC ## set_fun_mode ### Description Sets the device to a specific 'fun' mode. ### Endpoint pypixelcolor.commands.set_fun_mode.set_fun_mode ``` -------------------------------- ### Set Clock Mode Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Configures the clock mode of the device, including style, date display, and time format. Optional arguments allow customization. ```python def set_clock_mode(style: int = 1, date="", show_date: bool = True, format_24: bool = True) ``` -------------------------------- ### Set device time Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Updates the device clock. Uses the same underlying command as get_device_info. ```python def set_time(hour: Optional[int] = None, minute: Optional[int] = None, second: Optional[int] = None) ``` -------------------------------- ### set_rhythm_mode Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/other.md Activates a rhythm mode for the pixel display. ```APIDOC ## `set_rhythm_mode` ### Description Activates a rhythm mode for the pixel display. ### Method (Method not specified in source) ### Endpoint (Endpoint not specified in source) ### Parameters (Parameters not specified in source) ### Request Example (Request example not specified in source) ### Response #### Success Response (200) (Success response details not specified in source) #### Response Example (Response example not specified in source) ``` -------------------------------- ### Set Brightness Source: https://github.com/lucagoc/pypixelcolor/blob/main/docs/commands/settings.md Adjusts the brightness level of the device. ```APIDOC ## set_brightness ### Description Sets the brightness level of the device. ### Method POST ### Endpoint /device/brightness ### Parameters #### Request Body - **level** (integer) - Required - The desired brightness level (0-100). ### Request Example { "level": 50 } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation ('success' or 'error'). #### Response Example { "status": "success" } ``` -------------------------------- ### Send image or animation Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Transmits image files or raw hex data to the device. Supports automatic resizing if device_info is provided. ```python def send_image(path: Union[str, Path], resize_method: Union[str, ResizeMethod] = ResizeMethod.CROP, device_info: Optional[DeviceInfo] = None) ``` ```python def send_image_hex(hex_string: Union[str, bytes], file_extension: str, resize_method: Union[str, ResizeMethod] = ResizeMethod.CROP, device_info: Optional[DeviceInfo] = None) ``` -------------------------------- ### Clear EEPROM Source: https://github.com/lucagoc/pypixelcolor/wiki/Commands Clears the EEPROM of the device. No arguments are required. ```python def clear() ```