switched to doubles as channel values

This commit is contained in:
2019-05-03 20:37:21 +02:00
parent d8c448662a
commit 94ce0749c7
2 changed files with 8 additions and 8 deletions

14
ledd.go
View File

@@ -188,7 +188,7 @@ func (manager *LEDManager) color(led *LED) {
return
}
cMap := make(map[int32]int32)
cMap := make(map[int32]float64)
if !color.IsValid() {
log.Warningf("[%s] Got invalid HCL->RGB color, clamping!", led.Name)
@@ -197,9 +197,9 @@ func (manager *LEDManager) color(led *LED) {
log.Debugf("[%s] New color: \x1b[38;2;%d;%d;%dm%s\x1b[0m", led.Name, int(math.Round(color.R*255)), int(math.Round(color.G*255)), int(math.Round(color.B*255)), color.Hex())
cMap[led.Channel[0]] = int32(color.R * float64(backend.resolution))
cMap[led.Channel[1]] = int32(color.G * float64(backend.resolution))
cMap[led.Channel[2]] = int32(color.B * float64(backend.resolution))
cMap[led.Channel[0]] = color.R
cMap[led.Channel[1]] = color.G
cMap[led.Channel[2]] = color.B
wrapperMsg := &ledd.BackendWrapperMessage{
Msg: &ledd.BackendWrapperMessage_MSetChannel{
@@ -486,7 +486,7 @@ func (manager *ClientManager) receive(client *Client) {
break
}
backend.setChannel(msg.MSetDirect.Channel, msg.MSetDirect.Value)
backend.setChannel(msg.MSetDirect.Channel, float64(msg.MSetDirect.Value/backend.resolution))
case *ledd.ClientWrapperMessage_MRemoveLed:
led, ok := ledManager.leds[msg.MRemoveLed.Name]
if !ok {
@@ -517,8 +517,8 @@ func (backend *Backend) niceName() string {
}
}
func (backend Backend) setChannel(channel int32, val int32) {
cMap := make(map[int32]int32)
func (backend Backend) setChannel(channel int32, val float64) {
cMap := make(map[int32]float64)
cMap[channel] = val

2
proto

Submodule proto updated: 9a2fd0ad06...3d37eb67b3