Skip to content

Instantly share code, notes, and snippets.

@connornishijima
Created July 29, 2020 21:48
Show Gist options
  • Save connornishijima/5032f4f1061889150e7ce3b001d3792d to your computer and use it in GitHub Desktop.
Save connornishijima/5032f4f1061889150e7ce3b001d3792d to your computer and use it in GitHub Desktop.
# Pixie driver test abusing SPI bus for clean data transfer at any speed
# If this works, let me know so I can simplify usage!
# Currently it sends a raw byte array below to render images to connected
# Pixies, flashing between a PIX_SMILE icon and a solid color at a visible rate.
# -------------------------------------------------------------------------
# SPI must be enabled using "sudo raspi-config" under "Interfacing Options"
# -------------------------------------------------------------------------
import spidev
import time
spi = spidev.SpiDev()
spi.open(0,0)
# SPI HOOKUP:
# -----------------+
# |
# PIX_VCC X |
# X X |
# X PIX_GND
# X X |
# X X |
# X X |
# X X |
# X X |
# X X |
# PIX_DAT X |
# X X |
# PIX_CLK X |
# X X |
# X X |
# X X |
# X X |
# X X |
# X X |
# X X |
# X X |
# |
# SPI Settings
spi.max_speed_hz = 10000 # increase or decrease speed if issues occur
spi.mode = 0b01 # clock polarity and phase
spi.no_cs = True # No CS pin needed
while True:
# Smiles
bytes = [
# Left display
0,255,0, # max brightness
16,38,32,38,16, # PIX_SMILE icon
# Right display
0,255,0, # max brightness
16,38,32,38,16 # PIX_SMILE icon
]
spi.writebytes(bytes)
time.sleep(0.05)
# Solid
bytes = [
# Left display
0,255,0, # max brightness
127,127,127,127,127, # Solid color
# Right display
0,255,0, # max brightness
127,127,127,127,127 # Solid color
]
spi.writebytes(bytes)
time.sleep(0.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment