dmx

package
v0.2.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dmx provides DMX output management and Art-Net communication.

Index

Constants

View Source
const (
	// UniverseSize is the number of channels per DMX universe.
	UniverseSize = 512
	// MaxUniverses is the maximum number of supported universes.
	MaxUniverses = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled          bool
	BroadcastAddr    string
	Port             int
	RefreshRateHz    int
	IdleRateHz       int
	HighRateDuration time.Duration
}

Config holds DMX service configuration.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv loads configuration from environment variables.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a configuration with default values.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service manages DMX channel values and Art-Net output.

func NewService

func NewService(cfg Config) *Service

NewService creates a new DMX service.

func (*Service) ClearActiveScene

func (s *Service) ClearActiveScene()

ClearActiveScene clears the active scene.

func (*Service) ClearAllOverrides

func (s *Service) ClearAllOverrides()

ClearAllOverrides removes all channel overrides.

func (*Service) ClearChannelOverride

func (s *Service) ClearChannelOverride(universe, channel int)

ClearChannelOverride removes a channel override.

func (*Service) CountActiveChannels

func (s *Service) CountActiveChannels() int

CountActiveChannels returns the number of non-zero channels.

func (*Service) DisableArtNet

func (s *Service) DisableArtNet()

DisableArtNet disables Art-Net output and closes the connection.

func (*Service) FadeToBlack

func (s *Service) FadeToBlack()

FadeToBlack sets all channels to 0 (immediate, no fade).

func (*Service) ForceImmediateTransmission added in v0.2.10

func (s *Service) ForceImmediateTransmission()

ForceImmediateTransmission forces an immediate Art-Net transmission. This is used when we need to ensure the first frame of a fade is sent immediately without waiting for the next transmitLoop tick.

func (*Service) GetActiveSceneID

func (s *Service) GetActiveSceneID() *string

GetActiveSceneID returns the currently active scene ID.

func (*Service) GetAllUniverses

func (s *Service) GetAllUniverses() map[int][]int

GetAllUniverses returns all universes with channel values (1-indexed).

func (*Service) GetBroadcastAddress

func (s *Service) GetBroadcastAddress() string

GetBroadcastAddress returns the Art-Net broadcast address.

func (*Service) GetChannelValue

func (s *Service) GetChannelValue(universe, channel int) byte

GetChannelValue returns the current value of a channel.

func (*Service) GetCurrentRate

func (s *Service) GetCurrentRate() int

GetCurrentRate returns the current transmission rate in Hz.

func (*Service) GetUniverse

func (s *Service) GetUniverse(universe int) []int

GetUniverse returns all channel values for a universe (as ints for API compatibility).

func (*Service) Initialize

func (s *Service) Initialize() error

Initialize starts the DMX service and Art-Net transmission.

func (*Service) IsActive

func (s *Service) IsActive() bool

IsActive returns whether DMX output is currently active.

func (*Service) IsEnabled

func (s *Service) IsEnabled() bool

IsEnabled returns whether DMX output is enabled.

func (*Service) ReloadBroadcastAddress

func (s *Service) ReloadBroadcastAddress(newAddress string) error

ReloadBroadcastAddress updates the broadcast address and reconnects. If Art-Net was disabled, this will enable it.

func (*Service) SetActiveScene

func (s *Service) SetActiveScene(sceneID string)

SetActiveScene sets the currently active scene ID.

func (*Service) SetAllChannels

func (s *Service) SetAllChannels(universe int, values []byte)

SetAllChannels sets all channels in a universe.

func (*Service) SetChannelOverride

func (s *Service) SetChannelOverride(universe, channel int, value byte)

SetChannelOverride sets a channel override value.

func (*Service) SetChannelValue

func (s *Service) SetChannelValue(universe, channel int, value byte)

SetChannelValue sets a channel value.

func (*Service) Stop

func (s *Service) Stop()

Stop stops the DMX service and closes the socket.

func (*Service) TriggerChangeDetection

func (s *Service) TriggerChangeDetection()

TriggerChangeDetection manually triggers high-rate mode (useful for fades). This switches to high-rate transmission mode but lets the transmitLoop handle actual packet sending to avoid race conditions and duplicate transmissions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL