def __init__(self):
     # Initialise library
     LEDMatrix.init()
     # Clear the whole display
     LEDMatrix.clear_all()
     # Reset brightness
     LEDMatrix.brightness(3)
Пример #2
0
 def __init__(self, state, flag):
     self.state = state
     self.flag = flag
     # Initialise library
     LEDMatrix.init()
     # Clear the whole display
     LEDMatrix.clear_all()
     # Reset brightness
     LEDMatrix.brightness(3)
Пример #3
0
def display_messages(messages):
    LEDMatrix.init()
    try:
        LEDMatrix.brightness(3)
        LEDMatrix.scroll_message_horiz([messages])
        LEDMatrix.clear_all()
    except KeyboardInterrupt:
        LEDMatrix.scroll_message_horiz(["", "Have a good PyDay!", ""], 1, 8)
    LEDMatrix.clear_all()
Пример #4
0
from random import randrange
import serial, string, time
import MySQLdb

# Import library
import multilineMAX7219 as LEDMatrix
# Import fonts
from multilineMAX7219_fonts import CP437_FONT, SINCLAIRS_FONT, LCD_FONT, TINY_FONT

# The following imported variables make it easier to feed parameters to the library functions
from multilineMAX7219 import DIR_L, DIR_R, DIR_U, DIR_D
from multilineMAX7219 import DIR_LU, DIR_RU, DIR_LD, DIR_RD
from multilineMAX7219 import DISSOLVE, GFX_ON, GFX_OFF, GFX_INVERT

# Initialise the library and the MAX7219/8x8LED arrays
LEDMatrix.init()
ser = serial.Serial('/dev/ttyUSB0', 9600, 8, 'N', 1, timeout=1)
db = MySQLdb.connect("localhost", "root", "104403011", "sensorData")
cur = db.cursor()
cur.execute(
    "SELECT mq2,mq7,mq131,mq135,mq136,pm1,pm25,pm10 FROM sensorData.systemdata"
)


def warn():
    a = 0
    b = 1
    sad = [[b, b, b, b, b, b, b, b], [b, a, b, b, b, b, b, b],
           [b, b, a, b, b, a, b, b], [b, b, a, b, b, b, b, b],
           [b, b, a, b, b, b, b, b], [b, b, a, b, b, a, b, b],
           [b, a, b, b, b, b, b, b], [b, b, b, b, b, b, b, b]]
Пример #5
0
DIR_L = Point(-1,0)

# Make sure you set these correct in multilineMAX7219.py
WIDTH = 8*LEDMatrix.MATRIX_WIDTH-1
HEIGHT = 8*LEDMatrix.MATRIX_HEIGHT-1

tail = [Point(WIDTH//2, HEIGHT//2)]
start = randrange(2)
direction = Point(start, 1 - start)	# init direction

target = Point()
running = True			# loop variable
speed = 0.3				# getting faster, the longer the snake is
wasDisplayed = True		# to allow only one new direction per frame

LEDMatrix.init()


def display():
	# displays all on the LED Matrices
	LEDMatrix.gfx_set_all(GFX_OFF)
	for p in tail:
		LEDMatrix.gfx_set_px(int(p.x), int(p.y), GFX_ON)
	LEDMatrix.gfx_set_px(int(target.x), int(target.y), GFX_ON)
	LEDMatrix.gfx_render()
	global wasDisplayed
	wasDisplayed = True

def setTarget():
	# sets a new target, which is not in the tail of the snake
	global target