Example #1
0
  def __init__(self):

    self.capabilities(MATRIX_WIDTH, MATRIX_HEIGHT, mode="RGB")

    # Use Adafruit's RGB Matrix class
    from rgbmatrix import Adafruit_RGBmatrix
    self._matrix = Adafruit_RGBmatrix(32, 1)
Example #2
0
def main(argv):
    # init led matrix
    matrix = Adafruit_RGBmatrix(32, 1)
    matrix.Clear()

    # file name
    inputfile = ''
    try:
        opts, args = getopt.getopt(argv, "hi:o:", ["ifile="])
    except getopt.GetoptError:
        print 'test.py -i <inputfile>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'test.py -i <inputfile>'
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg

    # play
    print 'Input file is ', inputfile
    image = Image.open(inputfile)
    image.load()
    matrix.SetImage(image.im.id, 0, 1)
    time.sleep(10.0)
    matrix.Clear()
Example #3
0
def main():
    frames = processImage('/home/pi/rpi-matrix-gif/myGIF.gif')
    matrix = Adafruit_RGBmatrix(32, 1)
    while True:
        for f in frames:
            matrix.SetImage(f.im.id, 0, 0)
            time.sleep(0.1)
Example #4
0
def loop():
	from rgbmatrix import Adafruit_RGBmatrix
	matrix = Adafruit_RGBmatrix(MATRIX_SIZE,1) 
	while(True):
	    run(matrix)
	    time.sleep(REFRESH_INTERVAL)
	    matrix.Clear()
Example #5
0
def launch_matrix(message_queue):
    #setup the matrix and screen buffer
    matrix = Adafruit_RGBmatrix(height, chain_len)  # rows, chain length
    image = Image.new('RGB', (width, height))
    draw = ImageDraw.Draw(image)

    message_list = []  #initialize the message_list to empty.

    # Make two message slots (two rows of text)
    message_slots = []
    for y in xrange(0, 2):
        message_slots.append(MessageSlot(0, y * font_height, StillFrames))

    # Set times for frame counting
    current_time = 0.0
    prev_time = 0.0

    # Delay frames from when last message was shown to put default up
    frame_delay = 40
    # Frames since last message was displayed
    frames_since_message = frame_delay

    while True:
        # Draw empty background rectangle
        draw.rectangle((0, 0, width, height), fill=(0, 0, 0))

        # Empty the inbound queue
        while (not message_queue.empty()):
            message_list.append(message_queue.get())

        # Find out if we are displaying anything and draw if we are.
        displaying_messages = False
        for message_slot in message_slots:
            if (message_slot.has_message()):
                displaying_messages = True
                message_slot.draw(draw)
                message_slot.advance()
            else:
                if (message_list):
                    message_slot.set_message(message_list.pop())

        if displaying_messages:
            frames_since_message = 0
        else:
            frames_since_message += 1
            if (frames_since_message >= frame_delay):
                draw_default(draw)

        current_time = time.time()
        time_delta = (1.0 / fps) - (current_time - prev_time)
        if (time_delta > 0.0):
            time.sleep(time_delta)
        prev_time = current_time

        # Copy the offscreen buffer to the screen.
        matrix.SetImage(image.im.id, 0, 0)
Example #6
0
 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
Example #7
0
 def __init__(self):
     self.font_width = 6
     self.font_height = 10
     self.max_char_width = 9
     self.max_char_height = 2
     self.matrix = Adafruit_RGBmatrix(32, 2)
     self.fontfile = os.path.join(
         os.path.dirname(os.path.abspath(__file__)),
         "fonts/{0}x{1}.bdf".format(self.font_width, self.font_height))
     self.offset = [0, 0]
Example #8
0
    def __init__(self):
        """ Initialise a new twitter display """
        self.logger = logging.getLogger(self.__class__.__name__)
        self.logger.info("Initialising the Amp View")
        self.matrix = Adafruit_RGBmatrix(AmpView.PANEL_HEIGHT, AmpView.PANELS)
        self.__load_fonts()

        self.volume = ""
        self.source = ""
        self.timer = None
        self.model = None
Example #9
0
 def __init__(self):
     self.__initSerial()
     self.game_mode = self.MODE['ATTRACT']
     self.matrix = Adafruit_RGBmatrix(32, 2, 3)
     self.image = Image.new("RGB", (96, 64))
     self.draw = ImageDraw.Draw(self.image)
     font = ImageFont.truetype(
         "/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 14)
     self.draw.text((20, 10), "LOADING", font=font, fill=(255, 60, 5))
     self.draw.text((18, 30), "SKEEBALL", font=font, fill=(255, 60, 5))
     self.matrix.Clear()
     self.matrix.SetImage(self.image.im.id, 0, 0)
     time.sleep(1)
Example #10
0
	def __init__(self):
		#self.__initSerial()
		self.game_mode = self.MODE['ATTRACT']
		self.matrix = Adafruit_RGBmatrix(32,2,3)
		self.image = Image.new("RGB", (96, 64))
		self.draw  = ImageDraw.Draw(self.image)


		image = Image.open("imgs/penis.png")
		image.load()          # Must do this before SetImage() calls
		self.matrix.SetImage(image.im.id,0,0)
		time.sleep(5)
		self.__start()
Example #11
0
 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
Example #12
0
 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
Example #13
0
def main(argv=[]):
    logging.getLogger().setLevel(
        logging.DEBUG if DEBUG_DISPLAY else logging.INFO)
    logging.info("running")

    def quit_handler(signal, frame):
        logging.info("Interrupted")
        a.finish()

    signal.signal(signal.SIGINT, quit_handler)

    logging.debug("Creating matrix")
    matrix = Adafruit_RGBmatrix(LED_MATRIX_ROWS, 1)
    logging.debug("Starting renderer")
    a = LedApp(matrix, None)
    while True:
        try:
            a.refresh()
        except Exception as e:
            logging.exception("Top level exception")
            a.finish()
    a.finish()
Example #14
0
def main():
    if len(sys.argv) != 2:
        sys.exit('usage: {} <src_dir>'.format(sys.argv[0]))

    if not os.path.isdir(sys.argv[1]):
        sys.exit('{} is not a directory'.format(sys.argv[1]))

    dir_src = os.path.normpath(sys.argv[1])
    images = sorted(list_files_with_ext(dir_src, JPEG))

    matrix = Adafruit_RGBmatrix(MATRIX_SIZE, MATRIX_CHAIN)

    try:
        while True:
            for image in images:
                im = Image.open(image)
                im.load()
                matrix.SetImage(im.im.id, 0, 0)
                time.sleep(SLEEP)
    except KeyboardInterrupt:
        pass

    matrix.Clear()
Example #15
0
	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)
Example #16
0
#!/usr/bin/python

# 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 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)
Example #17
0
import sys
import time

# Add the submodule to the list of paths. This way, we can import rgbmatrix.
sys.path.insert(0, '/home/pi/ipwa/matrix')

from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
from rgbmatrix import Adafruit_RGBmatrix

matrix = Adafruit_RGBmatrix(16, 1)


class SimpleEcho(WebSocket):
    def handleMessage(self):
        values = eval(self.data, {'os': None})
        for rowIndex, row in enumerate(values):
            for colIndex, col in enumerate(row):
                r = col[0]
                g = col[1]
                b = col[2]

                matrix.SetPixel(colIndex, rowIndex, r, g, b)

    def handleConnected(self):
        print self.address, 'connected'

    def handleClose(self):
        print self.address, 'closed'


server = SimpleWebSocketServer('', 1337, SimpleEcho)
Example #18
0
                        dot.b = 255
            elif TempsActuel - DebutInvincible >= 11:  #Revert
                ModeInvincible = False
                for dot in Snake:
                    dot.r = 0
                    dot.g = 0
                    dot.b = 255
            else:
                for dot in Snake:
                    dot.r = random.randint(0, 255)
                    dot.g = random.randint(0, 255)
                    dot.b = random.randint(0, 255)


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

gLightMatrix = def_clsLightMatrix(device)
gRand = def_clsRandom()
Score = 0
ScoreMult = 1
ModeInvincible = False
DebutInvincible = time.time()
DebutMur = time.time()

gaterie = []
Snake = []
obstacles = []
etoiles = []
Murs = []
Tirs = []
Example #19
0
import atexit
import math
import os
import time

import Image
import ImageDraw
import ImageFont

from rgbmatrix import Adafruit_RGBmatrix

# Configuration
fps            = 2
width          = 64  # Matrix size (pixels) -- change for different matrix
height         = 32  # types (incl. tiling).  Other code may need tweaks.
matrix         = Adafruit_RGBmatrix(32, 2) # rows, chain length

green          = (0, 132, 69)
red            = (225, 39, 38)
orange         = (232, 116, 36)
blue           = (15, 75, 145)
silver         = (125, 134,140)
plum           = (194, 147, 181)
aqua           = (216, 240, 252)
white          = (255, 255, 255)
black          = (0, 0, 0)

font           = ImageFont.load(os.path.dirname(os.path.realpath(__file__)) + '/helvR08.pil')

# Main application -----------------------------------------------------------
Example #20
0
 def __init__(self, rows=32, chain=1):
     super(DriverAdaMatrix, self).__init__(rows * 32 * chain)
     self._matrix = Adafruit_RGBmatrix(rows, chain)
Example #21
0
    def __init__(self, name, callback_function, queue, threadlist):
        """
        This class puts it all together, creating a state machine and a socket thread that calls state changes for received commands
        """
        HomeAutomationQueueThread.__init__(self, name, callback_function,
                                           queue, threadlist)

        logging.info('LEDMatrixCore initialized')
        self.rgbmatrix = Adafruit_RGBmatrix(32, 1)
        self.rgbm = RGBMatrix(self.rgbmatrix, self.queue, self.threadlist)

        self.transitions = [
            {
                'trigger': 'SetPixel',
                'source': 'idle',
                'dest': 'settingpixel'
            },
            {
                'trigger': 'Clear',
                'source': 'idle',
                'dest': 'clearing'
            },
            {
                'trigger': 'AudioVisualize',
                'source': 'idle',
                'dest': 'audiovisualizing'
            },
            {
                'trigger': 'StopAudioVisualize',
                'source': 'audiovisualizing',
                'dest': 'stopaudiovisualizing'
            },
            {
                'trigger': 'SetMatrixFromImgBase64',
                'source': 'idle',
                'dest': 'settingmatrixfromimage'
            },
            {
                'trigger': 'Screensaver',
                'source': 'idle',
                'dest': 'screensaver'
            },
            {
                'trigger': 'SplashScreen',
                'source': 'idle',
                'dest': 'splashscreen'
            },
        ]
        self.states = [
            'idle', 'settingpixel', 'clearing', 'audiovisualizing',
            'settingmatrixfromimage', 'stopaudiovisualizing', 'screensaver',
            'splashscreen'
        ]

        self.machine = Machine(model=self.rgbm,
                               states=self.states,
                               transitions=self.transitions,
                               initial='idle')

        lmssu = LEDMatrixSocketServiceUDP(name='SocketService',
                                          callback_function=None,
                                          rgbmatrix=self.rgbmatrix,
                                          rgbm=self.rgbm,
                                          queue=queue)
        #lmssu.start()
        threadlist.append(lmssu)  #hacore should start() it afterwards

        global CurrentInstance
        CurrentInstance = self
Example #22
0
 def __init__(self):
     # Initialize LED Matrix
     self.matrix = Adafruit_RGBmatrix(32, 1)
 def __init__(self):
     self._matrix = Adafruit_RGBmatrix(32, 1)
     self._font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 12)
Example #24
0
# string on each line can then be edited for brevity if desired.
stops = [
    ('sf-muni', 'N', '7318', 'Inbound'),
    ('sf-muni', '24', '4330', 'Castro'),
    ('sf-muni', '24', '4331', 'Divis'),
    #   ('sf-muni', '22', '5018', 'Mission'),
]

maxPredictions = 3  # NextBus shows up to 5; limit to 3 for simpler display
minTime = 0  # Drop predictions below this threshold (minutes)
shortTime = 5  # Times less than this are displayed in red
midTime = 10  # Times less than this are displayed yellow

width = 32  # Matrix size (pixels) -- change for different matrix
height = 16  # types (incl. tiling).  Other code may need tweaks.
matrix = Adafruit_RGBmatrix(16, 1)  # rows, chain length
fps = 12  # Scrolling speed (ish)

routeColor = (255, 255, 255)  # Color for route labels (usu. numbers)
descColor = (110, 110, 110)  # " for route direction/description
longTimeColor = (0, 255, 0)  # Ample arrival time = green
midTimeColor = (255, 255, 0)  # Medium arrival time = yellow
shortTimeColor = (255, 0, 0)  # Short arrival time = red
minsColor = (110, 110, 110)  # Commans and 'minutes' labels
noTimesColor = (0, 0, 255)  # No predictions = blue

# TrueType fonts are a bit too much for the Pi to handle -- slow updates and
# it's hard to get them looking good at small sizes.  A small bitmap version
# of Helvetica Regular taken from X11R6 standard distribution works well:
font = ImageFont.load(
    os.path.dirname(os.path.realpath(__file__)) + '/helvR08.pil')
Example #25
0
from __future__ import unicode_literals
import Image
import ImageDraw
import time
import ImageFont
from rgbmatrix import Adafruit_RGBmatrix

import ImageOps
import pickle

with open("emojiemotionlist.txt", "rb") as fp:  # Unpickling
    emojilist = pickle.load(fp)

print(len(emojilist))
# print(emojilist[0:10])
matrix = Adafruit_RGBmatrix(32, 4)
num = len(emojilist)
rep = 4
im = Image.new("RGB", (32 * num * rep, 32))
size = 32, 32

for n in range(0, rep * num, 1):
    print(emojilist[n % num])
    emoji = Image.open(emojilist[n % num])
    emoji.thumbnail(size, Image.ANTIALIAS)
    emoji.load()  # Must do this before SetImage() calls
    im.paste(emoji, (n * 32 + 1, 0))

print(im.size[0])
for n in range(128, -im.size[0], -1):  # Scroll R to L
Example #26
0
            #'/(.*)', 'WebService_Index',
        )
        for wsdi in WebServiceDefinitions:
            urls = urls + (wsdi.url, wsdi.cl)
        urls = urls + ('/(.*)', 'WebService_Index')
        app = web.application(urls, globals())
        logging.info('Starting up WebService app')
        app.run()


# END WEBSERVICE SECTION

if __name__ == '__main__':
    InitLogging()
    logging.info('running some tests..')
    mtx = Adafruit_RGBmatrix(32, 1)
    """logging.info('test audio system')
	a = Audio(mtx)
	a.playwavfile('/home/pi/wav/savant_alchemist.wav')
	mtx.Clear()"""
    """logging.info('test clock/font system')
	displayCurrentTime(mtx, 0, 0, 0, 127, 127)
	time.sleep(2)
	mtx.Clear()"""
    """logging.info('test image system')
	SetMatrixFromImgBase64(mtx, 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABT0lEQVR4nO2XMY6DMBBFTZRij5Ay'+
		'JXQuOUaOwRG23DJH4Bh7DEo6KLfcI6QjBf6W/GdHNpGicbGvQbbHFv/j8Zhm2zZXQtd1ZYGBdV2b'+
		'krjTkUXfwVkbYMXzPCfj08clafeP36TtvU/ma46YO9DwHoDycd0VsbLINXXA/fwdB6eGdn+yE/U4'+
		'IJRDICtj5YwSP4VudsLcAZEF8ZtDKSseMisqDsV1vU/6zR1o2rbdnJN5HoEiKP9UsgLcQ/wY2kp2'+
		'+OCEuQPqSSjIKee4MZMtAXMH/l9A3wO5E68UrKNkQz0OoGqhBkz8whjXqiOtw/RUE1yoCfU4ALhq'+
		'CegsFyjzUGUZcwfEfYCZx1vS9sP3S/3Msix13AfUO2FU0n8l46hiXD21fjft8+EElANzB8qrYUC7'+
Example #27
0
LIME = [0, 255, 0]
BLUE = [0, 0, 255]
YELLOW = [255, 255, 0]
FUCHSIA = [255, 0, 255]
AQUA = [0, 255, 255]
WHITE = [255, 255, 255]

# Birthday
BIRTH_MONTH = 8
BIRTH_DAY = 29

#Color Fade Order (for Leah <3)
FADE_COLORS = [LIME, YELLOW, RED, FUCHSIA, BLUE, AQUA]

# Enumerate RGB Matrix Object
matrix = Adafruit_RGBmatrix(MATRIX_H, MATRIX_W / MATRIX_H)

#Word Dictionary
#Uses the Physical Grid mapping for the laser cut grid:
# X is 1 - 16 inclusive
# Y is 1 - 16 includive
# Origin is top left corner
m = {
    "good": {
        "row": 1,
        "start": 1,
        "length": 4,
        "height": 1
    },
    "hiya": {
        "row": 1,
Example #28
0
def run():
    if os.environ['env'] == 'dev':
        while True:
        try:
            display_info = get_display_info(10)
        except Exception as e:
            print e
            continue
        for i in range(12):
            print(matrix,
                            COLOR_MAPPING[display_info[top_i]['route']],
                            display_info[top_i]['route'],
                            display_info[top_i]['route_direction'],
                            display_info[top_i]['minutes'],
                            display_info[top_i]['stop_name'],
                            first_row_y)
            print(matrix,
                            COLOR_MAPPING[display_info[bot_i]['route']],
                            display_info[bot_i]['route'],
                            display_info[bot_i]['route_direction'],
                            display_info[bot_i]['minutes'],
                            display_info[bot_i]['stop_name'],
                            second_row_y)
            time.sleep(5.0)
            
    # Rows and chain length are both required parameters:
    matrix = Adafruit_RGBmatrix(16, 2)
    # matrix.SetPWMBits(8)
    def clearOnExit():
	    matrix.Clear()
    atexit.register(clearOnExit)

    row_width = 64
    row_height = 8
    fps = 20  # Scrolling speed (ish)
    first_row_y = 0
    second_row_y = 8

    while True:
        try:
            display_info = get_display_info(10)
        except Exception as e:
            print e
            continue
        top_i = 0
        bot_i = 1
        for i in range(12):
            draw_subway_row(matrix,
                            COLOR_MAPPING[display_info[top_i]['route']],
                            display_info[top_i]['route'],
                            display_info[top_i]['route_direction'],
                            display_info[top_i]['minutes'],
                            display_info[top_i]['stop_name'],
                            first_row_y)
            draw_subway_row(matrix,
                            COLOR_MAPPING[display_info[bot_i]['route']],
                            display_info[bot_i]['route'],
                            display_info[bot_i]['route_direction'],
                            display_info[bot_i]['minutes'],
                            display_info[bot_i]['stop_name'],
                            second_row_y)
            top_i += 2
            bot_i += 2
            if top_i >= len(display_info):
                top_i = 0
            if bot_i >= len(display_info):
                bot_i = 1
            time.sleep(5.0)

if __name__ == "__main__":
    try:
        run()
    except Exception as e:
        raise e
Example #29
0
File: run.py Project: Simhs/APad
 def alloc_matrix(self):
     self.matrix = Adafruit_RGBmatrix(32, 2)
Example #30
0
slidewait = 3.0
staticwait = 3.0
# Note: the width of the matrix is assumed by underlying code to be 32.  
# This is not good as 64x64 panels are now available
matrixcols = 32     # 32, the pixel width of a matrix; do not change from 32, will break things
matrixrows = 32     # 32 or 16, the pixel height of a matrix; not well tested with anything other than 32
nummatrix = 2       # the number of chained matrix; not well tested with anything other than 2
dispheight = matrixcols
dispwidth = matrixrows * nummatrix
if verbosity > 1:
    print str(dispheight) + " h x " + str(dispwidth) + " w"

# Rows and chain length are both required parameters:
# Note: this normally prints a Result line that is somewhat undesirable, several experiments to suppress didn't work

matrix = Adafruit_RGBmatrix(matrixrows, nummatrix)

### This is stuff from the original Adafruit example that is not currently set up
### begin dead code block

# Bitmap example w/graphics prims
#image = Image.new("1", (32, 32)) # Can be larger than matrix if wanted!!
#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!