add gradient and random effect.

This commit is contained in:
2022-08-19 10:55:29 +02:00
parent 8c7f1c6ffc
commit 1f5df2e034
13 changed files with 247 additions and 50 deletions
+16 -25
View File
@@ -55,27 +55,15 @@ func main() {
time.Sleep(time.Millisecond)
bus.RunEvent(events.HardwareState{
ID: "nanoleaf:10.80.1.11:40e5",
InternalName: "Hexagon 6",
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
ColorFlags: device.CFlagRGB,
State: device.State{},
})
bus.RunEvent(events.HardwareState{
ID: "nanoleaf:10.80.1.11:dead",
InternalName: "Hexagon 7",
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
ColorFlags: device.CFlagRGB,
State: device.State{},
})
bus.RunEvent(events.HardwareState{
ID: "nanoleaf:10.80.1.11:beef",
InternalName: "Hexagon 8",
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
ColorFlags: device.CFlagRGB,
State: device.State{},
})
for i, id := range []string{"40e5", "dead", "beef", "cafe", "1337"} {
bus.RunEvent(events.HardwareState{
ID: "nanoleaf:10.80.1.11:" + id,
InternalName: fmt.Sprintf("Hexagon %d", 6+i),
SupportFlags: device.SFlagPower | device.SFlagColor | device.SFlagIntensity,
ColorFlags: device.CFlagRGB,
State: device.State{},
})
}
time.Sleep(time.Millisecond)
@@ -90,22 +78,25 @@ func main() {
time.Sleep(time.Millisecond)
c1 := gentools.Ptr(color.MustParse("rgb:#ff0000"))
c2 := gentools.Ptr(color.MustParse("rgb:#00ff00"))
bus.RunCommand(commands.Assign{
Match: "**:Hexagon *",
Effect: effects.Pattern{
Effect: effects.Gradient{
States: []device.State{
{
Power: gentools.Ptr(true),
Color: gentools.Ptr(color.MustParse("rgb:#ff0000")),
Color: c1,
Intensity: gentools.Ptr(1.0),
},
{
Power: gentools.Ptr(true),
Color: gentools.Ptr(color.MustParse("rgb:#00ff00")),
Color: c2,
Intensity: gentools.Ptr(0.7),
},
},
ShiftMS: 1000,
AnimationMS: 1000,
Interpolate: true,
},
})