You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
548 B

  1. package effects
  2. import (
  3. "fmt"
  4. "git.aiterp.net/lucifer3/server/device"
  5. "time"
  6. )
  7. type Pattern struct {
  8. States []device.State `json:"states,omitempty"`
  9. ShiftMS int64 `json:"shiftMs,omitempty"`
  10. }
  11. func (p Pattern) State(index, round, _ int) device.State {
  12. return p.States[(index+round)%len(p.States)]
  13. }
  14. func (p Pattern) Frequency() time.Duration {
  15. return time.Duration(p.ShiftMS) * time.Millisecond
  16. }
  17. func (p Pattern) EffectDescription() string {
  18. return fmt.Sprintf("Pattern(len:%d, animation:%dms)", len(p.States), p.ShiftMS)
  19. }