first commit of files
This commit is contained in:
25
models/device.go
Normal file
25
models/device.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Device struct {
|
||||
startAddress uint
|
||||
length uint
|
||||
channels *DMX
|
||||
}
|
||||
|
||||
func NewDevice(startAddress uint, channels uint, dmx *DMX) *Device {
|
||||
return &Device{
|
||||
startAddress: startAddress,
|
||||
length: channels,
|
||||
channels: dmx,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Device) SetChannelValue(channel uint, value uint8) error {
|
||||
if d.length == channel {
|
||||
return fmt.Errorf("channel out of range %d", channel)
|
||||
}
|
||||
d.channels.SetValue(d.startAddress+channel, value)
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user