Fix the universes bug
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
This commit is contained in:
parent
209bebe51d
commit
c41fca9c5a
|
@ -24,11 +24,12 @@ var sema = make(chan struct{}, 1) // a binary semaphore guarding currentFrame
|
||||||
|
|
||||||
var currentEffect queue.QueueItem
|
var currentEffect queue.QueueItem
|
||||||
var globalEffectChannel = make(chan queue.QueueItem, 1024)
|
var globalEffectChannel = make(chan queue.QueueItem, 1024)
|
||||||
|
var universeCount int = 0
|
||||||
|
|
||||||
func foreverLoop() {
|
func foreverLoop() {
|
||||||
for /*ever*/ {
|
for /*ever*/ {
|
||||||
time.Sleep(40 * time.Millisecond) //25fps
|
time.Sleep(40 * time.Millisecond) //25fps
|
||||||
for u := 0; u < 2; u++ {
|
for u := 0; u < universeCount; u++ {
|
||||||
sema <- struct{}{} // acquire token
|
sema <- struct{}{} // acquire token
|
||||||
channels[u] <- currentFrame[u]
|
channels[u] <- currentFrame[u]
|
||||||
<-sema
|
<-sema
|
||||||
|
@ -43,8 +44,6 @@ func reduceBrightness(universe [512]byte, percentage int) [512]byte {
|
||||||
return universe
|
return universe
|
||||||
}
|
}
|
||||||
|
|
||||||
var universeCount int = 0
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
|
@ -74,7 +73,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
universeCount = int(math.Ceil(float64(PanelHeight*PanelWidth*3) / 510))
|
universeCount = int(math.Ceil(float64(PanelHeight*PanelWidth*3) / 510))
|
||||||
fmt.Printf("Universe count is %d", universeCount)
|
fmt.Printf("Universe count is %d\n", universeCount)
|
||||||
|
|
||||||
PanelBrightness, err := strconv.Atoi(os.Getenv("PANEL_BRIGHTNESS"))
|
PanelBrightness, err := strconv.Atoi(os.Getenv("PANEL_BRIGHTNESS"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -111,7 +110,8 @@ func main() {
|
||||||
e.SeedColour[1] = 255
|
e.SeedColour[1] = 255
|
||||||
e.SeedColour[2] = 0
|
e.SeedColour[2] = 0
|
||||||
globalEffectChannel <- e
|
globalEffectChannel <- e
|
||||||
e.Effect = "default"
|
e.Effect = "plasma"
|
||||||
|
e.Speed = 40
|
||||||
globalEffectChannel <- e
|
globalEffectChannel <- e
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -120,7 +120,11 @@ func main() {
|
||||||
currentEffect.Duration -= 40
|
currentEffect.Duration -= 40
|
||||||
} else {
|
} else {
|
||||||
if len(globalEffectChannel) > 0 {
|
if len(globalEffectChannel) > 0 {
|
||||||
|
lastEffect := currentEffect
|
||||||
currentEffect = <-globalEffectChannel
|
currentEffect = <-globalEffectChannel
|
||||||
|
if lastEffect != currentEffect {
|
||||||
|
fmt.Printf("New effect selected : %s\n", currentEffect.Effect)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var rearranged [][]byte
|
var rearranged [][]byte
|
||||||
|
|
Loading…
Reference in New Issue