Matrix/main.go

53 lines
1.2 KiB
Go
Raw Normal View History

2024-04-12 07:54:27 +00:00
package main
import (
2024-04-14 19:47:13 +00:00
"fmt"
2024-04-12 08:00:53 +00:00
"log"
"github.com/go-resty/resty/v2"
"github.com/joho/godotenv"
2024-04-12 07:54:27 +00:00
)
2024-04-14 19:47:13 +00:00
func output(_ *resty.Client, _ string, width, height int, arr [][]Cell) {
for i := 0; i < width; i++ {
for j := 0; j < height; j++ {
if arr[i][j].live {
fmt.Printf("█")
} else {
fmt.Printf(" ")
}
}
fmt.Printf("\n")
}
}
2024-04-12 07:54:27 +00:00
func main() {
2024-04-12 08:02:12 +00:00
// Load .env file if it exists
err := godotenv.Load(".env")
if err != nil {
log.Fatal("Error loading .env file")
}
// Load env server data
2024-04-12 11:30:00 +00:00
url, width, height := loadMatrixData()
2024-04-12 08:14:17 +00:00
log.Printf("At '%s': %d x %d\n", url, width, height)
// Initialize resty client
client := resty.New()
// Initialize custom matrix data
2024-04-12 08:50:12 +00:00
col := Color{R: 255, G: 0, B: 255, Endpoint: COLOR}
rct := Rectangle{X: 0, Y: 0, W: 10, H: 10, Endpoint: RECTANGLE}
2024-04-12 12:13:21 +00:00
// Send request to remote server
sendRequest(client, url, []interface{}{col, rct})
// Initialize custom matrix data
col = Color{R: 255, G: 255, B: 0, Endpoint: COLOR}
rct = Rectangle{X: 15, Y: 15, W: 15, H: 15, Endpoint: RECTANGLE}
2024-04-12 08:50:12 +00:00
upd := Update{Endpoint: UPDATE}
2024-04-12 08:03:36 +00:00
// Send request to remote server
2024-04-12 11:30:00 +00:00
sendRequest(client, url, []interface{}{col, rct, upd})
2024-04-12 07:54:27 +00:00
}