Esempio n. 1
0
class Matrix:
	
	def __init__(self, height, chains):
		self.matrix = Adafruit_RGBmatrix(height, chains)
		self.MAX_Y = height
		self.MAX_X = height * chains
		self.obj_list = []
		self.setBG(0x000000)

	def setBG(self, hex_color):
		self.BG = hex_color
		self.drawBG()

	def setBoard(self, board_num, rgb):
		self.fillRect(board_num*self.MAX_Y, 0, board_num*self.MAX_Y + self.MAX_Y, self.MAX_Y, rgb)

	def drawBG(self):
		self.matrix.Fill(self.BG)

	def clear(self):
		self.matrix.Clear()

	def setPixel(self, x, y, rgb):
		self.matrix.SetPixel(x, y, *rgb)

	def fillRect(self, x1, y1, x2, y2, rgb):
		for x in range(x1, x2):
			for y in range(y1, y2):
				self.setPixel(x, y, rgb)

	def drawPointList(self, plist, rgb):
		for point in plist:
			self.setPixel(point[0],point[1], rgb)

	def drawImage(self, file_name):
		image = Image.open(file_name)
		raw = image.load()

		for x in range(0,30):
			for y in range(0,63):
				rgb = raw[y, x]
				if rgb == (0,0,0): #If you wanted to make the background another color
					self.setPixel(y,x, (0,0,0))
				else:
					self.setPixel(y, x, (rgb[0], rgb[1], rgb[2]))

	def refresh(self):
		self.drawBG()

		for obj in self.obj_list:
			obj.draw()

	def getMatrix(self):
		return self.matrix
Esempio n. 2
0
# Simple RGBMatrix example, using only Clear(), Fill() and SetPixel().
# These functions have an immediate effect on the display; no special
# refresh operation needed.
# Requires rgbmatrix.so present in the same directory.

import Image
import ImageDraw
import time
from rgbmatrix import Adafruit_RGBmatrix

# Rows and chain length are both required parameters:
matrix = Adafruit_RGBmatrix(32, 2)

# Flash screen red, green, blue (packed color values)
matrix.Fill(0xFF0000)
time.sleep(1.0)
matrix.Fill(0x00FF00)
time.sleep(1.0)
matrix.Fill(0x0000FF)
time.sleep(1.0)

# Show RGB test pattern (separate R, G, B color values)
for b in range(16):
    for g in range(8):
        for r in range(8):
            matrix.SetPixel((b / 4) * 8 + g, (b & 3) * 8 + r,
                            (r * 0b001001001) / 2, (g * 0b001001001) / 2,
                            b * 0b00010001)

time.sleep(10.0)
Esempio n. 3
0
            matrix.SetPixel(x + 3, y + 0, self.r, self.g, self.b)
            matrix.SetPixel(x + 0, y + 1, self.r, self.g, self.b)
            matrix.SetPixel(x + 4, y + 1, self.r, self.g, self.b)
            matrix.SetPixel(x + 0, y + 2, self.r, self.g, self.b)
            matrix.SetPixel(x + 4, y + 2, self.r, self.g, self.b)
            matrix.SetPixel(x + 1, y + 3, self.r, self.g, self.b)
            matrix.SetPixel(x + 2, y + 3, self.r, self.g, self.b)
            matrix.SetPixel(x + 3, y + 3, self.r, self.g, self.b)
            matrix.SetPixel(x + 4, y + 3, self.r, self.g, self.b)
            matrix.SetPixel(x + 4, y + 4, self.r, self.g, self.b)
            matrix.SetPixel(x + 0, y + 5, self.r, self.g, self.b)
            matrix.SetPixel(x + 4, y + 5, self.r, self.g, self.b)
            matrix.SetPixel(x + 1, y + 6, self.r, self.g, self.b)
            matrix.SetPixel(x + 2, y + 6, self.r, self.g, self.b)
            matrix.SetPixel(x + 3, y + 6, self.r, self.g, self.b)


if __name__ == "__main__":

    matrix = Adafruit_RGBmatrix(32, 2)

    font = Font()
    font.setColor(1, 255, 1)
    for i in range(10):
        for w in range(64):

            font.drawNumber(matrix, w, 0, i)
            time.sleep(0.02)
            matrix.Fill(0x000000)
    matrix.Clear()
Esempio n. 4
0
draw = ImageDraw.Draw(image)  # Declare Draw instance before prims
# Draw some shapes into image (no immediate effect on matrix)...
draw.rectangle((0, 0, 31, 31), fill=0, outline=1)
draw.line((0, 0, 31, 31), fill=1)
draw.line((0, 31, 31, 0), fill=1)
# Then scroll image across matrix...
for n in range(-32, 33):  # Start off top-left, move off bottom-right
    matrix.Clear()
    # IMPORTANT: *MUST* pass image ID, *NOT* image object!
    matrix.SetImage(image.im.id, n, n)
    time.sleep(0.05)

# 8-bit paletted GIF scrolling example
image = Image.open("cloud.gif")
image.load()  # Must do this before SetImage() calls
matrix.Fill(0x6F85FF)  # Fill screen to sky color
time.sleep(1)
for n in range(32, -image.size[0], -1):  # Scroll R to L
    matrix.SetImage(image.im.id, n, 0)
    time.sleep(0.025)

# 24-bit RGB scrolling example.
# The adafruit.png image has a couple columns of black pixels at
# the right edge, so erasing after the scrolled image isn't necessary.
matrix.Clear()
image = Image.open("adafruit.png")
image.load()
for n in range(32, -image.size[0], -1):
    matrix.SetImage(image.im.id, n, 1)
    time.sleep(0.025)
Esempio n. 5
0
draw = ImageDraw.Draw(image)  # Declare Draw instance before prims
# Draw some shapes into image (no immediate effect on matrix)...
draw.rectangle((0, 0, 31, 31), fill=0, outline=1)
draw.line((0, 0, 31, 31), fill=1)
draw.line((0, 31, 31, 0), fill=1)
# Then scroll image across matrix...
for n in range(-32, 60):  # Start off top-left, move off bottom-right
    matrix.Clear()
    # IMPORTANT: *MUST* pass image ID, *NOT* image object!
    matrix.SetImage(image.im.id, n, n)
    time.sleep(0.05)

# 8-bit paletted GIF scrolling example
image = Image.open("VDuedC0.png")
image.load()  # Must do this before SetImage() calls
matrix.Fill(0xffffff)  # Fill screen to sky color
for n in range(96, -image.size[0], -1):  # Scroll R to L
    matrix.SetImage(image.im.id, n, 0)
    time.sleep(0.025)

# 24-bit RGB scrolling example.
# The adafruit.png image has a couple columns of black pixels at
# the right edge, so erasing after the scrolled image isn't necessary.
matrix.Clear()

sprites = []

sprites.append(Image.open("megaman-sprites/1.png"))
sprites.append(Image.open("megaman-sprites/2.png"))
sprites.append(Image.open("megaman-sprites/3.png"))
sprites.append(Image.open("megaman-sprites/4.png"))
Esempio n. 6
0
# Rows and chain length are both required parameters:
matrix = Adafruit_RGBmatrix(32, 1)
matrix.SetWriteCycles(4)
# Bitmap example w/graphics prims
image = Image.new("RGB", (32, 32)) # Can be larger than matrix if wanted!!
draw = ImageDraw.Draw(image)
#color = PIL.ImageColor.rgb(0,0,255)
draw.rectangle((0,0,31,31),fill=(0,255,255),outline=1)
draw.line((0,0,31,31),fill=1)
matrix.SetImage(image.im.id,0,0)
time.sleep(2.0)
print "---------------"
matrix.Clear()
image = Image.open("circle_gif.gif")
image.load()
matrix.Fill((0,0,255))
image0 = Image.new("RGB", (32,32))
image1 = Image.new("RGB", (32,32))
image2 = Image.new("RGB", (32,32))

image0 = Image.open("Targeting1.png")
image0.load()
image1 = Image.open("Targeting2.png")
image1.load()
image2 = Image.open("Targeting3.png")
image2.load()


delay = 0.2
count = 0
while count < 10:
Esempio n. 7
0
matrix = Adafruit_RGBmatrix(32, 1)

#Fill screen red (packed color value)
#matrix.Fill(0xFF0000)
#pause (1 sec - i think)
time.sleep(1.0)

#clear matrix
matrix.Clear()

#SetPixel(x,y,r,g,b)
#matrix.SetPixel(4,4,255,0,0)
#matrix.SetPixel(5,4,0,255,0)
#matrix.SetPixel(6,4,0,255,255)
#time.sleep(1.0)
matrix.Fill(0xFFFFFF)
time.sleep(2)
#matrix.Clear()
matrix.SetPixel(0, 0, 255, 0, 0)
matrix.SetPixel(0, 10, 0, 0, 0)
matrix.Clear()
time.sleep(0.025)
matrix.SetPixel(0, 10, 0, 255, 0)
matrix.SetPixel(10, 0, 0, 0, 255)
matrix.SetPixel(20, 20, 255, 255, 255)
time.sleep(4)
matrix.Clear()
pixr = numpy.zeros((32, 32))
pixr[:][:] = 0
pixg = numpy.zeros((32, 32))
pixg[:][:] = 255
Esempio n. 8
0
import os
import Image
import ImageDraw
from time import sleep
from io import BytesIO
from picamera import PiCamera
from rgbmatrix import Adafruit_RGBmatrix

camera = PiCamera()
camera.resolution = (320, 240)
camera.vflip = True
camera.start_preview()

# Rows and chain length are both required parameters:
matrix = Adafruit_RGBmatrix(32, 1)
matrix.Fill(0x6F85FF)  # Fill screen with color
sleep(2)


def showImg():
    stream = BytesIO()
    camera.capture(stream, resize=(43, 32), format='jpeg')
    stream.seek(0)
    image = Image.open(stream)
    image.load()  # Must do this before SetImage() calls
    matrix.SetImage(image.im.id, -10, 0)
    image.close()


var = 0
while var < 4800: