Raspberry Pi 3 Cookbook for Python Programmers - Third Edition
by Steven Lawrence Fernandes, Tim Cox
How it works...
Initially, we defined addresses for each of the control registers used by the MAX7219 device. View the datasheet at for more information:
https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf.
We created a class called matrix that will allow us to control the module. The __init__() function sets up the SPI of Raspberry Pi (using SPI_CS as pin 26 CS1 and SPI_SPEED as 100 kHz).
The key function in our matrix class is the sendCmd() function; it uses wiringpi.wiringPiSPIDataRW(SPI_CS,buff) to send buffer (which is the raw byte data that we want to send) over the SPI bus (while also setting the SPI_CS pin to low when the transfer occurs). Each command consists of two bytes: the first specifies the address of the register, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access