def display_scroll_char(char, matrix): temp = int(char) for n in range(8): for i in range(8): MAX7219array.send_matrix_reg_byte(matrix, i+1, numbers[temp][i]*2**n) time.sleep(0.1) MAX7219array.clear_all()
def scroll_letter(letter, matrix): for i in range(len(characters)): if characters[i][1] == letter: print(str(letter) + ' is ' + str(characters[i][0])) for n in range(8): for j in range(8): MAX7219array.send_matrix_reg_byte(matrix, j+1, characters[i][0][j]*2**n) time.sleep(0.1) MAX7219array.clear_all()
def scroll_letter_LR(letter): for i in range(len(characters)): if characters[i][1] == letter: print(str(letter) + ' is ' + str(characters[i][0])) for n in range(16): for j in range(8): MAX7219array.send_matrix_reg_byte(1, j+1, characters[i][0][j]*2**n) if characters[i][0][j]*2**n >128: nextDisplay = characters[i][0][j]*2**n/256 MAX7219array.send_matrix_reg_byte(0, j+1, nextDisplay) time.sleep(0.1) MAX7219array.clear_all()
def scroll_letter_RL(letter): for i in range(len(characters)): if characters[i][1] == letter: print(str(letter) + ' is ' + str(characters[i][0])) for n in range(16): for j in range(8): thing = characters[i][0][j] thingf = float(thing) valf = float(thingf/2**n) lower = valf - int(valf) MAX7219array.send_matrix_reg_byte(0, j+1, int(valf)) MAX7219array.send_matrix_reg_byte(1, j+1, int(lower*256)) time.sleep(0.1) MAX7219array.clear_all()
def show_time(): print(time.strftime('%H:%M')) hour = time.strftime('%H') minu = time.strftime('%M') display(hour[0], 1) display(hour[1], 0) time.sleep(0.5) MAX7219array.clear_all() time.sleep(0.1) display_scroll_char(10, 1) #: is 10 in chars display_scroll_char(10, 0) #: is 10 in chars display(minu[0], 1) display(minu[1], 0) time.sleep(0.5) MAX7219array.clear_all()
from MAX7219fonts import CP437_FONT, SINCLAIRS_FONT, LCD_FONT, TINY_FONT # The following imported variables make it easier to feed parameters to the library functions from MAX7219array import DIR_L, DIR_R, DIR_U, DIR_D from MAX7219array import DIR_LU, DIR_RU, DIR_LD, DIR_RD from MAX7219array import DISSOLVE, GFX_ON, GFX_OFF, GFX_INVERT # Initialise the library and the MAX7219/8x8LED array m7219.init() try: # Display a stationary message m7219.static_message("Welcome!") time.sleep(2) m7219.clear_all() # Cycle through the range of brightness levels - up then down m7219.brightness(0) m7219.static_message("Bright ?") for loop in range(2): for brightness in range(15*(loop%2), 16-17*(loop%2), 1-2*(loop%2)): m7219.brightness(brightness) time.sleep(0.1) time.sleep(1) # Clear the whole display and reset brightness m7219.clear_all() m7219.brightness(3) time.sleep(1)
#!/usr/bin/env python import MAX7219array as m7219 from MAX7219fonts import CP437_FONT, SINCLAIRS_FONT, LCD_FONT, TINY_FONT from MAX7219array import DIR_L, DIR_R, DIR_U, DIR_D import sys import time import fileinput if len(sys.argv) == 1: for line in sys.stdin: m7219.init() m7219.brightness(1) m7219.scroll_message_horiz(line.rstrip(), 1, 8, DIR_L, CP437_FONT) m7219.clear_all() #print(line) sys.exit(0) print sys.argv m7219.init() prev = '' for word in sys.argv[1:]: #print word m7219.scroll_message_vert(prev, word, direction=1) prev = word
([54, 127, 127, 107, 99, 0, 0, 0],'w'), #w ([99, 54, 28, 54, 99, 0, 0, 0],'x'), #x ([31, 48, 62, 51, 51, 51, 0, 0],'y'), #y ([63, 38, 12, 25, 63, 0, 0, 0],'z') #z ] #255 is maximum per row try: running_dot() #running_dot() # MAX7219array.send_matrix_reg_byte(0, 1, int('10101010', 2)) time.sleep(1) MAX7219array.clear_all(); test = 'hello' for i in range(len(test)): scroll_letter_RL(test[i]) #-- Clock on repeat -- #while True: # show_time() # time.sleep(5) MAX7219array.clear_all() except KeyboardInterrupt: MAX7219array.clear_all()