Skip to content

Commit 0245819

Browse files
committed
fix: set backlight effect params
1 parent c2a77e5 commit 0245819

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

examples/current-effect/main.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/mishamyrt/nuga-lib"
7+
"github.com/mishamyrt/nuga-lib/packages/cli"
8+
)
9+
10+
func main() {
11+
err := nuga.Init()
12+
cli.Must("initialize CLI", err)
13+
dev, err := nuga.Open()
14+
cli.Must("open device", err)
15+
effects, err := dev.Features.Light.GetEffects()
16+
cli.Must("get effects", err)
17+
fmt.Println("Backlight")
18+
fmt.Printf(" Mode: %v\n", effects.Backlight.Mode.Name)
19+
fmt.Printf(" Color: %v\n", effects.Backlight.CurrentParams().Color)
20+
fmt.Printf(" Brightness: %v\n", effects.Backlight.CurrentParams().Brightness)
21+
fmt.Printf(" Speed: %v\n", effects.Backlight.CurrentParams().Speed)
22+
fmt.Println("Halo")
23+
fmt.Printf(" Mode: %v\n", effects.Halo.Mode.Name)
24+
fmt.Printf(" Color: %v\n", effects.Halo.Color)
25+
fmt.Printf(" Brightness: %v\n", effects.Halo.Brightness)
26+
fmt.Printf(" Speed: %v\n", effects.Halo.Speed)
27+
fmt.Println("Sidelight")
28+
fmt.Printf(" Mode: %v\n", effects.Sidelight.Mode.Name)
29+
fmt.Printf(" Color: %v\n", effects.Sidelight.Color)
30+
fmt.Printf(" Brightness: %v\n", effects.Sidelight.Brightness)
31+
fmt.Printf(" Speed: %v\n", effects.Sidelight.Speed)
32+
err = nuga.Exit()
33+
cli.Must("exit", err)
34+
}

features/light/effect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ func ParseEffects(data []byte) (*Effects, error) {
109109
result.Backlight.Params = make([]EffectParams, 29)
110110
for i := range result.Backlight.Params {
111111
offset := colorParamsOffset + (i * 2)
112-
113112
if data[offset] == 255 {
114113
continue
115114
}
116115
p := effectAppearance(data[offset+1])
117-
_, err := NewEffectParams(data[offset], p.Speed(), p.Brightness())
116+
params, err := NewEffectParams(data[offset], p.Speed(), p.Brightness())
118117
if err != nil {
119118
return nil, err
120119
}
120+
result.Backlight.Params[i] = *params
121121
}
122122
return result, nil
123123
}

0 commit comments

Comments
 (0)