Compare commits

...

3 Commits
v1 ... main

Author SHA1 Message Date
Nathan Wagner 3d3b3fbf7b new playAnimationUntil that stops animation when notify channel receives message
build lightwatch / build (push) Has started running Details
2 years ago
Nathan Wagner 6e27fc641b duh exporting
build lightwatch / build (push) Successful in 5m39s Details
2 years ago
Nathan Wagner 66d55c15de export field
build lightwatch / build (push) Successful in 5m41s Details
2 years ago

@ -60,7 +60,7 @@ var DefaultConfig = HardwareConfig{
} }
type RunTimeConfig struct { type RunTimeConfig struct {
gpio_slowdown int Gpio_slowdown int
} }
// HardwareConfig rgb-led-matrix configuration // HardwareConfig rgb-led-matrix configuration
@ -110,7 +110,7 @@ func (c *HardwareConfig) geometry() (width, height int) {
func (c *RunTimeConfig) rt_options() *C.struct_RGBLedRuntimeOptions { func (c *RunTimeConfig) rt_options() *C.struct_RGBLedRuntimeOptions {
rt := &C.struct_RGBLedRuntimeOptions{} rt := &C.struct_RGBLedRuntimeOptions{}
rt.gpio_slowdown = C.int(c.gpio_slowdown) rt.gpio_slowdown = C.int(c.Gpio_slowdown)
return rt return rt
} }

@ -64,7 +64,6 @@ func (tk *ToolKit) PlayAnimation(a Animation) error {
return err return err
} }
} }
if err == io.EOF { if err == io.EOF {
return nil return nil
} }
@ -72,6 +71,35 @@ func (tk *ToolKit) PlayAnimation(a Animation) error {
return err return err
} }
func (tk *ToolKit) PlayAnimationUntil(a Animation, notify <-chan bool) error {
var err error
var i image.Image
var n <-chan time.Time
var outerError error
for outerError == nil {
select {
case <-notify:
return nil
default:
i, n, err = a.Next()
if err != nil {
outerError = err
break
}
if err := tk.PlayImageUntil(i, n); err != nil {
return err
}
}
}
if outerError == io.EOF {
return nil
}
return err
}
// PlayImageUntil draws the given image until is notified to stop // PlayImageUntil draws the given image until is notified to stop
func (tk *ToolKit) PlayImageUntil(i image.Image, notify <-chan time.Time) error { func (tk *ToolKit) PlayImageUntil(i image.Image, notify <-chan time.Time) error {
defer func() { defer func() {

Loading…
Cancel
Save