Skip to content

Instantly share code, notes, and snippets.

@bobzsj87
Created April 27, 2018 14:56
Show Gist options
  • Select an option

  • Save bobzsj87/e38d3406621edabca03038cf2ddd4f70 to your computer and use it in GitHub Desktop.

Select an option

Save bobzsj87/e38d3406621edabca03038cf2ddd4f70 to your computer and use it in GitHub Desktop.
simple SPI apa102 with adafruit 8x8
import spidev
spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz = 800000
#signal = [0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x15,0xff,0x11,0x11,0x11,0xff,0x00,0x00,0x00,0xff,0x11,0x11,0x00,0xff,0xff,0xff,0xff]
mat = [
[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0],
[0,0,1,1,1,1,0,0],
[0,1,0,0,0,0,1,0],
[0,0,1,1,1,1,0,0],
[0,1,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0]
]
signal = [0x00,0x00,0x00,0x00]
for y in range(8):
for x in range(8):
value = mat[y][7-x]
if value:
signal += [0xe0, 0xff,0xff,0xff]
else:
signal += [0xf0, 0x00,0x00,0x00]
signal += [0xff,0xff,0xff,0xff]
spi.xfer(signal)
spi.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment