func draw(board Board, l *controller.Launchpad) { if monochrome == false { l.AllGridLightsOn(OFF_COLOR) } for x := 0; x < len(board); x++ { for y := 0; y < len(board[x]); y++ { if board[x][y] { l.LightOnXY(x, y, ON_COLOR) } } } }
func handleButtons(l *controller.Launchpad, nextBoards chan Board, quit chan bool) { for { select { case cc := <-l.OutPort().ControlChanges(): if cc.Value == 0 { continue } switch cc.ID { case 108: quit <- true time.Sleep(250 * time.Millisecond) // Hack. if len(quit) > 0 { <-quit } nextBoards <- glider() go loop(l, nextBoards, quit) case 111: quit <- true // Stop the playback loop. programMode = true } case note := <-l.OutPort().NoteOns(): switch note.Key { case 8: nextBoards <- glider() case 24: nextBoards <- spaceship() case 40: nextBoards <- queen() case 56: nextBoards <- phoenix() case 72: nextBoards <- queen() case 88: nextBoards <- infinity() } case note := <-l.OutPort().NoteOffs(): l.ToggleLightColor(note.Key, ON_COLOR, OFF_COLOR) } } }
func redraw(board, nextBoard Board, l *controller.Launchpad) { for x := 0; x < len(board); x++ { for y := 0; y < len(board[x]); y++ { if board[x][y] != nextBoard[x][y] { if nextBoard[x][y] { l.LightOnXY(x, y, ON_COLOR) } else { if monochrome == false { l.LightOnXY(x, y, OFF_COLOR) } else { l.LightOffXY(x, y) } } } } } }