### Create Wider ArtNet Channels (16-bit) Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Illustrates how to create channels with a width greater than 8 bits, specifically a 16-bit channel, using the `byte_size` parameter in `add_channel`. Requires node and universe setup. ```python # hide: start from helper import MockedSocket MockedSocket().mock() import pyartnet.base.network as network_module from ipaddress import IPv4Address async def resolve_hostname(*args, **kwargs): return [IPv4Address('127.0.0.1')] network_module.resolve_hostname = resolve_hostname import asyncio from pyartnet import ArtNetNode async def main(): # hide: stop # create node/universe async with ArtNetNode.create('IP', 6454) as node: universe = node.add_universe(0) # create a 16bit channel channel = universe.add_channel(start=1, width=3, byte_size=2) # hide: start asyncio.run(main()) # hide: stop ``` -------------------------------- ### Access ArtNet Channels by Index or Name Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Shows how to access channels within a universe using either their default name (start/width) or a custom name assigned during creation. Requires node and universe setup. ```python # hide: start from helper import MockedSocket MockedSocket().mock() import pyartnet.base.network as network_module from ipaddress import IPv4Address async def resolve_hostname(*args, **kwargs): return [IPv4Address('127.0.0.1')] network_module.resolve_hostname = resolve_hostname import asyncio from pyartnet import ArtNetNode async def main(): # hide: stop # create node/universe async with ArtNetNode.create('IP', 6454) as node: universe = node.add_universe(0) # create the channel channel = universe.add_channel(start=1, width=3) # after creation this would also work (default name) channel = universe['1/3'] channel = universe.get_channel('1/3') # it's possible to name the channel during creation universe.add_channel(start=4, width=3, channel_name='Dimmer1') # access is then by name channel = universe['Dimmer1'] channel = universe.get_channel('Dimmer1') # hide: start asyncio.run(main()) # hide: stop ``` -------------------------------- ### Synchronous Mode for Art-Net and sACN Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Enables synchronized transmission for Art-Net and sACN to prevent visual tearing in large LED installations. For Art-Net, `refresh_every` can be set to control sync frequency. For sACN, a specific `synchronization_address` can be provided. ```python import asyncio from pyartnet import ArtNetNode, SacnNode async def artnet_sync_example(): # Art-Net synchronization async with ArtNetNode.create('192.168.1.100', refresh_every=2) as node: # Enable sync mode - sends ArtSync packet after data node.set_synchronous_mode(True) # Create multiple universes for a large LED panel universes = [node.add_universe(i) for i in range(4)] channels = [u.add_channel(start=1, width=170) for u in universes] # All universes update together without tearing for ch in channels: ch.set_fade([255] * 170, 1000) await node async def sacn_sync_example(): # sACN synchronization with specific sync address async with SacnNode.create('192.168.1.50') as node: # Enable sync mode with synchronization universe address node.set_synchronous_mode(True, synchronization_address=100) universe1 = node.add_universe(1) universe2 = node.add_universe(2) ch1 = universe1.add_channel(start=1, width=512) ch2 = universe2.add_channel(start=1, width=512) # Synchronized update across universes ch1.set_fade([128] * 512, 2000) ch2.set_fade([128] * 512, 2000) await node # Disable sync mode node.set_synchronous_mode(False) asyncio.run(artnet_sync_example()) ``` -------------------------------- ### Create and Configure ArtNet Node Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Demonstrates creating an ArtNet node, adding a universe, and a channel with a fade. Ensure asyncio is imported and the main function is run. ```python # hide: start from helper import MockedSocket MockedSocket().mock() import pyartnet.base.network as network_module from ipaddress import IPv4Address async def resolve_hostname(*args, **kwargs): return [IPv4Address('127.0.0.1')] network_module.resolve_hostname = resolve_hostname # hide: stop import asyncio from pyartnet import ArtNetNode async def main(): async with ArtNetNode.create('IP', 6454) as node: # Create universe 0 universe = node.add_universe(0) # Add a channel to the universe which consists of 3 values # Default size of a value is 8Bit (0..255) so this would fill # the DMX values 1..3 of the universe channel = universe.add_channel(start=1, width=3) # Fade channel to 255,0,0 in 5s # The fade will automatically run in the background channel.add_fade([255,0,0], 1000) # this can be used to wait till the fade is complete await channel # hide: start node.stop_refresh() # hide: stop asyncio.run(main()) ``` -------------------------------- ### Initialize ArtNetNode with Async Context Manager Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/readme.md Use the async context manager to properly initialize and manage the lifecycle of an ArtNetNode. ```python async with ArtNetNode.create('IP') as node: ... ``` -------------------------------- ### Configure ArtNet Node and Output Correction Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Demonstrates creating an ArtNet node, adding universes and channels, and applying different output correction strategies. ```python async def resolve_hostname(*args, **kwargs): return [IPv4Address('127.0.0.1')] network_module.resolve_hostname = resolve_hostname import asyncio async def main(): # hide: stop from pyartnet import ArtNetNode, output_correction # create node/universe/channel async with ArtNetNode.create('IP', 6454) as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # set quadratic correction for the whole universe to quadratic universe.set_output_correction(output_correction.quadratic) # Explicitly set output for this channel to linear channel.set_output_correction(output_correction.linear) # Remove output correction for the channel. # The channel will now use the correction from the universe again channel.set_output_correction(None) # hide: start asyncio.run(main()) # hide: stop ``` -------------------------------- ### Create an Art-Net Node Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Initializes a unicast Art-Net node on port 6454. Must be used as an async context manager to handle network resources. ```python import asyncio from pyartnet import ArtNetNode async def main(): # Create an Art-Net node connecting to a lighting controller async with ArtNetNode.create('192.168.1.100', 6454, max_fps=30) as node: # Add universe 0 universe = node.add_universe(0) # Create a 3-channel RGB fixture starting at DMX address 1 channel = universe.add_channel(start=1, width=3) # Set to red color channel.set_fade([255, 0, 0], 1000) await channel # Wait for fade to complete # Fade to blue over 2 seconds channel.set_fade([0, 0, 255], 2000) await channel asyncio.run(main()) ``` -------------------------------- ### Create a KiNet Node Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Initializes a KiNet node for Philips Color Kinetics devices on port 6038. ```python import asyncio from pyartnet import KiNetNode async def main(): # Create a KiNet node async with KiNetNode.create('192.168.1.75', 6038, max_fps=25) as node: universe = node.add_universe(0) # Add channel for Color Kinetics fixture fixture = universe.add_channel(start=1, width=3) # Animate through colors colors = [[255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 255]] for color in colors: fixture.set_fade(color, 500) await fixture asyncio.run(main()) ``` -------------------------------- ### Node Implementations Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Information on different node implementations available in PyARTNET. ```APIDOC ## Node Implementations ### Description PyARTNET supports various network protocols for DMX control. ### Classes - `ArtNetNode`: For Art-Net protocol. - `KiNetNode`: For KiNet protocol. - `SacnNode`: For sACN protocol. ### Base Class All node implementations inherit from a base class providing common functionality. ``` -------------------------------- ### Handle PyArtNet Exceptions Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Demonstrates catching specific errors like ChannelOutOfUniverseError, OverlappingChannelError, and ChannelValueOutOfBoundsError during node configuration. ```python import asyncio from pyartnet import ArtNetNode from pyartnet.errors import ( PyArtNetError, ChannelOutOfUniverseError, OverlappingChannelError, ChannelValueOutOfBoundsError, InvalidUniverseAddressError, ChannelNotFoundError, ) async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) # Error: Channel start position out of bounds (1-512) try: universe.add_channel(start=0, width=3) except ChannelOutOfUniverseError as e: print(f"Invalid channel position: {e}") # Error: Channel extends beyond universe (512 max) try: universe.add_channel(start=510, width=10) except ChannelOutOfUniverseError as e: print(f"Channel exceeds universe: {e}") # Create valid channel first universe.add_channel(start=1, width=10, channel_name='fixture1') # Error: Overlapping channels try: universe.add_channel(start=5, width=3) except OverlappingChannelError as e: print(f"Channels overlap: {e}") # Error: Channel not found try: universe.get_channel('nonexistent') except ChannelNotFoundError as e: print(f"Channel not found: {e}") # Error: Value out of bounds for 8-bit channel channel = universe.add_channel(start=20, width=3) try: channel.set_values([256, 0, 0]) # 256 exceeds 8-bit max (255) except ChannelValueOutOfBoundsError as e: print(f"Value out of range: {e}") # Catch-all for any PyArtNet error try: node.add_universe(-1) except PyArtNetError as e: print(f"PyArtNet error: {e}") asyncio.run(main()) ``` -------------------------------- ### Add DMX Channels to a Universe Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Demonstrates adding channels with different bit depths and accessing them by name or address. ```python import asyncio from pyartnet import ArtNetNode async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) # Standard 8-bit RGB channel (3 values, addresses 1-3) rgb_channel = universe.add_channel(start=1, width=3) # 16-bit dimmer for precise control (1 value, addresses 4-5) dimmer_16bit = universe.add_channel(start=4, width=1, byte_size=2) # Named channel for easy access later universe.add_channel(start=6, width=3, channel_name='Spotlight1') # Access channel by name spotlight = universe['Spotlight1'] # Or by default name (start/width) rgb = universe['1/3'] # 16-bit values: 0-65535 range dimmer_16bit.set_values([32768]) # ~50% brightness # RGB values: 0-255 range rgb_channel.set_fade([255, 128, 64], 1000) await rgb_channel asyncio.run(main()) ``` -------------------------------- ### Set Output Correction Levels Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Demonstrates setting output correction at node, universe, and channel levels. Node-level settings apply globally, while universe and channel settings can override them. Use `None` to remove channel-specific correction and inherit from the parent. ```python import asyncio from pyartnet import ArtNetNode, output_correction async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) # Set output correction at different levels # Node level - applies to all universes/channels by default node.set_output_correction(output_correction.quadratic) # Universe level - overrides node setting for this universe universe.set_output_correction(output_correction.cubic) channel1 = universe.add_channel(start=1, width=3) channel2 = universe.add_channel(start=4, width=3) # Channel level - overrides universe setting for this channel channel1.set_output_correction(output_correction.linear) # channel2 inherits cubic from universe # Remove channel-specific correction (inherits from universe again) channel1.set_output_correction(None) # Available corrections: # - output_correction.linear (default, no change) # - output_correction.quadratic (smoother low-end) # - output_correction.cubic (even smoother) # - output_correction.quadruple (most aggressive curve) # Demonstrate the difference channel1.set_output_correction(output_correction.linear) channel2.set_output_correction(output_correction.quadratic) # Both fade 0->255, but quadratic will appear smoother channel1.set_fade([255, 255, 255], 3000) channel2.set_fade([255, 255, 255], 3000) await node asyncio.run(main()) ``` -------------------------------- ### Universe and Channel Management Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Details on how to manage universes and channels within an Art-Net node, including setting output corrections. ```APIDOC ## Universe and Channel Management ### Description Manages DMX universes and individual channels, including configuration of output correction. ### Classes - `BaseUniverse`: Base class for universes. - `Channel`: Represents a single DMX channel or a group of channels. ### Methods - `BaseUniverse.set_output_correction(correction_type)`: Sets the output correction for the entire universe. - `Channel.set_output_correction(correction_type)`: Sets the output correction for a specific channel. ### Output Correction Types - `pyartnet.output_correction.quadratic`: Quadratic output correction. - `pyartnet.output_correction.linear`: Linear output correction. - `None`: Removes output correction, reverting to the universe's setting. ### Example Usage ```python from pyartnet import ArtNetNode, output_correction async with ArtNetNode.create('IP', 6454) as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # Set quadratic correction for the whole universe universe.set_output_correction(output_correction.quadratic) # Explicitly set output for this channel to linear channel.set_output_correction(output_correction.linear) # Remove output correction for the channel (uses universe's setting) channel.set_output_correction(None) ``` ``` -------------------------------- ### Schedule Fade Transitions Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Schedules smooth transitions between values. Fades run in the background and can be awaited. ```python import asyncio from pyartnet import ArtNetNode from pyartnet.fades import LinearFade async def main(): async with ArtNetNode.create('192.168.1.100', max_fps=40) as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # Simple fade to red over 2 seconds channel.set_fade([255, 0, 0], 2000) await channel # Wait for completion # Fade to green over 1.5 seconds channel.set_fade([0, 255, 0], 1500) await channel # Multiple sequential fades sequence = [ ([255, 0, 0], 500), # Red ([255, 255, 0], 500), # Yellow ([0, 255, 0], 500), # Green ([0, 255, 255], 500), # Cyan ([0, 0, 255], 500), # Blue ([255, 0, 255], 500), # Magenta ] for color, duration in sequence: channel.set_fade(color, duration) await channel asyncio.run(main()) ``` -------------------------------- ### Fades Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Details on fade implementations for smooth transitions. ```APIDOC ## Fades ### Description Provides classes for implementing fades, allowing for smooth changes in DMX values. ### Class - `pyartnet.fades.LinearFade`: Implements a linear fade. ``` -------------------------------- ### Create a Multicast sACN Node Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Initializes a sACN node using multicast addressing to broadcast data to multiple receivers simultaneously. ```python import asyncio from pyartnet import SacnNode async def main(): # Create a sACN node using multicast # The source_ip must be a valid interface on your machine async with SacnNode.create_multicast('192.168.1.10', max_fps=30) as node: # Add multiple universes - each broadcasts to its multicast address # Universe 1 -> 239.255.0.1, Universe 2 -> 239.255.0.2, etc. universe1 = node.add_universe(1) universe2 = node.add_universe(2) # Create channels on each universe ch1 = universe1.add_channel(start=1, width=3) ch2 = universe2.add_channel(start=1, width=3) # Control both simultaneously ch1.set_fade([255, 0, 0], 1000) ch2.set_fade([0, 255, 0], 1000) await node # Wait for all fades on all universes asyncio.run(main()) ``` -------------------------------- ### Set Immediate Channel Values Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Updates channel values instantly without interpolation. Useful for strobing or direct control. ```python import asyncio from pyartnet import ArtNetNode async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # Instant color change (no fade) channel.set_values([255, 0, 0]) # Immediate red await asyncio.sleep(1) channel.set_values([0, 255, 0]) # Immediate green await asyncio.sleep(1) # Get current values current = channel.get_values() print(f"Current values: {current}") # Output: Current values: [0, 255, 0] # Strobe effect using set_values for _ in range(10): channel.set_values([255, 255, 255]) await asyncio.sleep(0.05) channel.set_values([0, 0, 0]) await asyncio.sleep(0.05) asyncio.run(main()) ``` -------------------------------- ### Create a sACN Node Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Initializes a unicast sACN node on port 5568. Supports universe numbers from 1 to 63999. ```python import asyncio from pyartnet import SacnNode async def main(): # Create a sACN node for unicast transmission async with SacnNode.create('192.168.1.50', 5568, max_fps=25) as node: # sACN universes start at 1 (not 0) universe = node.add_universe(1) # Add an RGBW fixture (4 channels) rgbw = universe.add_channel(start=1, width=4, channel_name='LED_Strip') # Fade to warm white rgbw.set_fade([255, 180, 100, 128], 1500) await rgbw asyncio.run(main()) ``` -------------------------------- ### Channel.set_fade Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Schedules a smooth fade transition to target values over a specified duration. The fade runs automatically in the background and can be awaited. Supports custom fade classes for non-linear transitions. ```APIDOC ## Channel.set_fade ### Description Schedules a smooth fade transition to target values over a specified duration. The fade runs automatically in the background and can be awaited. Supports custom fade classes for non-linear transitions. ### Method Not applicable (this is a method call within a Python script) ### Endpoint Not applicable (this is a method call within a Python script) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import asyncio from pyartnet import ArtNetNode from pyartnet.fades import LinearFade async def main(): async with ArtNetNode.create('192.168.1.100', max_fps=40) as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # Simple fade to red over 2 seconds channel.set_fade([255, 0, 0], 2000) await channel # Wait for completion # Fade to green over 1.5 seconds channel.set_fade([0, 255, 0], 1500) await channel # Multiple sequential fades sequence = [ ([255, 0, 0], 500), # Red ([255, 255, 0], 500), # Yellow ([0, 255, 0], 500), # Green ([0, 255, 255], 500), # Cyan ([0, 0, 255], 500), # Blue ([255, 0, 255], 500), # Magenta ] for color, duration in sequence: channel.set_fade(color, duration) await channel asyncio.run(main()) ``` ### Response #### Success Response (200) This method does not return a value directly but schedules a fade operation. #### Response Example None ``` -------------------------------- ### Output Corrections Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Lists the available output correction methods. ```APIDOC ## Available Output Corrections ### Description Defines various methods for correcting DMX output values. ### Module `pyartnet.output_correction` ### Members - `quadratic`: Quadratic output correction. - `linear`: Linear output correction. ``` -------------------------------- ### ArtNetNode Class Source: https://github.com/spacemanspiff2007/pyartnet/blob/master/docs/pyartnet.rst Represents an Art-Net node, allowing for the creation and management of universes and channels. ```APIDOC ## ArtNetNode Class ### Description Represents an Art-Net node. This class is used to create and manage network connections for sending DMX data. ### Class `ArtNetNode` ### Methods - `create(ip_address: str, port: int)`: Asynchronously creates an ArtNetNode instance. - `add_universe(id: int)`: Adds a new universe to the node. ### Example Usage ```python from pyartnet import ArtNetNode async with ArtNetNode.create('IP', 6454) as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # ... further operations ... ``` ``` -------------------------------- ### Channel.set_values Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Sets channel values immediately without a fade transition. Useful for instant changes or when implementing custom fade logic. ```APIDOC ## Channel.set_values ### Description Sets channel values immediately without a fade transition. Useful for instant changes or when implementing custom fade logic. ### Method Not applicable (this is a method call within a Python script) ### Endpoint Not applicable (this is a method call within a Python script) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import asyncio from pyartnet import ArtNetNode async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) # Instant color change (no fade) channel.set_values([255, 0, 0]) # Immediate red await asyncio.sleep(1) channel.set_values([0, 255, 0]) # Immediate green await asyncio.sleep(1) # Get current values current = channel.get_values() print(f"Current values: {current}") # Output: Current values: [0, 255, 0] # Strobe effect using set_values for _ in range(10): channel.set_values([255, 255, 255]) await asyncio.sleep(0.05) channel.set_values([0, 0, 0]) await asyncio.sleep(0.05) asyncio.run(main()) ``` ### Response #### Success Response (200) This method does not return a value directly but updates the channel's state. #### Response Example None ``` -------------------------------- ### BaseUniverse.add_channel Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Adds a new DMX channel or channel group to a universe. Supports various bit depths (8, 16, 24, 32-bit) for high-resolution fixtures. The channel automatically handles byte ordering for multi-byte values. ```APIDOC ## BaseUniverse.add_channel ### Description Adds a new DMX channel or channel group to a universe. Supports various bit depths (8, 16, 24, 32-bit) for high-resolution fixtures. The channel automatically handles byte ordering for multi-byte values. ### Method Not applicable (this is a method call within a Python script) ### Endpoint Not applicable (this is a method call within a Python script) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import asyncio from pyartnet import ArtNetNode async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) # Standard 8-bit RGB channel (3 values, addresses 1-3) rgb_channel = universe.add_channel(start=1, width=3) # 16-bit dimmer for precise control (1 value, addresses 4-5) dimmer_16bit = universe.add_channel(start=4, width=1, byte_size=2) # Named channel for easy access later universe.add_channel(start=6, width=3, channel_name='Spotlight1') # Access channel by name spotlight = universe['Spotlight1'] # Or by default name (start/width) rgb = universe['1/3'] # 16-bit values: 0-65535 range dimmer_16bit.set_values([32768]) # ~50% brightness # RGB values: 0-255 range rgb_channel.set_fade([255, 128, 64], 1000) await rgb_channel asyncio.run(main()) ``` ### Response #### Success Response (200) This method does not return a value directly but modifies the universe object. #### Response Example None ``` -------------------------------- ### Callback on Fade Complete Source: https://context7.com/spacemanspiff2007/pyartnet/llms.txt Registers a callback function to be executed when a channel's fade operation finishes. This is useful for chaining effects or triggering subsequent actions. The callback receives the `Channel` object as an argument. ```python import asyncio from pyartnet import ArtNetNode, Channel async def main(): async with ArtNetNode.create('192.168.1.100') as node: universe = node.add_universe(0) channel = universe.add_channel(start=1, width=3) fade_count = 0 def on_fade_complete(ch: Channel): nonlocal fade_count fade_count += 1 print(f"Fade #{fade_count} completed! Values: {ch.get_values()}") # Register callback channel.callback_fade_finished = on_fade_complete # Each fade completion will trigger the callback channel.set_fade([255, 0, 0], 500) await channel # Output: Fade #1 completed! Values: [255, 0, 0] channel.set_fade([0, 255, 0], 500) await channel # Output: Fade #2 completed! Values: [0, 255, 0] channel.set_fade([0, 0, 255], 500) await channel # Output: Fade #3 completed! Values: [0, 0, 255] asyncio.run(main()) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.