Скрипт под старую библиотеку Max7219 и в новой отказывается работать.
Я попытался его исправить но не получилось. Получаю ошибку.
pi@raspberrypi:~ $ python timedate.py
Traceback (most recent call last):
File "timedate.py", line 29, in <module>
device.letter(n, ord(c))
AttributeError: 'max7219' object has no attribute 'letter'
pi@raspberrypi:~ $
#!/usr/bin/env python # name = "timedate", import max7219.led as led import datetime import time from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT from random import randrange device = led.matrix(cascaded=4) device.orientation(90) device.brightness(1) while(True): clock = time.strftime("%H%M") seconds = int(time.strftime("%S")) month = time.strftime(" %m") day = time.strftime(" %d") year = time.strftime("%Y") for n, c in enumerate(clock): device.letter(n, ord(c)) if seconds == 59 : for row in range(8): device.scroll_up() time.sleep(0.1) for n, c in enumerate(month): device.letter(n, ord(c)) time.sleep(1) for row in range(8): device.scroll_down() time.sleep(0.1) for n, c in enumerate(day): device.letter(n, ord(c)) time.sleep(1) for row in range(8): device.scroll_down() time.sleep(0.1) for n, c in enumerate(year): device.letter(n, ord(c)) time.sleep(1) for row in range(8): device.scroll_down() time.sleep(0.1) #device.show_message(time.strftime("%b %d %Y"))
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2017-18 Richard Hull and contributors # See LICENSE.rst for details. import re import sys import datetime import time import argparse from luma.led_matrix.device import max7219 from luma.core.interface.serial import spi, noop from luma.core.render import canvas from luma.core.virtual import viewport from luma.core.legacy import text, show_message from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT serial = spi(port=0, device=0, gpio=noop()) device = max7219(serial, cascaded=4, block_orientation=-90) while(True): clock = time.strftime("%H%M") seconds = int(time.strftime("%S")) month = time.strftime(" %m") day = time.strftime(" %d") year = time.strftime("%Y") for n, c in enumerate(clock): device.letter(n, ord(c)) if seconds == 59 : for row in range(8): device.scroll_up() time.sleep(0.1) for n, c in enumerate(month): device.letter(n, ord(c)) time.sleep(1) for row in range(8): device.scroll_down() time.sleep(0.1) for n, c in enumerate(day): device.letter(n, ord(c)) time.sleep(1) for row in range(8): device.scroll_down() time.sleep(0.1) for n, c in enumerate(year): device.letter(n, ord(c)) time.sleep(1) for row in range(8): device.scroll_down() time.sleep(0.1) device.show_message(time.strftime("%b %d %Y"))