Ejemplo n.º 1
0
class drawing_app_matrix:
    def __init__(self):
        # Initialize LED Matrix
        self.matrix = Adafruit_RGBmatrix(32, 1)

    def main(self, arg1, arg2):
        self.matrix.Clear()

        #   INPUT
        pix = arg1
        rainbow = arg2
        #   end INPUT

        #print_to_matrix_default(canvas_pix)
        if rainbow:
            for x in range(0, 32):
                for y in range(0, 32):
                    if pix[x][y] == 1:
                        self.matrix.SetPixel(x, y, randint(0, 255),
                                             randint(0, 255), randint(0, 255))
        else:
            for x in range(0, 32):
                for y in range(0, 32):
                    if pix[x][y] == 1:
                        self.matrix.SetPixel(x, y, 255, 0, 0)

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

    if __name__ == "__main__":
        main(sys.argv[1], sys.argv[2])
Ejemplo n.º 2
0
class input_triggered_matrix:

    def __init__(self):
        # Initialize LED Matrix
        self.matrix = Adafruit_RGBmatrix(32, 1)

    def main(self, arg1, arg2):
        #   INPUT
        word = arg1
        score = arg2
        #   end INPUT
    
        # Initialize canvas
        canvas_pix = numpy.zeros((32, 32))
    
        # Word input -> canvas
        canvas_pix = overlayAt(1, 4, stringtopix(word), canvas_pix, 1)
    
        # Scoreboard -> canvas
        canvas_pix = overlayAt(1, 16, stringtopix("Score:"), canvas_pix, 1)
    
        # Score input -> canvas
        canvas_pix = overlayAt(1, 24, stringtopix(str(score)), canvas_pix, 1)
    
    #    print_to_matrix_default(canvas_pix)
        for x in range(0,32):
            for y in range(0,32):
                if canvas_pix[x][y] == 1:
                    self.matrix.SetPixel(x,y,255,0,0)
#        time.sleep(1.0)
#        matrix.Clear()

    def clear_matrix(self):
        self.matrix.Clear()
    
    def clear_word(self,score):
        # Initialize canvas
        canvas_pix = numpy.zeros((32, 32))
 
        # Word input -> canvas
        #canvas_pix = overlayAt(1, 4, stringtopix(word), canvas_pix, 1)

        # Scoreboard -> canvas
        canvas_pix = overlayAt(1, 16, stringtopix("Score:"), canvas_pix, 1)

        # Score input -> canvas
        canvas_pix = overlayAt(1, 24, stringtopix(str(score)), canvas_pix, 1)

    #    print_to_matrix_default(canvas_pix)
        for x in range(0,32):
            for y in range(0,32):
                if canvas_pix[x][y] == 1:
                    self.matrix.SetPixel(x,y,255,0,0)


    if __name__ == "__main__":
        main(sys.argv[1], sys.argv[2])
Ejemplo n.º 3
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
Ejemplo n.º 4
0
import string
import time
from rgbmatrix import Adafruit_RGBmatrix
from shapes import *

# Rows and chain length are both required parameters:
matrix = Adafruit_RGBmatrix(32, 1)
time.sleep(2.0)
matrix.Clear()
#shapes- rect test
square_fill = rect(5, 7, 0)
square_empt = rect(5, 7, 1)
#for row in square_empt:
#    for val in row:
#        print '{:4}'.format(val)
#    print
test_screen0 = displayAt(0, 0, square_fill)
test_screen1 = displayAt(0, 7, square_empt)

for i in range(0, 32):
    for j in range(0, 32):
        if test_screen0[i][j] == 1:
            matrix.SetPixel(i, j, 255, 0, 0)
        elif test_screen1[i][j] == 1:
            matrix.SetPixel(i, j, 0, 0, 255)
        else:
            matrix.SetPixel(i, j, 0, 0, 0)

time.sleep(5.0)
matrix.Clear()
Ejemplo n.º 5
0
# 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)
matrix.Clear()
Ejemplo n.º 6
0
import time
from rgbmatrix import Adafruit_RGBmatrix

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

# 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)
matrix.Fill(0x000000)
# Show RGB test pattern (separate R, G, B color values)
matrix.SetPixel(0,0,255,0,0)
time.sleep(1)
matrix.SetPixel(10,10,0,255,0)
time.sleep(1)
matrix.SetPixel(40,40,0,0,255)
time.sleep(1)
matrix.SetPixel(60,60,255,255,0)
time.sleep(1)

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,
Ejemplo n.º 7
0
print int(pixb[31][31])
#for n in range(32, -image.size[0], -1):
#    matrix.SetImage(image.im.id,0,0)
#    time.sleep(0.025)
time.sleep(4.0)
matrix.Clear()
for x in range(0, 32):
    for y in range(0, 32):
        r = int(pixr[x][y] / 3)
        g = int(pixg[x][y] / 2)
        b = int(pixb[x][y] / 2)
        if r > 0:
            temp = 1
        else:
            temp = 0
        matrix.SetPixel(x, y, r, g, b)
#        matrix.SetPixel(x,y,0,255,0)
#        matrix.SetPixel(x,y,0,0,255)
#        matrix.SetPixel(x,y,int(pixr[x][y]/3+(temp*50)),int(pixg[x][y]),int(pixb[x][y]))
#        time.sleep(0.0025)
time.sleep(5.0)
'''
def img_to_pix(filename):
    matrix = Adafruit_RGBmatrix(32,1)
    im = Image.open("Targeting1.png")
    im_pix = im.load()
    pixr = numpy.zeros((32,32))
    pixg = numpy.zeros((32,32))
    pixb = numpy.zeros((32,32))
    for x in range(0,32):
        for y in range(0,32):
Ejemplo n.º 8
0
class ThreadingExample(object):
    """ Threading example class
    The run() method will be started and it will run in the background
    until the application exits.
    """
    def __init__(self, interval=3):
        """ Constructor
        :type interval: int
        :param interval: Check interval, in seconds
        """
        self.interval = interval
        self.channel_data = dict()
        self.histogram_data = list()
        self.showlight = False
        for i in chanlookup:
            self.channel_data[i] = dict()
        # Rows and chain length are both required parameters:
        if args.nolights is False: self.matrix = Adafruit_RGBmatrix(16, 1)
        # use a bitmap font
        if args.nolights is False:
            self.font = ImageFont.load("rpi-rgb-led-matrix/fonts/4x6.pil")
        if args.nolights is False:
            self.font2 = ImageFont.load("rpi-rgb-led-matrix/fonts/5x7.pil")
        thread = threading.Thread(target=self.run, args=())
        thread.daemon = True  # Daemonize thread
        thread.start()  # Start the execution

    def run(self):
        """ Method that runs forever """
        counter = 0
        switchval = 1
        while True:
            if self.showlight is True:
                if args.ratio is False:
                    self.flash_state_summary()
                else:
                    if switchval == 1:
                        self.ratio_summary()
                    elif switchval == 2:
                        self.histogram_summary()
                    else:
                        self.flash_state_summary()
            #if args.verbose is True:
            if args.verbose is True: print self.get_state_summary()
            if args.verbose is True: print time.time()
            time.sleep(0.5)
            counter += 1
            if (counter / switchval) >= 20:
                if switchval == 1:
                    switchval = 2
                elif switchval == 2:
                    switchval = 3
                else:
                    switchval = 1
                counter = 0
            pass

    def histogram_summary(self):
        if args.nolights is False:
            scaled_hist = scale16(proc_hist_3(self.histogram_data))
            self.matrix.Clear()
            for idx, val in enumerate(scaled_hist):
                #print(idx, val)
                for i in range(15):
                    if i + 1 <= val:
                        self.point(idx, 16 - (i + 1), 50, 50, 200)
                    else:
                        self.point(idx, 16 - (i + 1), 0, 0, 0)

    def ratio_summary(self):
        summary = self.get_state_summary()
        strand = 0
        single = 0
        if "strand" in summary.keys():
            strand = int(summary["strand"])
        if "good_single" in summary.keys():
            single = int(summary["good_single"])
            print "Seen Good Single", single
        total = strand + single
        if strand == 0:
            percentage = 0
        else:
            percentage = (strand / total) * 100
        perc = "%.1f" % percentage
        texttowrite1 = str(strand) + "/" + str(total)
        texttowrite2 = str(perc) + "%"
        color1 = "blue"
        color2 = "blue"
        if perc <= 90.0: color2 = "red"
        if strand <= 256: color1 = "red"
        self.write_text_inst_two(str(texttowrite1), color1, str(texttowrite2),
                                 color2)

    def write_text_inst_two(self, message1, color1, message2, color2):
        if args.nolights is False:
            image = Image.new("1", (320, 200))
            image = image.convert("RGBA")
            draw = ImageDraw.Draw(image)
            draw.text((0, 0), message1, font=self.font, fill=color1)
            draw.text((0, 9), message2, font=self.font2, fill=color2)
            self.matrix.Clear()
            self.matrix.SetImage(image.im.id, 1, 0)

    def flash_state_summary(self):
        for key, value in self.channel_data.items():
            #print key,value
            (r, g, b) = (0, 0, 0)
            try:
                (r, g, b) = colourlookup[value["state"]]
            except:
                pass
            (x, y) = chanlookup[int(key)]
            self.point(x, y, r, g, b)

    def get_state_summary(self):
        state_dict = dict()
        for key, value in self.channel_data.items():

            #print value,type(value)
            try:
                if value["state"] in state_dict:
                    state_dict[value["state"]] += 1
                else:
                    state_dict[value["state"]] = 1
            except:
                pass
            #print(key, len([item for item in value if item]))
        return state_dict

    def logitem(self, channel, state):
        self.channel_data[channel]["state"] = state

    def point(self, x, y, r, g, b):
        if args.nolights is False:
            if args.brightness is True:
                self.matrix.SetPixel(x, y, int(r / 3), int(g / 3), int(b / 3))
            else:
                self.matrix.SetPixel(x, y, r, g, b)
        else:
            if args.verbose is True:
                print "would do:", x, y, r, g, b

    def write_text_inst(self, message, color):
        if args.nolights is False:
            image = Image.new("1", (320, 200))
            image = image.convert("RGBA")
            draw = ImageDraw.Draw(image)
            draw.text((0, 0), message, font=self.font, fill=color)
            self.matrix.Clear()
            self.matrix.SetImage(image.im.id, 1, 0)

    def write_text(self, message, color, showtime):
        if args.nolights is False:
            image = Image.new("1", (320, 200))
            image = image.convert("RGBA")
            draw = ImageDraw.Draw(image)
            draw.text((0, 0), message, font=self.font, fill=color)
            self.matrix.Clear()
            self.matrix.SetImage(image.im.id, 1, 0)
            time.sleep(showtime)
            self.matrix.Clear()

    def write_time(self, color):
        if args.nolights is False:
            timestring = time.strftime("%H:%M:%S", time.gmtime())
            image = Image.new("1", (320, 200))
            image = image.convert("RGBA")
            draw = ImageDraw.Draw(image)
            draw.text((0, 0), timestring, font=self.font, fill=color)
            #self.matrix.Clear()
            self.matrix.SetImage(image.im.id, 0, 0)
Ejemplo n.º 9
0
class Transmitter:

    def __init__(self, version, qrECC, linkID,duration):
        self.linkID = linkID
        self.matrix = Adafruit_RGBmatrix(32,1)
        self.currentID = 0
        self.version = version
        self.qrECC = qrECC
        self.qrSize = int(QR_DICTIONARIES.VERSION_SIZE[version])
        self.dict = self.__selectDict__(qrECC)
        self.startTime = time()
        self.duration = duration

##        self.__startTransmitter__()

    def __startTransmitter__(self, queue):
        print("Transmitter Started")
        self.homeScreen(3)
        self.__transmit__(queue)
        sleep(.2)
        self.homeScreen(3)

    def __transmit__(self, queue):
        self.homeScreen(0)
        cont = self.checkTime()
        while cont == True:
            cont = self.checkTime()
            try:
                packet = queue.pop(0)
                print("Transmitting: ",packet)
                self.matrix.Clear()
                prep = EncodeFrame.EncodeFrame(packet, self.version, self.qrECC, self.qrSize, self.currentID, self.linkID, self.matrix)
                prep.sendPacket()
                self.__incrementID__()
                self.homeScreen(0)
                

            except:
                pass

    def checkTime(self):
        now = time()
        if self.duration > (now - self.startTime):
            return True
        else:
            return False


    def __incrementID__(self):
        if self.currentID >= 255:
            self.currentID = 0
        else:
            self.currentID += 1
 
    def __selectDict__(self, qrECC):
        """Determines capacity dictionary to use for error correction level."""


        if qrECC == "L":
            self.dict = QR_DICTIONARIES.QR_DICT_L
        elif qrECC == "M":
            self.dict = QR_DICTIONARIES.QR_DICT_M
        elif qrECC == "Q":
            self.dict = QR_DICTIONARIES.QR_DICT_Q
        elif qrECC == "H":
            self.dict = QR_DICTIONARIES.QR_DICT_H
        else:
            print("Error: Invalid Error Correction Level selected.")
            pass
        return self.dict

    def homeScreen(self, duration):

        for i in range(32):
            if i%2 == 1:
                
                for j in range(32):
                    if j%2 == 1:
                        self.matrix.SetPixel(i, j,0, 0, 200)
                    else:
                        self.matrix.SetPixel(i, j, 0, 0, 0)
            else:
                for j in range(32):
                    if j%2 == 0:
                        self.matrix.SetPixel(i, j,0, 0, 200)
                    else:
                        self.matrix.SetPixel(i, j, 0, 0, 0)
        if duration != 0:
            sleep(duration)
            self.matrix.Clear()
Ejemplo n.º 10
0
import numpy
import time
from random import randint
from rgbmatrix import Adafruit_RGBmatrix
#from random import randint

matrix = Adafruit_RGBmatrix(32,1)

x = numpy.zeros((50))
y = numpy.zeros((50))
r = numpy.zeros((50))
g = numpy.zeros((50))
b = numpy.zeros((50))
for s in range(0,100): 
    for i in range(0,50):
        x[i] = randint(0,31)
        y[i] = randint(0,31)
        r[i] = randint(1,255)
        g[i] = randint(1,255)
        b[i] = randint(1,255)
        matrix.SetPixel(int(x[i]),int(y[i]),int(r[i]),int(g[i]),int(b[i]))
        time.sleep(0.0025)
    matrix.Clear()
    #time.sleep(1)
    
#for j in range(0,50):
#    matrix.SetPixel(x[j],y[j],r[j],g[j],b[j])
#    time.sleep(1)
Ejemplo n.º 11
0
#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
pixb = numpy.zeros((32, 32))
pixb[:][:] = 255
for x in range(0, 32):
Ejemplo n.º 12
0
#addr = rpc_connection.getnewaddress()
addr = 'L45S4EjxBtD9He53GxqCvVPjk7NpU83PYVJgUVM7xqbLRVju9rTc'
code = pyqrcode.create(addr, error='L', version=3)
t = code.text(1)

print addr

print t

row = 31
col = 0

for i in t:
	if i != '\n':
		matrix.SetPixel(row, col, 255-int(i)*255, 255-int(i)*255, 255-int(i)*255)
		col += 1
	else:
		row -= 1
		col = 0
	
	time.sleep(0.001)

time.sleep(3)



def showQR():
	global rpc_connection
	print "Loading 2nd bitcoin address..."
Ejemplo n.º 13
0
class Transmitter:
    def __init__(self, version, qrECC, linkID, duration, speed):
        """Contructor"""
        self.linkID = linkID
        self.matrix = Adafruit_RGBmatrix(32, 1)
        self.currentID = 0
        self.version = version
        self.versionLength = QR_DICTIONARIES.VERSION_SIZE[version]
        self.qrECC = qrECC
        self.qrSize = self.__selectDict__(qrECC)
        self.speed = speed
        self.startTime = time()
        self.duration = duration
        self.packetsSent = 0
        self.bytesSent = 0
        self.qrsSent = 0

##        self.__startTransmitter__()

    def __startTransmitter__(self, queue):
        """Initializes the LED matrix with a basic pattern to assist receiver in
        adjusting to glare."""
        print("Transmitter Started")
        self.homeScreen(6)
        self.__transmit__(queue)
        sleep(.2)
        self.homeScreen(3)

    def __transmit__(self, queue):
        """Transmits network packets that are contained in the share memory queue."""
        self.homeScreen(0)
        print("Transmitting")
        cont = self.checkTime(
        )  #used for testing.  sets total transmit time of trial
        while cont == True:
            cont = self.checkTime()
            try:
                packet = queue.pop(0)
                print("Transmitting: ", packet)
                ##                self.matrix.Clear()
                prep = EncodeFrame.EncodeFrame(packet, self.version,
                                               self.qrECC, self.qrSize,
                                               self.currentID, self.linkID,
                                               self.matrix, self.speed)
                self.packetsSent += 1
                self.bytesSent += (len(packet) / 2)
                self.qrsSent += prep.sendPacket()
                self.__incrementID__()  #gets new PID for next packet
                if len(queue) == 0:
                    self.homeScreen(0)

            except:
                self.homeScreen(0)
        print("Finished Transmission")
        print(
            str(self.packetsSent) + " packets sent (" + str(self.bytesSent) +
            " bytes) in " + str(self.duration) + " seconds.")
        rate = self.bytesSent / self.duration
        print(str(rate) + " Bps")
        print(str(self.qrsSent) + " Frames Sent")

    def checkTime(self):
        """used for testing.  limits trial transmit time to a defined length to prevent overheading
        of RPi."""
        now = time()
        if self.duration > (now - self.startTime):
            return True
        else:
            return False

    def __incrementID__(self):
        """Increments packet ID."""
        if self.currentID >= 255:
            self.currentID = 0
        else:
            self.currentID += 1

    def __selectDict__(self, qrECC):
        """Determines capacity dictionary to use for error correction level."""

        if qrECC == "L":
            return QR_DICTIONARIES.QR_DICT_L[self.versionLength]
        elif qrECC == "M":
            return QR_DICTIONARIES.QR_DICT_M[self.versionLength]
        elif qrECC == "Q":
            return QR_DICTIONARIES.QR_DICT_Q[self.versionLength]
        elif qrECC == "H":
            return QR_DICTIONARIES.QR_DICT_H[self.versionLength]
        else:
            print("Error: Invalid Error Correction Level selected.")
            pass

    def homeScreen(self, duration):
        """Displays alternating on/off LED pattern to be used at the beginning of transmission
        and when no packets are in the shared queue."""
        print("Home Screen")
        for i in range(31):
            if i % 2 == 1:

                for j in range(31):
                    if j % 2 == 1:
                        self.matrix.SetPixel(i, j, 0, 0, 150)
                    else:
                        self.matrix.SetPixel(i, j, 0, 0, 0)
            else:
                for j in range(31):
                    if j % 2 == 0:
                        self.matrix.SetPixel(i, j, 0, 0, 150)
                    else:
                        self.matrix.SetPixel(i, j, 0, 0, 0)
        if duration != 0:
            sleep(duration)
Ejemplo n.º 14
0
# These functions have an immediate effect on the display; no special
# refresh operation needed.
# Requires rgbmatrix.so present in the same directory.

from __future__ import division
from builtins import range
from past.utils import old_div
import time
from rgbmatrix import Adafruit_RGBmatrix

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

# 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((old_div(b, 4)) * 8 + g, (b & 3) * 8 + r,
                            old_div((r * 0b001001001), 2),
                            old_div((g * 0b001001001), 2), b * 0b00010001)

time.sleep(10.0)
matrix.Clear()
Ejemplo n.º 15
0
import random
import time
from rgbmatrix import Adafruit_RGBmatrix
matrix = Adafruit_RGBmatrix(32, 1)

x = 0


def zclear():
    for i in range(1000):
        matrix.SetPixel(random.randint(0, 31), random.randint(0, 31), 0, 0, 0)
        time.sleep(.00125)


while True:
    pix = [
        random.randint(0, 31),
        random.randint(0, 31),
        random.randint(0, 255),
        random.randint(0, 255),
        random.randint(0, 255)
    ]
    matrix.SetPixel(pix[0], pix[1], pix[2], pix[3], pix[4])
    print x, pix
    x += 1
    if x == 500:
        x = 0
        zclear()
    time.sleep(.0025)
Ejemplo n.º 16
0
class drawing_app_matrix:
    def __init__(self):
        # Initialize LED Matrix
        self.matrix = Adafruit_RGBmatrix(32, 1)

    def main(self, arg1, arg2):
        #        global random, randint
        self.matrix.Clear()

        #   INPUT
        pix = arg1
        rainbow = arg2
        #   end INPUT

        # Initialize canvas
        #        canvas_pix = numpy.zeros((32, 32))

        # Word input -> canvas
        #        canvas_pix = overlayAt(0, 4, stringtopix(word), canvas_pix, 1)

        # Scoreboard -> canvas
        #       canvas_pix = overlayAt(1, 16, stringtopix("Score:"), canvas_pix, 1)

        # Score input -> canvas
        #       canvas_pix = overlayAt(1, 24, stringtopix(str(score)), canvas_pix, 1)

        #    print_to_matrix_default(canvas_pix)
        if rainbow:
            for x in range(0, 32):
                for y in range(0, 32):
                    if pix[x][y] == 1:
                        self.matrix.SetPixel(x, y, randint(0, 255),
                                             randint(0, 255), randint(0, 255))
        else:
            for x in range(0, 32):
                for y in range(0, 32):
                    if pix[x][y] == 1:
                        self.matrix.SetPixel(x, y, 255, 0, 0)

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

    def clear_word(self, score):
        # Initialize canvas
        canvas_pix = numpy.zeros((32, 32))

        # Word input -> canvas
        #canvas_pix = overlayAt(1, 4, stringtopix(word), canvas_pix, 1)

        # Scoreboard -> canvas
        canvas_pix = overlayAt(1, 16, stringtopix("Score:"), canvas_pix, 1)

        # Score input -> canvas
        canvas_pix = overlayAt(1, 24, stringtopix(str(score)), canvas_pix, 1)

        #    print_to_matrix_default(canvas_pix)
        for x in range(0, 32):
            for y in range(0, 32):
                if canvas_pix[x][y] == 1:
                    self.matrix.SetPixel(x, y, 255, 0, 0)

    if __name__ == "__main__":
        main(sys.argv[1], sys.argv[2])