Created
May 18, 2022 19:32
-
-
Save youngkin/2811bd14b580024ea92950aee6c33b9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize SPI on the SPI0 associated GPIO pins | |
if err := rpio.SpiBegin(rpio.Spi0); err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
csPin.Output() | |
rpio.SpiChipSelect(uint8(csPin)) // Select CE0 (csPin) as slave | |
initMax7219() | |
for { | |
select { | |
case <-stop: | |
break | |
default: | |
for i := 0; i < NUM_CHARS; i++ { | |
for j := 1; j < MATRIX_ROW+1; j++ { | |
// 'j' starts at 1 since it's also used to reference the MAX7219 display registers | |
// which start at offset 1. | |
writeMax7219(byte(j), disp1[i][j-1]) | |
} | |
time.Sleep(500 * time.Millisecond) | |
} | |
break | |
} | |
} | |
// Reset the SPI0 pins back to INPUT mode | |
rpio.SpiEnd(rpio.Spi0) | |
// Release SPI resources (e.g., mapped memory) | |
rpio.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment