Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomasw-mitutoyo-ctl/7d7af3269280941fc600b20c12d4456a to your computer and use it in GitHub Desktop.
Save thomasw-mitutoyo-ctl/7d7af3269280941fc600b20c12d4456a to your computer and use it in GitHub Desktop.
led matrix
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.legacy import text
from luma.core.legacy.font import LCD_FONT, proportional
from luma.led_matrix.device import max7219
from time import sleep
serial = spi(port=0, device=0, gpio=noop())
scoreboard = max7219(serial, cascaded=4, block_orientation=-90)
scoreboard.contrast(20)
for score in range(0, 2000, 10):
with canvas(scoreboard) as draw:
leading_zeros = (5 - len(str(score))) * "0"
text(draw, (0, 0), leading_zeros + str(score), fill="white", font=proportional(LCD_FONT))
sleep(.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment