propably fixed a memorx access error
This commit is contained in:
24
main.go
24
main.go
@@ -39,7 +39,7 @@ type config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LedDaemon struct {
|
type LedDaemon struct {
|
||||||
name string
|
name string
|
||||||
socket net.Conn
|
socket net.Conn
|
||||||
data chan []byte
|
data chan []byte
|
||||||
}
|
}
|
||||||
@@ -82,10 +82,10 @@ func (daemon *LedDaemon) receive() {
|
|||||||
case *ledd.BackendWrapperMessage_MSetChannel:
|
case *ledd.BackendWrapperMessage_MSetChannel:
|
||||||
for c, v := range msg.MSetChannel.NewChannelValues {
|
for c, v := range msg.MSetChannel.NewChannelValues {
|
||||||
if pwm, ok := pwmMap[c]; ok {
|
if pwm, ok := pwmMap[c]; ok {
|
||||||
pwm.SetPercentage(float32(v)/RESOLUTION)
|
pwm.SetPercentage(float32(v) / RESOLUTION)
|
||||||
} else {
|
} else {
|
||||||
pwmMap[c] = pca9685.NewPwm(int(c))
|
pwmMap[c] = pca9685.NewPwm(int(c))
|
||||||
pwmMap[c].SetPercentage(float32(v)/RESOLUTION)
|
pwmMap[c].SetPercentage(float32(v) / RESOLUTION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ func main() {
|
|||||||
killSignals := make(chan os.Signal, 1)
|
killSignals := make(chan os.Signal, 1)
|
||||||
signal.Notify(killSignals, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(killSignals, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
log.Info("LedD", VERSION)
|
log.Info("LedD PCA9685 backend", VERSION)
|
||||||
config := config{}
|
config := config{}
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("config.yaml")
|
content, err := ioutil.ReadFile("config.yaml")
|
||||||
@@ -129,7 +129,7 @@ func main() {
|
|||||||
check(err)
|
check(err)
|
||||||
defer i2cDevice.Close()
|
defer i2cDevice.Close()
|
||||||
|
|
||||||
pca9685 := device.NewPCA9685(i2cDevice, "PWM Controller", config.Pca9685.MinPulse, config.Pca9685.MaxPulse, log)
|
pca9685 := device.NewPCA9685(i2cDevice, "PWM Controller", config.Pca9685.MinPulse, config.Pca9685.MaxPulse, logging.MustGetLogger("PCA9685"))
|
||||||
pca9685.Init()
|
pca9685.Init()
|
||||||
|
|
||||||
pwmMap = make(map[int32]*device.Pwm, 1)
|
pwmMap = make(map[int32]*device.Pwm, 1)
|
||||||
@@ -138,9 +138,9 @@ func main() {
|
|||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
ledDaemon = &LedDaemon{
|
ledDaemon = &LedDaemon{
|
||||||
socket:conn,
|
socket: conn,
|
||||||
data: make (chan []byte),
|
data: make(chan []byte),
|
||||||
name: "?",
|
name: "?",
|
||||||
}
|
}
|
||||||
|
|
||||||
go ledDaemon.send()
|
go ledDaemon.send()
|
||||||
@@ -149,11 +149,11 @@ func main() {
|
|||||||
wrapperMsg := &ledd.BackendWrapperMessage{
|
wrapperMsg := &ledd.BackendWrapperMessage{
|
||||||
Msg: &ledd.BackendWrapperMessage_MBackend{
|
Msg: &ledd.BackendWrapperMessage_MBackend{
|
||||||
MBackend: &ledd.Backend{
|
MBackend: &ledd.Backend{
|
||||||
Name: config.Name,
|
Name: config.Name,
|
||||||
Channel: CHANNEL,
|
Channel: CHANNEL,
|
||||||
Type: "PCA9685",
|
Type: "PCA9685",
|
||||||
Resolution: RESOLUTION,
|
Resolution: RESOLUTION,
|
||||||
Version: VERSION,
|
Version: VERSION,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user