Matrix/matrix.go

30 lines
895 B
Go
Raw Normal View History

2024-04-12 12:13:21 +00:00
package main
import (
"fmt"
"os"
)
2024-04-17 06:11:23 +00:00
func loadMatrixData() (string, uint, uint) {
2024-04-12 12:13:21 +00:00
// Remote server info
API_SERVER_IP, _ := getEnvFallback("API_SERVER_IP", "localhost")
API_SERVER_PORT, _ := getEnvFallback("API_SERVER_PORT", "8080")
// LED panel info
PUBLIC_LED_WIDTH, _ := convertFallback(os.Getenv("PUBLIC_LED_WIDTH"), 64)
PUBLIC_LED_HEIGHT, _ := convertFallback(os.Getenv("PUBLIC_LED_HEIGHT"), 64)
// Matrix arrangement info
PUBLIC_LED_CHAIN, _ := convertFallback(os.Getenv("PUBLIC_LED_CHAIN"), 1)
PUBLIC_LED_PARALLEL, _ := convertFallback(os.Getenv("PUBLIC_LED_PARALLEL"), 1)
// Prepare remote server url
url := fmt.Sprintf("http://%s:%s", API_SERVER_IP, API_SERVER_PORT)
// Calculate combined resolution
2024-04-17 06:11:23 +00:00
width := uint(PUBLIC_LED_WIDTH * PUBLIC_LED_CHAIN)
height := uint(PUBLIC_LED_HEIGHT * PUBLIC_LED_PARALLEL)
2024-04-12 12:13:21 +00:00
return url, width, height
}