issue_108.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!usr/bin/env python
  2. import time
  3. import argparse
  4. from luma.led_matrix.device import max7219
  5. from luma.core.interface.serial import spi, noop
  6. from luma.core.render import canvas
  7. from luma.core.legacy import text
  8. print('Press Ctrl-C to quit...')
  9. serial = spi(port=0, device=0, gpio=noop())
  10. device = max7219(serial, cascaded=5, block_orientation=0)
  11. currentLoop = 0
  12. if __name__ == "__main__":
  13. parser = argparse.ArgumentParser(description='matrix_demo arguments',
  14. formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  15. parser.add_argument('--cascaded', '-n', type=int, default=5, help='Number of cascaded MAX7219 LED matrices')
  16. parser.add_argument('--block-orientation', type=int, default=0, choices=[0, 90, -90], help='Corrects block orientation when wired vertically')
  17. args = parser.parse_args()
  18. while True:
  19. currentLoop = currentLoop + 1
  20. Tv = str(currentLoop)
  21. Tv = Tv.rjust(5, " ")
  22. with canvas(device) as draw:
  23. text(draw, (0, 0), Tv, fill="white")
  24. print(Tv)
  25. time.sleep(1)
  26. if currentLoop >= 99999:
  27. currentLoop = 0