Last active
October 11, 2016 21:11
-
-
Save asukakenji/9e210ba0632b474e1a1603c873adbe4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (bt *BlinkyTape) animation(p Pattern, repeat int, delay time.Duration) { | |
bt.status = Running | |
innerLoop := func() bool { | |
select { | |
case <-bt.stop: | |
return false | |
default: | |
go bt.playPattern(p, delay) | |
<-bt.next | |
return true | |
} | |
} | |
if repeat < 0 { | |
for { | |
if !innerLoop() { | |
break | |
} | |
} | |
} else { | |
for i := 0; i < repeat; i++ { | |
if !innerLoop() { | |
break | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment