add pattern effects.
This commit is contained in:
+28
-2
@@ -62,6 +62,20 @@ func main() {
|
|||||||
ColorFlags: device.CFlagRGB,
|
ColorFlags: device.CFlagRGB,
|
||||||
State: device.State{},
|
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{},
|
||||||
|
})
|
||||||
|
|
||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
|
|
||||||
@@ -78,11 +92,21 @@ func main() {
|
|||||||
|
|
||||||
bus.RunCommand(commands.Assign{
|
bus.RunCommand(commands.Assign{
|
||||||
Match: "**:Hexagon *",
|
Match: "**:Hexagon *",
|
||||||
Effect: effects.Manual{
|
Effect: effects.Pattern{
|
||||||
|
States: []device.State{
|
||||||
|
{
|
||||||
Power: gentools.Ptr(true),
|
Power: gentools.Ptr(true),
|
||||||
Color: gentools.Ptr(color.MustParse("rgb:#ffcc11")),
|
Color: gentools.Ptr(color.MustParse("rgb:#ff0000")),
|
||||||
Intensity: gentools.Ptr(1.0),
|
Intensity: gentools.Ptr(1.0),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Power: gentools.Ptr(true),
|
||||||
|
Color: gentools.Ptr(color.MustParse("rgb:#00ff00")),
|
||||||
|
Intensity: gentools.Ptr(0.7),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ShiftMS: 1000,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
time.Sleep(time.Millisecond * 100)
|
time.Sleep(time.Millisecond * 100)
|
||||||
@@ -92,4 +116,6 @@ func main() {
|
|||||||
log.Println("- ID:", dev.ID)
|
log.Println("- ID:", dev.ID)
|
||||||
log.Println(" Aliases:", dev.Aliases)
|
log.Println(" Aliases:", dev.Aliases)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Second * 15)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package effects
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.aiterp.net/lucifer3/server/device"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Pattern struct {
|
||||||
|
States []device.State `json:"states,omitempty"`
|
||||||
|
ShiftMS int64 `json:"shiftMs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Pattern) State(index, round, _ int) device.State {
|
||||||
|
return p.States[(index+round)%len(p.States)]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Pattern) Frequency() time.Duration {
|
||||||
|
return time.Duration(p.ShiftMS) * time.Millisecond
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Pattern) EffectDescription() string {
|
||||||
|
return fmt.Sprintf("Pattern(len:%d, animation:%dms)", len(p.States), p.ShiftMS)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user