first commit of files

This commit is contained in:
Adrian Zürcher
2025-04-18 10:30:18 +02:00
parent 5595af0add
commit f213f53547
22 changed files with 842 additions and 0 deletions

29
models/package.go Normal file
View File

@@ -0,0 +1,29 @@
package models
import (
"bytes"
"encoding/binary"
)
// Art-Net constants
const (
opCode = 0x5000 // OpDmx (low byte first)
protocolID = "Art-Net\x00"
)
type Package []byte
func NewArtNetPackage(data *DMX) Package {
// Build ArtDMX packet
packet := &bytes.Buffer{}
packet.WriteString(protocolID) // Art-Net ID
binary.Write(packet, binary.LittleEndian, uint16(opCode)) // OpCode (OpDmx)
packet.WriteByte(0x00) // Protocol Version High
packet.WriteByte(14) // Protocol Version Low (14 for Art-Net 4)
packet.WriteByte(0x00) // Sequence
packet.WriteByte(0x00) // Physical
binary.Write(packet, binary.BigEndian, uint16(0)) // Universe (net:subuni, usually 0)
binary.Write(packet, binary.BigEndian, uint16(len(*data))) // Length
packet.Write(*data)
return packet.Bytes()
}