fix wrong call and missing send set

This commit is contained in:
Adrian Zuercher
2025-07-27 13:07:16 +02:00
parent a503b71fb6
commit 3704edebd5
2 changed files with 8 additions and 3 deletions

View File

@@ -157,6 +157,7 @@ func (b *Bus) Start(log *logging.Logger) error {
}() }()
for range ticker.C { for range ticker.C {
if !b.Send { if !b.Send {
continue continue
} }
@@ -165,7 +166,7 @@ func (b *Bus) Start(log *logging.Logger) error {
b.mu.Lock() b.mu.Lock()
data := NewDMXUniverse() data := NewDMXUniverse()
copy(data.Data, data.GetDMXData()) copy(data.Data, b.DMX.GetDMXData())
b.mu.Unlock() b.mu.Unlock()
_, err = conn.Write(NewArtNetPackage(data)) _, err = conn.Write(NewArtNetPackage(data))
@@ -174,6 +175,7 @@ func (b *Bus) Start(log *logging.Logger) error {
return return
} }
} }
}() }()
return nil return nil
} }
@@ -215,6 +217,7 @@ func (b *Bus) ParsePayload(c *gin.Context) error {
func (b *Bus) SetDMXData(channel uint, value uint8) error { func (b *Bus) SetDMXData(channel uint, value uint8) error {
b.DMX.SetValue(channel, value) b.DMX.SetValue(channel, value)
b.Send = true
return nil return nil
} }

View File

@@ -1,6 +1,8 @@
package models package models
import "sync" import (
"sync"
)
type DMX struct { type DMX struct {
Data []byte Data []byte
@@ -17,7 +19,7 @@ func (d *DMX) GetDMXData() (data []byte) {
d.mu.Lock() d.mu.Lock()
data = d.Data data = d.Data
d.mu.Unlock() d.mu.Unlock()
return data return
} }
func (d *DMX) SetValue(channel uint, value uint8) { func (d *DMX) SetValue(channel uint, value uint8) {