### Install StupidArtnet from GitHub Source: https://github.com/cpvalente/stupidartnet/blob/master/README.md Clone the repository and run the example file to verify installation. ```bash git clone https://github.com/cpvalente/stupidArtnet.git cd stupidArtnet python3 examples/example.py ``` -------------------------------- ### Install StupidArtnet using Pip Source: https://github.com/cpvalente/stupidartnet/blob/master/README.md Install the library directly from PyPI using pip. ```pip pip install stupidartnet ``` -------------------------------- ### Use ArtnetUtils Byte Manipulation Helpers Source: https://context7.com/cpvalente/stupidartnet/llms.txt Provides examples for converting 16-bit values, clamping ranges, and generating Art-Net address masks. ```python from stupidArtnet import shift_this, put_in_range, make_address_mask # shift_this: Convert 16-bit value to MSB/LSB tuple msb, lsb = shift_this(512) print(f'512 -> MSB: {msb}, LSB: {lsb}') # MSB: 2, LSB: 0 # Reverse order (low byte first) lsb, msb = shift_this(512, high_first=False) print(f'512 -> LSB: {lsb}, MSB: {msb}') # LSB: 0, MSB: 2 # put_in_range: Clamp value and optionally make even value = put_in_range(1000, 0, 512, make_even=True) print(f'1000 clamped to 0-512 (even): {value}') # 512 value = put_in_range(99, 0, 512, make_even=True) print(f'99 made even: {value}') # 100 # make_address_mask: Create Art-Net address bytes # Simplified mode (universe 0-32767) mask = make_address_mask(universe=17, is_simplified=True) print(f'Universe 17 mask: {list(mask)}') # [17, 0] # Full Art-Net 4 addressing mask = make_address_mask(universe=5, sub=2, net=1, is_simplified=False) print(f'Net 1, Sub 2, Uni 5 mask: {list(mask)}') # [37, 1] ``` -------------------------------- ### Dynamic Server Configuration: Get Buffer and Set Callback Source: https://context7.com/cpvalente/stupidartnet/llms.txt Access received DMX data directly via `get_buffer()` or dynamically change callback functions for existing listeners using `set_callback()`. ```python from stupidArtnet import StupidArtnetServer import time server = StupidArtnetServer() ``` -------------------------------- ### Universe, Subnet, and Net Configuration Source: https://context7.com/cpvalente/stupidartnet/llms.txt Configure advanced Art-Net addressing, including net, subnet, and universe, for complex installations. Supports both simplified and full Art-Net 4 addressing modes. ```APIDOC ## Universe, Subnet, and Net Configuration ### Description Configure advanced Art-Net addressing for large installations. By default, simplified mode allows universe 0-255. Disable simplified mode to use full Art-Net 4 addressing with 128 nets x 16 subnets x 16 universes. ### Method `set_universe(universe)`: Sets the universe address. `set_simplified(simplified)`: Enables or disables simplified mode. `set_net(net)`: Sets the net address (when simplified mode is off). `set_subnet(subnet)`: Sets the subnet address (when simplified mode is off). `show()`: Prints the current Art-Net configuration. ### Parameters - **universe** (int) - The universe address (0-255 in simplified mode, 0-15 when simplified mode is off). - **simplified** (bool) - `True` to enable simplified mode, `False` to disable. - **net** (int) - The net address (0-127, only when simplified mode is off). - **subnet** (int) - The subnet address (0-15, only when simplified mode is off). ### Request Example ```python from stupidArtnet import StupidArtnet artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Simplified mode (default): universe 0-255 artnet.set_universe(17) # Equivalent to subnet 1, universe 1 # Disable simplified mode for full Art-Net 4 addressing artnet.set_simplified(False) # Now configure net, subnet, and universe separately artnet.set_net(0) # Net 0-127 artnet.set_subnet(1) # Subnet 0-15 artnet.set_universe(1) # Universe 0-15 # Print configuration to verify print(artnet) # Output: # =================================== # Stupid Artnet initialized # Target IP: 192.168.1.100 : 6454 # Universe: 1 # Subnet: 1 # Net: 0 # Packet Size: 512 # =================================== artnet.show() del artnet ``` ### Response No direct response. Configuration changes are applied internally. `show()` prints the current configuration to the console. ``` -------------------------------- ### start() and stop() - Threaded Continuous Transmission Source: https://context7.com/cpvalente/stupidartnet/llms.txt Start and stop a background thread for continuous DMX transmission at a configured frame rate. This is essential for maintaining a persistent signal to DMX devices. ```APIDOC ## start() and stop() ### Description Start continuous DMX transmission in a background thread at the configured frame rate (default 30fps). Use this for persistent signal required by most DMX devices. ### Method `start()`: Starts the transmission thread. `stop()`: Stops the transmission thread. ### Parameters None for `start()` and `stop()` directly. Configuration is done during `StupidArtnet` initialization. ### Request Example ```python from stupidArtnet import StupidArtnet import time import random artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=100, fps=30) # Start continuous transmission thread artnet.start() # Update DMX values while thread is running packet = bytearray(100) for cycle in range(50): # Fill with random values for i in range(100): packet[i] = random.randint(0, 255) artnet.set(packet) time.sleep(0.2) # Thread continues sending at 30fps # Blackout before stopping artnet.blackout() # Stop the transmission thread artnet.stop() del artnet ``` ### Response No direct response for `start()` and `stop()`. Success is indicated by the thread running or stopping as expected. Errors may be raised during initialization or if the thread cannot be started/stopped. ``` -------------------------------- ### Persistent Art-Net Sending Source: https://github.com/cpvalente/stupidartnet/blob/master/README.md Utilize the threaded capabilities of StupidArtnet to send Art-Net data persistently at a regular interval. Remember to start the thread before sending and stop it when finished. ```python # TO SEND PERSISTENT SIGNAL YOU CAN START THE THREAD a.start() # AND MODIFY THE DATA AS YOU GO for x in range(100): for i in range(packet_size): # Fill buffer with random stuff packet[i] = random.randint(0, 255) a.set(packet) time.sleep(.2) # ... REMEMBER TO CLOSE THE THREAD ONCE YOU ARE DONE a.stop() ``` -------------------------------- ### Start and Stop Continuous Art-Net Transmission Source: https://context7.com/cpvalente/stupidartnet/llms.txt Initiates continuous DMX transmission in a background thread at a specified frame rate. Use this for persistent signals. Ensure to call `stop()` to terminate the thread gracefully. ```python from stupidArtnet import StupidArtnet import time import random artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=100, fps=30) # Start continuous transmission thread artnet.start() # Update DMX values while thread is running packet = bytearray(100) for cycle in range(50): # Fill with random values for i in range(100): packet[i] = random.randint(0, 255) artnet.set(packet) time.sleep(0.2) # Thread continues sending at 30fps # Blackout before stopping artnet.blackout() # Stop the transmission thread artnet.stop() del artnet ``` -------------------------------- ### Initialize StupidArtnet Client Source: https://context7.com/cpvalente/stupidartnet/llms.txt Basic initialization of the StupidArtnet client with target IP and universe. Optional parameters like frame rate, packet size, and broadcast mode can be configured. ```python from stupidArtnet import StupidArtnet # Basic initialization with target IP and universe target_ip = '192.168.1.100' # IP of Art-Net device (typically in 2.x or 10.x range) universe = 0 packet_size = 512 # Number of DMX channels to send (max 512) # Create Art-Net client artnet = StupidArtnet(target_ip, universe, packet_size) # Optional parameters available: # fps=30 - Transmission frame rate # even_packet_size=True - Enforce even packet sizes (some receivers require this) # broadcast=False - Enable broadcast mode # source_address=None - Bind to specific network interface # artsync=False - Enable ArtSync for synchronized multi-universe output # port=6454 - Custom UDP port (default Art-Net port is 6454) # Print client configuration print(artnet) # Output: # =================================== # Stupid Artnet initialized # Target IP: 192.168.1.100 : 6454 # Universe: 0 # Packet Size: 512 # =================================== # Cleanup when done del artnet ``` -------------------------------- ### StupidArtnet Initialization Source: https://context7.com/cpvalente/stupidartnet/llms.txt Initializes the Art-Net client to communicate with a target device. ```APIDOC ## StupidArtnet Initialization ### Description Creates an Art-Net client instance to send DMX data to a specific target IP and universe. ### Parameters #### Request Body - **target_ip** (string) - Required - IP address of the Art-Net device. - **universe** (int) - Required - Art-Net universe (0-32767). - **packet_size** (int) - Required - Number of DMX channels (max 512). - **fps** (int) - Optional - Transmission frame rate (default 30). - **broadcast** (bool) - Optional - Enable broadcast mode. - **artsync** (bool) - Optional - Enable ArtSync for multi-universe synchronization. - **port** (int) - Optional - UDP port (default 6454). ``` -------------------------------- ### Initialize StupidArtnet with Simplified Universe Source: https://github.com/cpvalente/stupidartnet/blob/master/README.md Creates a StupidArtnet instance using the default simplified universe setting (0-255). This is suitable for networks not using subnets, as the library handles subnet masking internally. ```python # Create a StupidArtnet instance with the relevant values # By default universe is simplified to a value between 0 - 255 # this should suffice for anything not using subnets # on sending universe will be masked to two values # making the use of subnets invisible universe = 17 # equivalent to universe 1 subnet 1 a = StupidArtnet(target_ip, universe, packet_size) ``` -------------------------------- ### blackout() and flash_all() - Quick DMX Actions Source: https://context7.com/cpvalente/stupidartnet/llms.txt Convenience methods for immediate DMX actions. `blackout()` sets all channels to 0, and `flash_all()` sets all channels to 255. `flash_all()` can also include an optional delay for auto-blackout. ```APIDOC ## blackout() and flash_all() ### Description Convenience methods to quickly set all channels to 0 (blackout) or 255 (flash). `flash_all()` optionally accepts a delay parameter to auto-blackout after the flash. ### Method `blackout()`: Sets all DMX channels to 0. `flash_all(delay=None)`: Sets all DMX channels to 255. Optionally takes a `delay` in seconds after which it will automatically blackout. ### Parameters - **delay** (float) - Optional - The delay in seconds after which to automatically blackout after a flash. ### Request Example ```python from stupidArtnet import StupidArtnet import time artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Flash all channels at 255, then auto-blackout after 0.5 seconds artnet.flash_all(delay=0.5) # Manual flash/blackout sequence artnet.flash_all() time.sleep(1) artnet.blackout() # Clear buffer without sending artnet.clear() del artnet ``` ### Response No direct response. Actions are performed immediately on the DMX output. ``` -------------------------------- ### Quick DMX Actions: Blackout and Flash All Source: https://context7.com/cpvalente/stupidartnet/llms.txt Convenience methods for setting all DMX channels to 0 (blackout) or 255 (flash). `flash_all()` can auto-blackout after a specified delay. ```python from stupidArtnet import StupidArtnet import time artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Flash all channels at 255, then auto-blackout after 0.5 seconds artnet.flash_all(delay=0.5) # Manual flash/blackout sequence artnet.flash_all() time.sleep(1) artnet.blackout() # Clear buffer without sending artnet.clear() del artnet ``` -------------------------------- ### StupidArtnetServer: Receive Art-Net Data with Callbacks Source: https://context7.com/cpvalente/stupidartnet/llms.txt Creates a server to listen for incoming Art-Net packets. Register listeners for specific universes with optional callback functions to process received DMX data. ```python from stupidArtnet import StupidArtnetServer import time # Callback function receives DMX data as array def on_dmx_received(data): print(f'Received {len(data)} channels') print(f'Channel 1: {data[0]}') print(f'Channel 2: {data[1]}') # Create server (listens on default port 6454) server = StupidArtnetServer() # Register listener for universe 0 with callback listener_id = server.register_listener( universe=0, callback_function=on_dmx_received ) print(server) # Output: # =================================== # Stupid Artnet Listening # =================================== # Let server run for 10 seconds time.sleep(10) # Cleanup del server ``` -------------------------------- ### Set and Send DMX Buffer Source: https://context7.com/cpvalente/stupidartnet/llms.txt Use `set()` to load a DMX buffer and `show()` to transmit it. The `send()` method combines both operations for convenience. Ensure the packet size matches the initialized client. ```python from stupidArtnet import StupidArtnet artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=100) # Create a DMX packet buffer (bytearray) packet = bytearray(100) # Fill with sequential values (channels 1-100) for i in range(100): packet[i] = i % 256 # Load packet into Art-Net client artnet.set(packet) # Send the data to the device artnet.show() # Alternatively, use send() to set and show in one call new_packet = bytearray([255] * 100) # All channels at full artnet.send(new_packet) del artnet ``` -------------------------------- ### register_listener() - Advanced Universe Listening Source: https://context7.com/cpvalente/stupidartnet/llms.txt Demonstrates advanced usage of `register_listener` for multiple universes, including configurations with nets and subnets, and manual polling of data buffers. ```APIDOC ## register_listener() - Advanced Universe Listening ### Description Register multiple listeners for different universes, with support for nets and subnets. Each listener can have its own callback or be polled manually via `get_buffer()`. ### Method `register_listener(universe, callback_function, sub=0, net=0, is_simplified=True)`: Registers a listener. `get_buffer(listener_id)`: Retrieves the DMX data buffer for a specific listener. `delete_listener(listener_id)`: Deletes a specific listener. `delete_all_listener()`: Deletes all registered listeners. ### Parameters - **universe** (int) - The universe address. - **callback_function** (function or None) - The callback function to execute on data reception, or `None` for manual polling. - **sub** (int) - The subnet address (default 0). - **net** (int) - The net address (default 0). - **is_simplified** (bool) - `True` for simplified addressing, `False` for full Art-Net 4 addressing. - **listener_id** (int) - The ID of the listener to delete or poll. ### Request Example ```python from stupidArtnet import StupidArtnetServer import time def callback_universe_0(data): print(f'Universe 0: {len(data)} channels') def callback_universe_1(data, universe): # Callback can optionally receive universe address as second parameter print(f'Universe {universe}: {len(data)} channels') server = StupidArtnetServer() # Simple listener for universe 0 u0_id = server.register_listener( universe=0, callback_function=callback_universe_0 ) # Listener for universe 1 with address in callback u1_id = server.register_listener( universe=1, callback_function=callback_universe_1 ) # Listener with nets and subnets (disable simplified mode) u2_id = server.register_listener( universe=5, sub=2, net=0, is_simplified=False, callback_function=None # Poll manually ) # Let server receive data time.sleep(5) # Manually get buffer from listener without callback buffer = server.get_buffer(u2_id) if len(buffer) > 0: print(f'Polled channel 1: {buffer[0]}') # Delete specific listener server.delete_listener(u1_id) # Delete all listeners server.delete_all_listener() del server ``` ### Response - **listener_id** (int) - The ID of the registered listener. - **buffer** (bytearray) - The DMX data retrieved from `get_buffer()`. ``` -------------------------------- ### Register and Poll Art-Net Server Source: https://context7.com/cpvalente/stupidartnet/llms.txt Demonstrates manual polling for Art-Net data on a specific universe and dynamic configuration of callbacks and address filters. ```python listener_id = server.register_listener(universe=0) # Poll for data periodically for _ in range(10): time.sleep(1) buffer = server.get_buffer(listener_id) if len(buffer) > 0: print(f'Channels received: {len(buffer)}') print(f'First 5 values: {buffer[:5]}') else: print('No data received yet') # Add callback dynamically def new_callback(data): print(f'Now using callback! Got {len(data)} channels') server.set_callback(listener_id, new_callback) # Change universe filter dynamically server.set_address_filter(listener_id, universe=5, sub=0, net=0) # Clear buffer server.clear_buffer(listener_id) time.sleep(5) del server ``` -------------------------------- ### Configure Explicit Net, Subnet, and Universe in StupidArtnet Source: https://github.com/cpvalente/stupidartnet/blob/master/README.md Disables the default universe simplification and allows explicit setting of net, subnet, and universe values. This is useful for precise control in complex Artnet configurations. ```python # You can also disable simplification a.set_simplified(False) # Add net and subnet value # Values here are 0 based a.set_universe(15) a.set_subnet(15) a.set_net(127) ``` -------------------------------- ### Receive Art-Net Data with a Server Source: https://github.com/cpvalente/stupidartnet/blob/master/README.md Use StupidArtnetServer to listen to a specific universe and process incoming Art-Net data via a callback function or by inspecting the buffer. ```python # a StupidArtnetServer can listen to a specific universe # and return new data to a user defined callback a = StupidArtnetServer(universe=0, callback_function=test_callback) # if you prefer, you can also inspect the latest # received data yourself buffer = a.get_buffer() ``` -------------------------------- ### Integrate Art-Net with Tkinter GUI Source: https://context7.com/cpvalente/stupidartnet/llms.txt Shows how to control DMX channel values using a Tkinter slider interface with continuous transmission. ```python from tkinter import Tk, Scale, Label, IntVar, CENTER from stupidArtnet import StupidArtnet # Global Art-Net instance artnet = None window = None def on_slider_change(value): """Send slider value to DMX channel 1.""" global artnet artnet.set_single_value(1, int(value)) def cleanup(): """Clean shutdown when window closes.""" global artnet, window artnet.stop() del artnet window.destroy() # Initialize Art-Net client artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) artnet.start() # Start continuous transmission # Create Tkinter window window = Tk() window.title("DMX Channel 1 Control") # Create slider (0-255 range) slider_value = IntVar() slider = Scale( window, variable=slider_value, command=on_slider_change, from_=255, to=0, label="Channel 1" ) slider.pack(anchor=CENTER, padx=20, pady=20) # Handle window close window.protocol("WM_DELETE_WINDOW", cleanup) # Start GUI window.mainloop() ``` -------------------------------- ### Configure Art-Net Addressing: Universe, Subnet, Net Source: https://context7.com/cpvalente/stupidartnet/llms.txt Configure advanced Art-Net addressing for full Art-Net 4 compatibility. By default, simplified mode is enabled for universes 0-255. Disable simplified mode to configure net, subnet, and universe separately. ```python from stupidArtnet import StupidArtnet artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Simplified mode (default): universe 0-255 artnet.set_universe(17) # Equivalent to subnet 1, universe 1 # Disable simplified mode for full Art-Net 4 addressing artnet.set_simplified(False) # Now configure net, subnet, and universe separately artnet.set_net(0) # Net 0-127 artnet.set_subnet(1) # Subnet 0-15 artnet.set_universe(1) # Universe 0-15 # Print configuration to verify print(artnet) # Output: # =================================== # Stupid Artnet initialized # Target IP: 192.168.1.100 : 6454 # Universe: 1 # Subnet: 1 # Net: 0 # Packet Size: 512 # =================================== artnet.show() del artnet ``` -------------------------------- ### Advanced Server Listeners: Nets, Subnets, and Manual Polling Source: https://context7.com/cpvalente/stupidartnet/llms.txt Register multiple listeners for different universes, including support for nets and subnets. Listeners can have callbacks or be polled manually using `get_buffer()`. Callbacks can optionally receive the universe address. ```python from stupidArtnet import StupidArtnetServer import time def callback_universe_0(data): print(f'Universe 0: {len(data)} channels') def callback_universe_1(data, universe): # Callback can optionally receive universe address as second parameter print(f'Universe {universe}: {len(data)} channels') server = StupidArtnetServer() # Simple listener for universe 0 u0_id = server.register_listener( universe=0, callback_function=callback_universe_0 ) # Listener for universe 1 with address in callback u1_id = server.register_listener( universe=1, callback_function=callback_universe_1 ) # Listener with nets and subnets (disable simplified mode) u2_id = server.register_listener( universe=5, sub=2, net=0, is_simplified=False, callback_function=None # Poll manually ) # Let server receive data time.sleep(5) # Manually get buffer from listener without callback buffer = server.get_buffer(u2_id) if len(buffer) > 0: print(f'Polled channel 1: {buffer[0]}') # Delete specific listener server.delete_listener(u1_id) # Delete all listeners server.delete_all_listener() del server ``` -------------------------------- ### get_buffer() and set_callback() - Dynamic Server Configuration Source: https://context7.com/cpvalente/stupidartnet/llms.txt Access received DMX data directly using `get_buffer()` or dynamically change callback functions for existing listeners using `set_callback()`. ```APIDOC ## get_buffer() and set_callback() ### Description Access received DMX data directly or dynamically change callback functions for existing listeners. ### Method `get_buffer(listener_id)`: Retrieves the DMX data buffer for a specific listener. `set_callback(listener_id, callback_function)`: Dynamically changes the callback function for an existing listener. ### Parameters - **listener_id** (int) - The unique identifier of the listener. - **callback_function** (function) - The new callback function to associate with the listener. ### Request Example ```python from stupidArtnet import StupidArtnetServer import time def initial_callback(data): print("Initial callback executed.") def new_callback(data): print("New callback executed.") server = StupidArtnetServer() listener_id = server.register_listener(universe=0, callback_function=initial_callback) time.sleep(1) # Allow registration # Dynamically change the callback server.set_callback(listener_id, new_callback) # To demonstrate, you would need to send Art-Net data to trigger the callbacks. # For example, after sending data, the 'New callback executed.' message would appear. # You can also get the buffer manually # buffer = server.get_buffer(listener_id) # if buffer: # print(f"Retrieved buffer: {buffer}") time.sleep(5) del server ``` ### Response - **buffer** (bytearray) - The DMX data retrieved by `get_buffer()`. - No direct return value for `set_callback()`, but the listener's behavior changes. ``` -------------------------------- ### StupidArtnetServer - Receive Art-Net Data Source: https://context7.com/cpvalente/stupidartnet/llms.txt Implement a server to listen for incoming Art-Net packets on a specified universe. Register callback functions to process received DMX data dynamically. ```APIDOC ## StupidArtnetServer ### Description The `StupidArtnetServer` class creates a server that listens for incoming Art-Net packets. Register listeners for specific universes with optional callback functions to process received DMX data. ### Method `StupidArtnetServer()`: Initializes the server. `register_listener(universe, callback_function, sub=0, net=0, is_simplified=True)`: Registers a listener for a specific universe. `get_buffer(listener_id)`: Retrieves the DMX data buffer for a given listener. `delete_listener(listener_id)`: Removes a specific listener. `delete_all_listener()`: Removes all registered listeners. ### Parameters - **universe** (int) - The universe address to listen on. - **callback_function** (function) - A function to be called when DMX data is received. It can optionally accept the universe address as a second parameter. - **sub** (int) - The subnet address (default 0). - **net** (int) - The net address (default 0). - **is_simplified** (bool) - `True` for simplified addressing, `False` for full Art-Net 4 addressing. - **listener_id** (int) - The unique identifier of a listener. ### Request Example ```python from stupidArtnet import StupidArtnetServer import time # Callback function receives DMX data as array def on_dmx_received(data): print(f'Received {len(data)} channels') print(f'Channel 1: {data[0]}') print(f'Channel 2: {data[1]}') # Create server (listens on default port 6454) server = StupidArtnetServer() # Register listener for universe 0 with callback listener_id = server.register_listener( universe=0, callback_function=on_dmx_received ) print(server) # Output: # =================================== # Stupid Artnet Listening # =================================== # Let server run for 10 seconds time.sleep(10) # Cleanup del server ``` ### Response - **listener_id** (int) - The ID of the newly registered listener. - **buffer** (bytearray) - The DMX data buffer retrieved by `get_buffer()`. ### Error Handling - Errors may occur if the server cannot bind to the port or if invalid parameters are provided to `register_listener`. ``` -------------------------------- ### Set RGB Color Values for Fixtures Source: https://context7.com/cpvalente/stupidartnet/llms.txt Use `set_rgb()` to set three consecutive DMX channels for RGB fixtures. Values are automatically clamped between 0 and 255. Call `show()` after setting values to transmit them. ```python from stupidArtnet import StupidArtnet import time artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Set RGB fixture starting at channel 1 # Channels 1=Red, 2=Green, 3=Blue artnet.set_rgb(1, 255, 0, 0) # Pure red artnet.show() # Set another RGB fixture starting at channel 4 artnet.set_rgb(4, 0, 255, 128) # Cyan-ish artnet.show() # Create a color sweep effect for r in range(0, 256, 5): artnet.set_rgb(1, r, 255 - r, 128) artnet.show() time.sleep(0.05) del artnet ``` -------------------------------- ### DMX Buffer Management Source: https://context7.com/cpvalente/stupidartnet/llms.txt Methods for loading and transmitting DMX data buffers. ```APIDOC ## set() and show() ### Description `set()` loads a bytearray into the client buffer, and `show()` transmits the buffer to the device. `send()` performs both actions in one call. ### Parameters #### Request Body - **packet** (bytearray) - Required - DMX data buffer. ``` -------------------------------- ### DMX Channel Control Source: https://context7.com/cpvalente/stupidartnet/llms.txt Methods for setting individual channels, RGB values, and 16-bit data. ```APIDOC ## set_single_value(channel, value) ### Description Sets a single DMX channel (1-512) to a value (0-255). ## set_rgb(channel, r, g, b) ### Description Sets three consecutive DMX channels starting at the specified address for RGB fixtures. ## set_16bit(channel, value, high_first=False) ### Description Sets a 16-bit value across two consecutive DMX channels. Supports little-endian (default) or big-endian (high_first=True) byte order. ``` -------------------------------- ### Set 16-bit DMX Value Source: https://context7.com/cpvalente/stupidartnet/llms.txt The `set_16bit()` method sets a 16-bit value across two DMX channels. It supports both little-endian (default) and big-endian byte orders, useful for high-resolution controls. ```python from stupidArtnet import StupidArtnet artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Set 16-bit value starting at channel 1 # Default is low byte first (little-endian) artnet.set_16bit(1, 32768) # Mid-range value (0-65535) # Set 16-bit value with high byte first (big-endian) # Some fixtures require this byte order artnet.set_16bit(3, 65535, high_first=True) # Maximum value artnet.show() del artnet ``` -------------------------------- ### Set Individual DMX Channel Value Source: https://context7.com/cpvalente/stupidartnet/llms.txt The `set_single_value()` method allows updating a single DMX channel. Channel addresses are 1-based, ranging from 1 to 512. Remember to call `show()` to send the updated buffer. ```python from stupidArtnet import StupidArtnet artnet = StupidArtnet('192.168.1.100', universe=0, packet_size=512) # Set channel 1 to full brightness (255) artnet.set_single_value(1, 255) # Set channel 10 to 50% brightness (128) artnet.set_single_value(10, 128) # Set channel 100 to off (0) artnet.set_single_value(100, 0) # Send the updated buffer artnet.show() del artnet ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.