def main(): global device device = led.matrix(2) device.orientation(270) try: ew = ExternalWeather() we = ew.weather_data t, h, w = ew.add_units(we) s = ''.join([str(we.time_of_entry[:5]),' Outside:',' ',t,' ',h,' ',w,' ',we.weather]) display_on_led_matrix(s) iw = InternalWeather() t, h = iw.add_units(iw.weather_data) s = ''.join([' Inside:',' ',t,' ',h]) display_on_led_matrix(s) time.sleep(0.8) for h in get_headlines(): display_on_led_matrix(h) time.sleep(1) except Exception as err: print(err) finally: device.clear()
def main(argv): remote = '' key = '' try: opts, args = getopt.getopt(argv,"hr:k:",["remote=","key="]) except getopt.GetoptError: print 'remote.py [-r <remote>] -k <key>' sys.exit(2) for opt, arg in opts: if opt == '-h': print 'remote.py [-r <remote>] -k <key>' sys.exit() elif opt in ("-r", "--remote"): remote = arg elif opt in ("-k", "--key"): key = arg device = led.matrix(cascaded=3) device.brightness(3) if(len(key) == 1): if (key.isdigit()): device.letter(0,ord(key)) else: device.show_message(key, font=proportional(CP437_FONT)) else: device.show_message(key, font=proportional(CP437_FONT)) time.sleep(0.5) device.clear()
def __init__(self, callback=None): RPIO.setmode(RPIO.BCM) RPIO.setup(self.button_pin, RPIO.IN, pull_up_down=RPIO.PUD_DOWN) self.matrix = led.matrix() if callback is not None: self.set_button_callback(callback) RPIO.wait_for_interrupts(threaded=True)
def fuc1(): while True: device = led.matrix(cascaded=1) rd=read_temp() con = str("%.2f" % rd)+"`C" #+"Time is "+str(datetime.datetime.now().time()) "%.2f" %" for TWO decimial point # print(con) #To display on the terminal # print(datetime.datetime.now().time()) device.show_message(con, font=proportional(CP437_FONT))
def main(): try: device = led.matrix(2) device.orientation(270) t = time.time() ctime = datetime.datetime.fromtimestamp(t).strftime('%H:%M') device.show_message(ctime) device.clear() except KeyboardInterrupt: device.clear()
def main(): try: device = led.matrix(2) device.orientation(270) device.brightness(int(bright_number)) if len(sys.argv) < 2: sys.exit(1) else: device.show_message(message) except KeyboardInterrupt: device.clear()
def __init__(self, path, log_items): self.device = led.matrix(cascaded=16,vertical=True) self.device.orientation(180) self.port = None self.sensorlist = [] localtime = time.localtime(time.time()) filename = path+"car-"+str(localtime[0])+"-"+str(localtime[1])+"-"+str(localtime[2])+"-"+str(localtime[3])+"-"+str(localtime[4])+"-"+str(localtime[5])+".log" self.log_file = open(filename, "w", 128) self.log_file.write("Time,RPM,MPH,Throttle,Load,Fuel Status\n"); for item in log_items: self.add_log_item(item) self.gear_ratios = [34/13, 39/21, 36/23, 27/20, 26/21, 25/22]
def __init__(self, nb = 1, brightness = 0, speed = 2, sleep_timeout = 600): '''Init the leds - nb : nb of cascaded led(s) - brightness : (0-15) (be careful, high level draw more current and may cause crashes) - speed : (1-5) the speed of scolling ''' self.dev = led.matrix(cascaded = nb) self.nb = nb self.dev.brightness(brightness) self.brightness = brightness self.dev.clear() self.speed=speed self.sleep_timeout = sleep_timeout self.sleep_time = sleep_timeout self.is_alive = True self.sleeper_th = threading.Thread(None, self.sleeper) self.sleeper_th.start()
def countdown(self): """ Display countdown on LED matrix, updatingn in 10 second intervals Determines video recording length :return: """ # Initialize display matrix = led.matrix() # Display message at beginning of recording. matrix.show_message("Seconds left:", font=proportional(CP437_FONT)) time.sleep(1) # Wait for message to display time_remaining = self.video_length while time_remaining > 0: matrix.show_message(str(time_remaining)) time_remaining -= 10 time.sleep(10)
def main(argv): remote = "" key = "" try: opts, args = getopt.getopt(argv, "hr:k:", ["remote=", "key="]) except getopt.GetoptError: print "remote.py [-r <remote>] -k <key>" sys.exit(2) for opt, arg in opts: if opt == "-h": print "remote.py [-r <remote>] -k <key>" sys.exit() elif opt in ("-r", "--remote"): remote = arg elif opt in ("-k", "--key"): key = arg device = led.matrix(cascaded=3) device.brightness(3) device.show_message(key, font=proportional(CP437_FONT)) time.sleep(1) device.clear()
class DMS_wrdck: device = led.matrix(cascaded=1) def blank(self): # blank - no hour displayed pass def one(self): # self.device.set_byte(0,4,0B00000111) self.device.pixel(7,4,1,0) self.device.pixel(6,4,1,0) self.device.pixel(5,4,1,0) def two(self): # self.device.set_byte(0,3,0B00000011) # self.device.set_byte(0,2,0B00000010) self.device.pixel(7,5,1,0) self.device.pixel(6,5,1,0) self.device.pixel(6,6,1,0) def three(self): # self.device.set_byte(0,4,0B11111000) self.device.pixel(4,4,1,0) self.device.pixel(3,4,1,0) self.device.pixel(2,4,1,0) self.device.pixel(1,4,1,0) self.device.pixel(0,4,1,0) def four(self): # self.device.set_byte(0,2,0B00001111) self.device.pixel(7,6,1,0) self.device.pixel(6,6,1,0) self.device.pixel(5,6,1,0) self.device.pixel(4,6,1,0) def five(self): # self.device.set_byte(0,2,0B11110000) self.device.pixel(3,6,1,0) self.device.pixel(2,6,1,0) self.device.pixel(1,6,1,0) self.device.pixel(0,6,1,0) def six(self): # self.device.set_byte(0,1,0B00000111) self.device.pixel(7,7,1,0) self.device.pixel(6,7,1,0) self.device.pixel(5,7,1,0) def seven(self): # self.device.set_byte(0,1,0B11111000) self.device.pixel(4,7,1,0) self.device.pixel(3,7,1,0) self.device.pixel(2,7,1,0) self.device.pixel(1,7,1,0) self.device.pixel(0,7,1,0) def eight(self): # self.device.set_byte(0,5,0B11111000) self.device.pixel(4,3,1,0) self.device.pixel(3,3,1,0) self.device.pixel(2,3,1,0) self.device.pixel(1,3,1,0) self.device.pixel(0,3,1,0) def nine(self): # self.device.set_byte(0,5,0B00001111) self.device.pixel(7,3,1,0) self.device.pixel(6,3,1,0) self.device.pixel(5,3,1,0) self.device.pixel(4,3,1,0) def ten(self): # self.device.set_byte(0,5,0B10000000) self.device.pixel(0,3,1,0) self.device.pixel(0,4,1,0) self.device.pixel(0,5,1,0) def eleven(self): # self.device.set_byte(0,3,0B11111100) self.device.pixel(5,5,1,0) self.device.pixel(4,5,1,0) self.device.pixel(3,5,1,0) self.device.pixel(2,5,1,0) self.device.pixel(1,5,1,0) self.device.pixel(0,5,1,0) def twelve(self): # self.device.set_byte(0,3,0B01111111) self.device.pixel(7,5,1,0) self.device.pixel(6,5,1,0) self.device.pixel(5,5,1,0) self.device.pixel(4,5,1,0) self.device.pixel(2,5,1,0) self.device.pixel(1,5,1,0) def oclock(self): # blank no minute displayed pass # pass is like nop in machine code def five_hr(self): # self.device.set_byte(0,7,0B00101011) # self.device.set_byte(0,6,0B01111000) self.device.pixel(7,1,1,0) self.device.pixel(6,1,1,0) self.device.pixel(4,1,1,0) self.device.pixel(2,1,1,0) def ten_hr(self): # self.device.set_byte(0,7,0B11010000) # self.device.set_byte(0,6,0B01111000) self.device.pixel(3,1,1,0) self.device.pixel(2,1,1,0) self.device.pixel(0,1,1,0) def fifteen(self): # self.device.set_byte(0,7,0B11110111) # self.device.set_byte(0,6,0B01111000) self.device.pixel(7,1,1,0) self.device.pixel(6,1,1,0) self.device.pixel(5,1,1,0) self.device.pixel(3,1,1,0) self.device.pixel(2,1,1,0) self.device.pixel(1,1,1,0) self.device.pixel(0,1,1,0) def twenty(self): # self.device.set_byte(0,8,0B11111100) # self.device.set_byte(0,6,0B01111000) self.device.pixel(5,0,1,0) self.device.pixel(4,0,1,0) self.device.pixel(3,0,1,0) self.device.pixel(2,0,1,0) self.device.pixel(1,0,1,0) self.device.pixel(0,0,1,0) def twenty5(self): # self.device.set_byte(0,8,0B11111100) # self.device.set_byte(0,7,0B00101011) # self.device.set_byte(0,6,0B01111000) self.device.pixel(5,0,1,0) self.device.pixel(4,0,1,0) self.device.pixel(3,0,1,0) self.device.pixel(2,0,1,0) self.device.pixel(1,0,1,0) self.device.pixel(0,0,1,0) self.device.pixel(7,1,1,0) self.device.pixel(6,1,1,0) self.device.pixel(4,1,1,0) self.device.pixel(2,1,1,0) def half(self): # self.device.set_byte(0,8,0B00000011) # self.device.set_byte(0,6,0B01111011) self.device.pixel(7,0,1,0) self.device.pixel(6,0,1,0) self.device.pixel(7,2,1,0) self.device.pixel(6,2,1,0) def past(self): self.device.pixel(4,2,1,0) self.device.pixel(3,2,1,0) self.device.pixel(2,2,1,0) self.device.pixel(1,2,1,0) def to(self): self.device.pixel(1,2,1,0) self.device.pixel(0,2,1,0) def ckdisp(self,mint,hour): # Perfor basic error check on variables if mint < 0 or mint > 59: return if hour < 0 or hour > 12: return # Clear the display first self.device.clear(0) # Convert minutes into 5 minute slots mint = float(mint) mint = mint / 5 tmp = math.modf(mint) if tmp[0] < 0.5: min = int(tmp[1]) else: min = int(tmp[1]+1) # add incrument 'hour' for >30 mins past the hour if min > 6: hour = hour +1 if hour == 13: hour = 1 # Bodge to keep display correct for the last 3 minutes before the hour # if min == 12: # min = 0 # compile past / to as need if min == 12: # Bodge to keep display correct for the last min = 0 # 3 minutes before the hour elif min == 0: # Bodge to keep display correct for the last pass # 3 minutes past the hour elif min < 7: # before half past display 'past' self.past() else: self.to() # otherwise display 'to' min = (6-(min-6)) # sort out 'min' offset for 'to' 5 minute slots # print "min lookup ",min # for debug only # Display miuntes past / to the hour in to nearest 5 minute 'slot' pointerm = [self.oclock,self.five_hr,self.ten_hr,self.fifteen,\ self.twenty,self.twenty5,self.half] pointerm[min]() # print "hour lookup ", hour # for debug only # Display the hours pointer = [self.blank,self.one,self.two,self.three,self.four,self.five,\ self.six,self.seven,self.eight,self.nine,self.ten,self.eleven,self.twelve] pointer[hour]() # update the output drivers self.device.flush()
#!/usr/bin/env python # -*- coding: utf-8 -*- import max7219.led as led import time import locale import Adafruit_DHT as dht DHT22_PIN = 4 SPI_DEVICE_NUMBER = 5 device = led.matrix(cascaded=SPI_DEVICE_NUMBER) device.brightness(1) locale.setlocale(locale.LC_ALL, '') try: while (True): humidity, temperature = dht.read_retry(dht.DHT22, DHT22_PIN) clock = time.strftime("%H:%M") minutes = int(time.strftime("%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: device.clear() device.show_message('Temp : ' + format(temperature, '.2f') + 'C')
#!/usr/bin/env python # -*- coding: utf-8 -*- import RPi.GPIO as GPIO # Con esta libreria, traemos las herramientas necesarias para poder utilizar las conexiones fisicas de K3OS import time # Con esta libreria, traemos las herramientas necesarias, para poder esperar una cantidad de tiempo determinada dentro de nuestro programa import max7219.led as Disp # con esta libreria, traemos las herramientas necesarias, para facilitar la comunicacion con la matriz #Configuramos los pines externos GPIO.setwarnings(False) # Deshabilitar la alertas de GPIO GPIO.setmode(GPIO.BCM) # Configuracion inicial de pines Matriz = Disp.matrix() # Inicializar matriz dat = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} while ( True ): # Este bloque se ejecutara de manera ciclica hasta que el programa sea detenido for x in dat: print(x) Matriz.show_message(x) time.sleep(1) Matriz.show_message("Hello world!") time.sleep(1)
import max7219.led as led matrix = led.matrix() matrix.brightness(5) matrix.orientation(0) matrix.show_message("Test text 001") matrix.letter(0, ord("1")) matrix.clear() matrix.clear()
import max7219.led as led from random import randint import time matrix = led.matrix(cascaded=4) # matrix = led.matrix() matrix.brightness(0) matrix.orientation(90) #deviceiD=1 #matrix.show_message("Display Ausgaben") #matrix.clear() #i = 1 #for i in range (1, 2): # matrix.show_message(str(i)) # time.sleep(1) #matrix.clear() #n = int(input("Zahl bitte: ")) #for n in range (1, n): # matrix.show_message(str(n)) # time.sleep(1) #matrix.clear()
from pad4pi import rpi_gpio import max7219.led as led from luma.core.interface.serial import spi, noop screen = led.matrix(cascaded=1) screen.clear()
def __init__(self): self.device = led.matrix(cascaded=4) self.device.brightness(2) self.displayOn = True
# test if .lock file exists and if yes, exit if os.path.isfile('test.lock'): print ('found lock file, will exit') sys.exit() else: print ('file test.lock does not exist') # and if we have results at all if os.path.isfile('test-output.json'): print ('found test-output.json, will process') else: print ('file test-output.json does not exist, will exit') sys.exit() # no running test, setup the rest device = led.matrix(cascaded=1) device.orientation(180) #device.show_message("MAX7219", font=proportional(CP437_FONT)) runFailed = False # check last test run with open('test-output.json') as data_file: data = json.load(data_file) for result in data['results']: runFailed = runFailed or (result['totalPassFailCounts']['fail'] > 0) # very simple logic for showing that script is alive tickFlag = 'l'
# -*- coding: utf-8 -*- # # RPi_SmartWatch_MAX7219 # Created by Jonatas Freitas - https://github.com/jonatasfreitasv # https://github.com/jonatasfreitasv/RPi_SmartWatch_MAX7219 # import datetime, time, urllib, json import max7219.led as led from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT from config import Config # Start LED Matrix with 2 modules device = led.matrix(cascaded=Config.display["total"]) device.brightness(Config.display["brightness"]) font = TINY_FONT # OpenWeather weather_city = Config.openWeather["locale"] weather_key = Config.openWeather["key"] weather_url = ("http://api.openweathermap.org/data/2.5/weather?q=%s&appid=%s" ) % (weather_city, weather_key) def main(): # Get weather data weather_data = urllib.urlopen(weather_url) weather_json = json.loads(weather_data.read())
#!/usr/bin/env python import max7219.led as led device = led.matrix(2) device.flush()
for k in range(8): matrix.pixel(k,j,0,False) def imprimeX(): limpaTela() l = 7; for i in range(8): matrix.pixel(i,i,1,False) if(i < 7): matrix.pixel(l,i,1,False) else: matrix.pixel(l,i,1) l = l-1 matrix = led.matrix() retorno = requests.get("http://10.1.2.30/almoco/CRT/ajax/travaCatraca.php") if retorno.status_code == 200 : retornoJSON = json.loads(retorno.content) if retornoJSON["catracaBloqueada"] == 1: GPIO.output(pin1, GPIO.LOW) if retornoJSON["isX"] == 1: imprimeX() else: GPIO.output(pin1, GPIO.HIGH) limpaTela() else: GPIO.output(pin1, GPIO.LOW)
#!/usr/bin/env python import os import max7219.led as led import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) #broadcom --value taken from bread board GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP) matrix = led.matrix() def getCPUtemperature(reading): p = str(input("Enter your name:")) i = 0 J = 1 while True: reading1 = GPIO.input(19) print(reading1) if (J == 1 and reading1 == 1): device.show_message(p) i = i + 2 elif (i > 1 and reading1 == 0): print("hello") J = 2 getCPUtemperature(reading) device = led.matrix(2) device.orientation(270) try: while True:
import symbols from socket import error as socket_error #import errno # debugging output import logging, mpd #logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.ERROR) import sys print(sys.version) print('connecting devices...') ### connect to LED matrix #device = led.matrix() # when using only one matrix device = led.matrix(cascaded=2) #device.brightness(15) device.orientation(180) ### connect to MPD client = mpd.MPDClient() # create client object host = "localhost" port = 6600 client.timeout = 10 # network timeout in seconds (floats allowed), default: None notConnected = True while notConnected: try: client.connect(host, port) print('connected.') notConnected = False
import websocket import time import json import max7219.led as led from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT import Queue from threading import Thread SERVER_URL = 'wss://localhost:5443' ACCESS_TOKEN = 'eyJhbGciOiJIUzI1...' SUBSCRIBE_TOPIC = 'cloud_matrix' GROUP_ID = 'cloud_matrix_client_0' queue = Queue.Queue() device = led.matrix(cascaded=4, vertical=True) def poll(): item = 'NO DATA' while True: try: item = queue.get(False) device.show_message(item, font=proportional(CP437_FONT)) queue.task_done() except Queue.Empty: device.show_message(item, font=proportional(CP437_FONT)) def authenticate(ws):
#!/usr/bin/env python # -*- coding: UTF-8 -*- import max7219.led as led import RPi.GPIO as GPIO import sys import time import serial import datetime import Adafruit_DHT from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT from random import randrange from time import sleep device = led.matrix(cascaded=20, spi_bus=0, spi_device=0) GPIO.setmode(GPIO.BCM) GPIO.setup(4, GPIO.OUT) GPIO.output(4, True) time_H_old = 0 time_M_old = 0 time_S_old = 0 ser = serial.Serial( port='/dev/ttyAMA0', baudrate = 9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0.5
def drive_to_next_col(): GPIO.output(19, True) for x in range (0,45): GPIO.output(26, True) time.sleep(speedSelect()) #time.sleep(0.005) GPIO.output(26, False) time.sleep(speedSelect()) #time.sleep(0.005) GPIO.output(19, False) cntrlr = matrix() cntrlr.clear() for col in cols: for index, val in enumerate(col): cntrlr.pixel(index // 8, 7 - (index % 8), val, False) cntrlr.pixel(index // 8, 7 - (index % 8), val, True) #time.sleep(0.3) #cntrlr.clear() drive_to_next_col() if sys.argv[2] == "r": os.system("sudo bin/python CLEANUP_image2bin_.py glowboard_blank.jpg l forcenight") #faehrt wieder nach links elif sys.argv[2] == "l": os.system("sudo bin/python CLEANUP_image2bin_.py glowboard_blank.jpg r forcenight") #faehrt wieder nach rechts cntrlr.clear()
return '%s%sC %s%sC %s-%sm/c' % (tMin, chr(0xF8), tMax, chr(0xF8), wMin, wMax) def download_fc(): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36', } r = requests.get('http://informer.gismeteo.ru/xml/34122.xml', headers=headers) return r.text device = led.matrix(cascaded=4, spi_bus=0, spi_device=0, vertical=True) while True: print "process new iteration" yandex = getYandexRootXML() gismeteo = getGismeteo() currentYandex = None if yandex != None: try: currentYandex = parseYandex(yandex) except: print "yandex parse err" print yandex gismeteRootNode = None
import websocket import time import json import max7219.led as led from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT import Queue from threading import Thread SERVER_URL = 'wss://localhost:5443' ACCESS_TOKEN = 'eyJhbGciOiJIUzI1...' SUBSCRIBE_TOPIC = 'cloud_matrix' GROUP_ID = 'cloud_matrix_client_0' queue = Queue.Queue() device = led.matrix(cascaded=4, vertical=True) def poll(): item = 'NO DATA' while True: try: item = queue.get(False) device.show_message(item, font=proportional(CP437_FONT)) queue.task_done() except Queue.Empty: device.show_message(item, font=proportional(CP437_FONT)) def authenticate(ws): data = {} data['event'] = 'auth'
import RPi.GPIO as gpio import time import max7219.led as led from random import randint gpio.setmode(gpio.BCM) taster = [14, 15, 18, 23] matrixe = 1 matrix = led.matrix(cascaded=matrixe) height = 7 width = (8 * matrixe) - 1 def steuerung(gpio): global richtung if (gpio == 14): #rechts richtung = [1, 0] elif (gpio == 15): #oben richtung = [0, -1] elif (gpio == 18): #unten richtung = [0, 1] elif (gpio == 23): #links richtung = [-1, 0] for i in taster: gpio.setup(i, gpio.IN, pull_up_down=gpio.PUD_UP) gpio.add_event_detect(i, gpio.FALLING, callback=steuerung) def startSpiel():
GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) button_left = 19 button_right = 20 button_up = 21 button_down = 26 GPIO.setup(button_left, GPIO.IN, GPIO.PUD_UP) GPIO.setup(button_right, GPIO.IN, GPIO.PUD_UP) GPIO.setup(button_up, GPIO.IN, GPIO.PUD_UP) GPIO.setup(button_down, GPIO.IN, GPIO.PUD_UP) GPIO.add_event_detect(button_left, GPIO.RISING, bouncetime=200) #rising edge detection GPIO.add_event_detect(button_right, GPIO.RISING, bouncetime=200) #rising edge detection GPIO.add_event_detect(button_up, GPIO.RISING, bouncetime=200) #rising edge detection GPIO.add_event_detect(button_down, GPIO.RISING, bouncetime=200) #rising edge detection GPIO.add_event_callback(button_left, button_pressed_left) #callback GPIO.add_event_callback(button_right, button_pressed_right) #callback GPIO.add_event_callback(button_up, button_pressed_up) #callback GPIO.add_event_callback(button_down, button_pressed_down) #callback device = led.matrix() #device.show_message("Hello world!") device.pixel(xpos,ypos,1) while True: continue
def __init__(self): self.device = LED.matrix() self.device.brightness(5)