common

package
v0.0.0-...-f5beb5c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Actions int = iota
	Clear
	Reset
	UpdateStatic
	UpdateFlashAllStaticColorButtons
	UpdateBounce
	UpdateAllStaticColor
	UpdateStaticColor
	UpdateASingeSequenceColor
	UpdateSequenceColors
	PlayStaticOnce
	PlaySwitchOnce
	Reveal
	Hide
	Start
	StartChase
	Stop
	StopChase
	ReadConfig
	LoadConfig
	UpdateSpeed
	UpdatePattern
	UpdateRGBFadeSpeed
	UpdateRGBSize
	UpdateScannerSize
	Blackout
	Normal
	UpdateColor
	UpdateFunctions
	GetUpdatedSequence
	ResetAllSwitchPositions
	UpdateSwitch
	Inverted
	UpdateGobo
	Flood
	StopFlood
	Strobe
	StopStrobe
	UpdateAutoColor
	UpdateAutoPattern
	ToggleFixtureState
	UpdateRGBShift
	UpdateRGBInvert
	UpdateScannerShift
	UpdateScannerColor
	UpdateStrobeSpeed
	ClearSequenceColor
	ClearStaticColor
	SetStaticColorBar
	Static
	Master
	UpdateNumberCoordinates
	UpdateOffsetPan
	UpdateOffsetTilt
	UpdateScannerChase
	UpdateMusicTrigger
	UpdateScannerHasShutterChase
)

Valid Command Actions.

View Source
const (
	Function1_Pattern       = 0 // Set pattern mode.
	Function2_Auto_Color    = 1 // Auto Color change.
	Function3_Auto_Pattern  = 2 // Auto Pattern change
	Function4_Bounce        = 3 // Sequence auto reverses.  doesn't apply in scanner mode.
	Function5_Color         = 4 // Set RGB chase color. or select the scanner color.
	Function6_Static_Gobo   = 5 // Set static color / set scanner gobo.
	Function7_Invert_Chase  = 6 // Invert the RGB colors  / Set scanner chase mode.
	Function8_Music_Trigger = 7 // Music trigger on and off. Both RGB and scanners.
)

Define the function keys.

View Source
const CENTER_DMX_BRIGHTNESS = 127
View Source
const DEFAULT_PATTERN = 0
View Source
const DEFAULT_RGB_FADE = 1
View Source
const DEFAULT_RGB_FADE_STEPS = 10
View Source
const DEFAULT_RGB_SHIFT = 0
View Source
const DEFAULT_RGB_SIZE = 0
View Source
const DEFAULT_SCANNER_COLOR = 1
View Source
const DEFAULT_SCANNER_COORDNIATES = 0
View Source
const DEFAULT_SCANNER_FADE = 10
View Source
const DEFAULT_SCANNER_GOBO = 1
View Source
const DEFAULT_SCANNER_SHIFT = 0
View Source
const DEFAULT_SCANNER_SIZE = 60
View Source
const DEFAULT_SPEED = 7
View Source
const DEFAULT_STROBE_SPEED = 255
View Source
const IS_RGB = false
View Source
const IS_SCANNER = true
View Source
const MAX_COLOR_BAR = 9 // Eight colors and a default color bar.
View Source
const MAX_DMX_ADDRESS = 512
View Source
const MAX_DMX_BRIGHTNESS = 255
View Source
const MAX_NUMBER_OF_CHANNELS = 8
View Source
const MAX_RGB_FADE = 10
View Source
const MAX_RGB_SHIFT = 10
View Source
const MAX_RGB_SIZE = 10
View Source
const MAX_SCANNER_SHIFT = 3
View Source
const MAX_SCANNER_SIZE = 127
View Source
const MAX_SPEED = 12
View Source
const MAX_TEXT_ENTRY_LENGTH = 35
View Source
const MIN_DMX_BRIGHTNESS = 0
View Source
const MIN_RGB_SHIFT = 1
View Source
const MIN_RGB_SIZE = 0
View Source
const MIN_SCANNER_SHIFT = 0
View Source
const MIN_SPEED = 0
View Source
const SCANNER_MID_POINT = 127
View Source
const StepSize = 39

A full step cycle is 39 ticks ie 39 values. 13 fade up values, 13 on values and 13 off values.

Variables

View Source
var Aqua = Color{R: 127, G: 255, B: 212}
View Source
var BLACKOUT_BUTTON = Button{X: 8, Y: 7}
View Source
var BLUE_BUTTON = Button{X: 3, Y: -1}
View Source
var Black = Color{R: 0, G: 0, B: 0}
View Source
var Blue = Color{R: 0, G: 0, B: 255}
View Source
var Crimson = Color{R: 220, G: 20, B: 60}
View Source
var Cyan = Color{R: 0, G: 255, B: 255}
View Source
var DarkOrange = Color{R: 215, G: 50, B: 0}
View Source
var DarkPurple = Color{R: 50, G: 0, B: 255}
View Source
var DefaultSequenceColors = []Color{{R: 0, G: 255, B: 0}}
View Source
var EmptyColor = Color{}
View Source
var FLOOD_BUTTON = Button{X: 8, Y: 3}
View Source
var ForestGreen = Color{R: 0, G: 100, B: 0}
View Source
var GREEN_BUTTON = Button{X: 2, Y: -1}
View Source
var GlobalScannerSequenceNumber int
View Source
var Gold = Color{R: 255, G: 215, B: 0}
View Source
var Green = Color{R: 0, G: 255, B: 0}
View Source
var LawnGreen = Color{R: 124, G: 252, B: 0}
View Source
var LightBlue = Color{R: 100, G: 185, B: 255}
View Source
var LightOrange = Color{R: 255, G: 175, B: 0}
View Source
var Magenta = Color{R: 255, G: 0, B: 255}
View Source
var Olive = Color{R: 150, G: 150, B: 0}
View Source
var Orange = Color{R: 255, G: 111, B: 0}
View Source
var Pink = Color{R: 255, G: 192, B: 203}
View Source
var PresetYellow = Color{R: 150, G: 150, B: 0}
View Source
var Purple = Color{R: 100, G: 0, B: 255}
View Source
var QuarterBlue = Color{R: 0, G: 0, B: 50}
View Source
var QuarterGreen = Color{R: 0, G: 50, B: 0}
View Source
var QuarterRed = Color{R: 50, G: 0, B: 0}
View Source
var QuarterYellow = Color{R: 50, G: 50, B: 0}
View Source
var RED_BUTTON = Button{X: 1, Y: -1}
View Source
var RUNNING_BUTTON = Button{X: 8, Y: 5}
View Source
var Red = Color{R: 255, G: 0, B: 0}
View Source
var SAVE_BUTTON = Button{X: 8, Y: 4}
View Source
var STROBE_BUTTON = Button{X: 8, Y: 6}
View Source
var Salmon = Color{R: 250, G: 128, B: 114}
View Source
var SkyBlue = Color{R: 0, G: 191, B: 255}
View Source
var Teal = Color{R: 0, G: 128, B: 128}
View Source
var Violet = Color{R: 199, G: 21, B: 133}
View Source
var White = Color{R: 255, G: 255, B: 255}
View Source
var Yellow = Color{R: 255, G: 255, B: 0}

Functions

func CalculateFadeValues

func CalculateFadeValues(sequence *Sequence)

CalculateFadeValues - calculate fade curve values.

func ClearLabelsSelectedRowOfButtons

func ClearLabelsSelectedRowOfButtons(selectedSequence int, guiButtons chan ALight)

func ClearSelectedRowOfButtons

func ClearSelectedRowOfButtons(selectedSequence int, eventsForLauchpad chan ALight, guiButtons chan ALight)

func ConvertRGBtoNRGBA

func ConvertRGBtoNRGBA(alight Color) color.NRGBA

Convert my common.Color RGB into color.NRGBA used by the fyne.io GUI library.

func FindSensitivity

func FindSensitivity(soundGain float32) int

func FlashLight

func FlashLight(button Button, onColor Color, offColor Color, eventsForLauchpad chan ALight, guiButtons chan ALight)

func FormatLabel

func FormatLabel(label string) string

func GetColorNameByRGB

func GetColorNameByRGB(color Color) string

func GetFadeOnValues

func GetFadeOnValues(size int, fade int) []int

func GetFadeValues

func GetFadeValues(noCoordinates int, size float64, fade int, reverse bool) (out []int)

func GetIDfromCoordinates

func GetIDfromCoordinates(X int, Y int) int

func GetLaunchPadCodeByRGBColor

func GetLaunchPadCodeByRGBColor(selectedColor Color) byte

func HideAllSequences

func HideAllSequences(commandChannels []chan Command)

func HideSequence

func HideSequence(targetSequence int, commandChannels []chan Command)

func LabelButton

func LabelButton(X int, Y int, label string, guiButtons chan ALight)

func LightLamp

func LightLamp(button Button, color Color, master int, eventsForLauchpad chan ALight, guiButtons chan ALight)

LightOn Turn on a Light.

func RevealSequence

func RevealSequence(targetSequence int, commandChannels []chan Command)

func Reverse

func Reverse(in int) int

func Reverse12

func Reverse12(in int) int

func ReverseDmx

func ReverseDmx(n int) int

Takes a DMX value 1-255 and reverses the value.

func SendCommandToAllSequence

func SendCommandToAllSequence(command Command, commandChannels []chan Command)

func SendCommandToAllSequenceExcept

func SendCommandToAllSequenceExcept(targetSequence int, command Command, commandChannels []chan Command)

func SendCommandToAllSequenceOfType

func SendCommandToAllSequenceOfType(sequences []*Sequence, command Command, commandChannels []chan Command, Type string)

func SendCommandToSequence

func SendCommandToSequence(targetSequence int, command Command, commandChannels []chan Command)

func ShowBottomButtons

func ShowBottomButtons(tYpe string, eventsForLauchpad chan ALight, guiButtons chan ALight)

func ShowRunningStatus

func ShowRunningStatus(runningState bool, eventsForLaunchpad chan ALight, guiButtons chan ALight)

func ShowStaticButtons

func ShowStaticButtons(sequence *Sequence, staticFlashing bool, eventsForLaunchpad chan ALight, guiButtons chan ALight)

func ShowStrobeButtonStatus

func ShowStrobeButtonStatus(state bool, eventsForLaunchpad chan ALight, guiButtons chan ALight)

func ShowTopButtons

func ShowTopButtons(tYpe string, eventsForLauchpad chan ALight, guiButtons chan ALight)

func StartStaticSequences

func StartStaticSequences(sequences []*Sequence, commandChannels []chan Command)

func UpdateBottomButtons

func UpdateBottomButtons(selectedType string, guiButtons chan ALight)

func UpdateStatusBar

func UpdateStatusBar(status string, which string, hide bool, guiButtons chan ALight)

Types

type ALight

type ALight struct {
	Button           Button
	Brightness       int
	Red              int
	Green            int
	Blue             int
	Flash            bool
	OnColor          Color
	OffColor         Color
	UpdateLabel      bool
	Label            string
	UpdateStatus     bool
	Status           string
	Which            string
	FlashStopChannel chan bool
	Hidden           bool
}

type Action

type Action struct {
	Name        string
	Number      int
	Colors      []string
	Mode        string
	Fade        string
	Size        string
	Speed       string
	Rotate      string
	RotateSpeed string
	Music       string
	Program     string
	Strobe      string
}

type Arg

type Arg struct {
	Name  string
	Value interface{}
}

type Button

type Button struct {
	X int
	Y int
}

type ButtonPresets

type ButtonPresets struct {
	X int
	Y int
}

type Channels

type Channels struct {
	CommmandChannels []chan Command
	ReplyChannels    []chan Sequence
	UpdateChannels   []chan Sequence
	SoundTriggers    []*Trigger
}

type Color

type Color struct {
	R     int
	G     int
	B     int
	W     int
	A     int
	UV    int
	Flash bool
}

func GetColorArrayByNames

func GetColorArrayByNames(names []string) ([]Color, error)

func GetColorButtonsArray

func GetColorButtonsArray(color int) Color

Colors are selected from a pallete of 8 colors, this function takes 0-9 (repeating 4 time) and returns the color array

func GetRGBColorByName

func GetRGBColorByName(color string) (Color, error)

func HowManyColorsInPositions

func HowManyColorsInPositions(positionsMap map[int]Position) (colors []Color)

func HowManyColorsInSteps

func HowManyColorsInSteps(steps []Step) (colors []Color)

func HowManyScannerColors

func HowManyScannerColors(positionsMap map[int]Position) (colors []Color)

func HowManyStepColors

func HowManyStepColors(steps []Step) (colors []Color)

func InvertColor

func InvertColor(color Color) (out Color)

InvertColor just reverses the DMX values.

type ColorPicker

type ColorPicker struct {
	Name  string
	ID    int
	Code  byte // Launchpad hex code for this color
	Color Color
	X     int
	Y     int
}

func GetColor

func GetColor(X int, Y int) ColorPicker

type Command

type Command struct {
	Action int
	Args   []Arg
}

Command tells sequences what to do.

type Event

type Event struct {
	Fixture   int
	Run       bool
	Stop      bool
	Start     bool
	Fadeup    bool
	Fadedown  bool
	Shift     int
	FadeTime  time.Duration
	LastColor Color
	Color     Color
}

type Fixture

type Fixture struct {
	ID           string
	Number       int
	Name         string
	Label        string
	MasterDimmer int
	Brightness   int
	ScannerColor Color
	BaseColor    Color
	Color        Color
	Pan          int
	Tilt         int
	Shutter      int
	Rotate       int
	Music        int
	Gobo         int
	Program      int
	Enabled      bool
	Inverted     bool
	State        int // Last thing we did :- MAKE SAME AGAIN ,FADEUP or FADEDOWN
}

A common fixture can have any or some of the following, depending if its a light or a scanner.

type FixtureBuffer

type FixtureBuffer struct {
	BaseColor    Color
	Color        Color
	MasterDimmer int
	Brightness   int
	Gobo         int
	Pan          int
	Tilt         int
	Shutter      int
	Enabled      bool
	DebugMsg     string
	Step         int
	Rule         int
}

Used in calculating Positions.

type FixtureCommand

type FixtureCommand struct {
	Step           int
	NumberSteps    int
	Type           string
	Label          string
	SequenceNumber int
	FixtureState   FixtureState
	LastColor      Color

	// Common commands.
	Hidden         bool
	Strobe         bool
	StrobeSpeed    int
	Master         int
	MasterChanging bool
	Blackout       bool
	Clear          bool

	StartFlood bool
	StopFlood  bool

	// RGB commands.
	RGBPosition       Position
	RGBStaticOff      bool
	RGBStaticOn       bool
	RGBStaticFadeUp   bool
	RGBStaticColors   []StaticColorButton
	RGBPlayStaticOnce bool
	RGBFade           int

	// Scanner Commands.
	ScannerColor             int
	ScannerPosition          Position
	ScannerDisableOnce       bool
	ScannerChaser            bool
	ScannerAvailableColors   []StaticColorButton
	ScannerGobo              int
	ScannerOffsetPan         int
	ScannerOffsetTilt        int
	ScannerNumberCoordinates int
	ScannerShutterPositions  map[int]Position
	ScannerHasShutterChase   bool

	// Derby Commands
	Rotate  int
	Music   int
	Program int

	// Switch Commands
	SwitchData         Switch
	State              State
	CurrentSwitchState int
}

type FixtureState

type FixtureState struct {
	Enabled                bool
	RGBInverted            bool
	ScannerPatternReversed bool
}

type Function

type Function struct {
	Name           string
	SequenceNumber int
	Number         int
	State          bool
	Flash          bool
	Label          string
}

type Gobo

type Gobo struct {
	Name    string
	Label   string
	Number  int
	Setting int
	Flash   bool
	Color   Color
}

type Hit

type Hit struct {
	X int
	Y int
}

type LastColor

type LastColor struct {
	RGBColor     Color
	ScannerColor int
}

Used for static fades, remember the last color.

type Pattern

type Pattern struct {
	Name     string
	Label    string
	Number   int
	Length   int // 8, 4 or 2
	Size     int
	Fixtures int    // 8 Fixtures
	Steps    []Step `json:"-"` // Don't save the steps as they can be very large.
}

type Position

type Position struct {
	// RGB
	Fixtures map[int]Fixture
}

type Sequence

type Sequence struct {
	Name                        string                      // Sequence name.
	Label                       string                      // Sequence label.
	Description                 string                      // Sequence description.
	Number                      int                         // Sequence number.
	Run                         bool                        // True if this sequence is running.
	Bounce                      bool                        // True if this sequence is bouncing.
	RGBInvert                   bool                        // True if RGB sequence patten is inverted.
	Hidden                      bool                        // Hidden is used to indicate sequence buttons are not visible.
	Type                        string                      // Type of sequnece, current valid values are :- rgb, scanner,  or switch.
	Master                      int                         // Master Brightness
	MasterChanging              bool                        // flag to indicate we are changing brightness.
	Strobe                      bool                        // Strobe is enabled.
	StrobeSpeed                 int                         // Strobe speed.
	Rotate                      int                         // Rotate speed.
	RGBShift                    int                         // RGB shift.
	CurrentSpeed                time.Duration               // Sequence speed represented as a duration.
	Speed                       int                         // Sequence speed represented by a short number.
	MusicTrigger                bool                        // Is this sequence in music trigger mode.
	ChangeMusicTrigger          bool                        // true when we change the state of the music trigger.
	LastMusicTrigger            bool                        // Save copy of music trigger.
	Blackout                    bool                        // Flag to indicate we're in blackout mode.
	CurrentColors               []Color                     // Storage for the colors in a sequence.
	SequenceColors              []Color                     // Temporay storage for changing sequence colors.
	Color                       int                         // Index into current sequnece colors.
	ScannerSteps                []Step                      // Pan & Tilt steps in this  sequence.
	NumberSteps                 int                         // Holds the number of steps this sequence has. Will change if you change size, fade times etc.
	NumberFixtures              int                         // Total Number of fixtures for this sequence.
	EnabledNumberFixtures       int                         // Enabled Number of fixtures for this sequence.
	AutoColor                   bool                        // Sequence is going to automatically change the color.
	AutoPattern                 bool                        // Sequence is going to automatically change the pattern.
	GuiFixtureLabels            []string                    // Storage for the fixture labels. Used for scanner names.
	Pattern                     Pattern                     // Contains fixtures and RGB steps info.
	RGBAvailableColors          []StaticColorButton         // Available colors for the RGB fixtures.
	RGBColor                    int                         // The selected RGB fixture color.
	FadeUp                      []int                       // Fade up values.
	FadeOn                      []int                       // Fade on values.
	FadeDown                    []int                       // Fade down values.
	FadeOff                     []int                       // Fade off values.
	RGBFade                     int                         // RGB Fade time
	RGBSize                     int                         // RGB Fade size
	SavedSequenceColors         []Color                     // Used for updating the color in a sequence.
	RecoverSequenceColors       bool                        // Storage for recovering sequence colors, when you come out of automatic color change.
	SaveColors                  bool                        // Indicate we should save colors in this sequence. used for above.
	Mode                        string                      // Tells sequnece if we're in sequence (chase) or static (static colors) mode.
	StaticColors                []StaticColorButton         // Used in static color editing
	Clear                       bool                        // Clear all fixtures in this sequence.
	Static                      bool                        // We're a static sequence.
	PlayStaticOnce              bool                        // Play a static scene only once.
	PlayStaticLampsOnce         bool                        // Play a static scene but only on indicator lamps.
	PlaySwitchOnce              bool                        // Play a switch sequence scene only once.
	PlaySingleSwitch            bool                        // Play a single switch.
	StaticFadeUpOnce            bool                        // Only Fade up once, used for don't fade during color config operations.
	StaticLampsOn               bool                        // Show the static scene on the lamps, but don't send anything to the DMX universe.
	StartFlood                  bool                        // We're in flood mode.
	StopFlood                   bool                        // We're not in flood mode.
	LastStatic                  bool                        // Last value of static before flood.
	StartStrobe                 bool                        // We're in strobe mode.
	StopStrobe                  bool                        // We're not in strobe mode.
	FloodPlayOnce               bool                        // Play the flood sceme only once.
	FloodSelectedSequence       map[int]bool                // A map that remembers who is in flood mode.
	ScannerAvailableColorsMutex *sync.RWMutex               // Mutex to protect the scanner available colors map from syncronous access.
	ScannerAvailableColors      map[int][]StaticColorButton // Available colors for this scanner.
	ScannerAvailableGobos       map[int][]StaticColorButton // Available gobos for this scanner.
	ScannerAvailablePatterns    map[int]Pattern             // Available patterns for this scanner.
	ScannersAvailable           []StaticColorButton         // Holds a set of red buttons, one for every available fixture.
	SelectedPattern             int                         // The selected pattern.
	ScannerSize                 int                         // The selected scanner size.
	ScannerShift                int                         // Used for shifting scanners patterns apart.
	ScannerGobo                 map[int]int                 // Eight scanners per sequence, each can have their own gobo.
	ScannerChaser               bool                        // Chase the scanner shutters instead of allways being on.
	ScannerReverse              bool                        // Reverse the scanner, i.e scan in the opposite direction.
	ScannerColor                map[int]int                 // Eight scanners per sequence, each can have their own color.
	ScannerCoordinates          []int                       // Number of scanner coordinates.
	ScannerSelectedCoordinates  int                         // index into scanner coordinates.
	ScannerOffsetPan            int                         // Offset for pan values.
	ScannerOffsetTilt           int                         // Offset for tilt values.
	FixtureState                map[int]FixtureState        // Map of fixtures which are disabled.
	DisableOnceMutex            *sync.RWMutex               // Lock to protect DisableOnce.
	DisableOnce                 map[int]bool                // Map used to play disable only once.
	UpdateSize                  bool                        // Command to update size.
	UpdateShift                 bool                        // Command to update the shift.
	UpdatePattern               bool                        // Flag to indicate we're going to change the RGB pattern.
	UpdateSequenceColor         bool                        // Command to update the sequence colors.
	Switches                    map[int]Switch              // A switch sequence stores its data in here.
	CurrentSwitch               int                         // Play this current switch position.
	Optimisation                bool                        // Flag to decide on calculatePositions Optimisation.
	RGBNumberStepsInFade        int                         // Number of steps in a RGB fade.
}

Sequence describes sequences.

func RefreshSequence

func RefreshSequence(selectedSequence int, commandChannels []chan Command, updateChannels []chan Sequence) *Sequence

Get an upto date copy of the sequence.

type Setting

type Setting struct {
	Name         string
	Label        string
	Number       int
	Channel      string
	Value        int16
	FixtureValue string
}

type State

type State struct {
	Name        string
	Number      int16
	Label       string
	Values      []Value
	ButtonColor string
	Actions     []Action
	Settings    []Setting
	Flash       bool
}

type StaticColorButton

type StaticColorButton struct {
	Name             string
	Label            string
	Number           int
	X                int
	Y                int
	SelectedSequence int
	Color            Color
	SelectedColor    int
	Flash            bool
	Setting          int
	FirstPress       bool
	Enabled          bool
}

func SetDefaultStaticColorButtons

func SetDefaultStaticColorButtons(selectedSequence int) []StaticColorButton

Sets the static colors to default values.

type Step

type Step struct {
	StepNumber int
	KeyStep    bool
	Fixtures   map[int]Fixture
}

type Switch

type Switch struct {
	ID                   int
	Name                 string
	Address              int16
	Number               int
	Label                string
	CurrentPosition      int
	Description          string
	States               map[int]State
	Fixture              string
	UseFixture           string
	MiniSequencerRunning bool
	Blackout             bool
	Master               int
}

type SwitchChannel

type SwitchChannel struct {
	Stop            chan bool
	StopRotate      chan bool
	StopFadeDown    chan bool
	StopFadeUp      chan bool
	KeepRotateAlive chan bool
}

type Trigger

type Trigger struct {
	Name    string
	State   bool
	Gain    float32
	Channel chan Command
}

type Value

type Value struct {
	Channel string
	Setting string
}

Jump to

Keyboard shortcuts

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