#!/usr/bin/env python2 # -*- coding: utf-8 -*- from time import sleep, strftime import LEDMatrix from fonts import TINY_FONT from LEDMatrix import DIR_RD, DIR_L LEDMatrix.init() def tick(): while True: date = strftime('%a') + " " + strftime('%x') LEDMatrix.scroll_message_horiz([date], 1, 5, DIR_L, TINY_FONT) sleep(1) cycle = 1 while cycle < 80: H = strftime('%H') M = strftime('%M') S = strftime('%S') LEDMatrix.static_message(H+M+S, DIR_RD, 0, TINY_FONT) cycle += 1 sleep(0.5) def end(): LEDMatrix.clear_all() exit(0) try: tick()
#!/usr/bin/env python2 # -*- coding: utf-8 -*- from sys import argv from time import sleep import LEDMatrix from fonts import CP437_FONT, SINCLAIRS_FONT, LCD_FONT, TINY_FONT from LEDMatrix import DIR_L, DIR_R LEDMatrix.init() def scroll(text, cycles=1, speed=5): speed = float(speed) LEDMatrix.scroll_message_horiz([text + " "], cycles, speed, DIR_L, TINY_FONT) def end(): sleep(1) LEDMatrix.clear_all() exit(0) def usage(): print('\nTry: \n banner.py "your text" [cycles] [speed]') try: argv.pop(0)
import LEDMatrix import time import pickle import socket LEDMatrix.init("COM4") sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind(('127.0.0.1', 5005)) chord = [1, 6, 2, 5] chord_idx = 0 while True: received = sock.recv(1024) if len(received) > 0: data = pickle.loads(received) if data['instrument'] == 'harmony': LEDMatrix.send_update(0, data['chord'][1], data['chord'][0]) #print("Harmony data: {}".format(data['chord'])) elif data['instrument'] == 'bass': LEDMatrix.send_update(1, data['chord'][1], data['chord'][0]) #print("Bassline data: {}".format(data['chord'])) #elif data['instrument'] == 'melody': # LEDMatrix.send_update(2, (255, 255), [data['note'], 255, 255]) # print("Melody data: {}".format(data['note']))