diff --git a/main.go b/main.go index 0dbbfae..8e6f2eb 100644 --- a/main.go +++ b/main.go @@ -8,18 +8,21 @@ import ( "github.com/joho/godotenv" ) -func output(_ *resty.Client, _ string, width, height int, arr [][]Cell) { +func output(client *resty.Client, url string, width, height int, arr [][]Cell) { + // Prepare instructions for matrix + instructions := make([]interface{}, 0) + // Append all live cells as pixel instructions for i := 0; i < width; i++ { for j := 0; j < height; j++ { if arr[i][j].live { - fmt.Printf("*") - } else { - fmt.Printf(" ") + instructions = append(instructions, Pixel{X: i, Y: j, Endpoint: PIXEL}) } } - fmt.Printf("\n") } - fmt.Printf("------------\n") + // Append update instruction + instructions = append(instructions, Update{Endpoint: UPDATE}) + // Send to matrix + sendRequest(client, url, instructions) } func main() { @@ -35,6 +38,8 @@ func main() { // Initialize resty client client := resty.New() + // Initialize pixel color + sendRequest(client, url, []interface{}{Color{R: 255, G: 255, B: 255, Endpoint: COLOR}}) // Run Game of Life done := setup(func(c [][]Cell) { @@ -45,19 +50,4 @@ func main() { fmt.Scanln() // Stop Game of Life, wait for routine done <- true - - // // Initialize custom matrix data - // col := Color{R: 255, G: 0, B: 255, Endpoint: COLOR} - // rct := Rectangle{X: 0, Y: 0, W: 10, H: 10, Endpoint: RECTANGLE} - // - // // 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} - // upd := Update{Endpoint: UPDATE} - // - // // Send request to remote server - // sendRequest(client, url, []interface{}{col, rct, upd}) }