From 8c3df1dfa22694eda08bd0a386f90405161ceb5c Mon Sep 17 00:00:00 2001 From: Martyn Ranyard Date: Mon, 13 Jul 2020 17:14:02 +0200 Subject: [PATCH] Vary framerate by env Signed-off-by: Martyn Ranyard --- cmd/ledcontroller-server/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/ledcontroller-server/main.go b/cmd/ledcontroller-server/main.go index f03dbd6..5d9ca2e 100755 --- a/cmd/ledcontroller-server/main.go +++ b/cmd/ledcontroller-server/main.go @@ -30,9 +30,11 @@ var overrideEffect queue.QueueItem var overrideFlag = make(chan queue.QueueItem, 1) var previousEffect queue.QueueItem +var msDelay = 0 + func foreverLoop() { for /*ever*/ { - time.Sleep(40 * time.Millisecond) //25fps + time.Sleep(time.Duration(msDelay) * time.Millisecond) //25fps for u := 0; u < universeCount; u++ { sema <- struct{}{} // acquire token channels[u] <- currentFrame[u] @@ -75,6 +77,10 @@ func main() { if err != nil { PanelHeight = 15 } + msDelay, err = strconv.Atoi(os.Getenv("MS_DELAY")) + if err != nil { + msDelay = 40 + } universeCount = int(math.Ceil(float64(PanelHeight*PanelWidth*3) / 510)) fmt.Printf("Universe count is %d\n", universeCount)