def __init__(
            self,
            message_cache_dir=None,
            repeat_delay=0,
            scroll_delay=0,
            display1_address=0x70,
            display2_address=0x72,
            display3_address=0x71,
            display4_address=0x74,
            font_size=9,
            font_path="/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"):
        self.num_displays = 0
        self.use_display1 = False
        self.use_display2 = False
        self.use_display3 = False
        self.use_display4 = False
        self.rotate_text = True
        self.repeat_delay = repeat_delay
        self.scroll_delay = scroll_delay
        self.message_cache_dir = message_cache_dir

        if display1_address:
            self.display1 = Matrix8x8.Matrix8x8(address=display1_address)
            self.display1.begin()
            self.num_displays += 1
            self.use_display1 = True
        else:
            self.display1 = None

        if display2_address:
            self.display2 = Matrix8x8.Matrix8x8(address=display2_address)
            self.display2.begin()
            self.num_displays += 1
            self.use_display2 = True
        else:
            self.display2 = None

        if display3_address:
            self.display3 = Matrix8x8.Matrix8x8(address=display3_address)
            self.display3.begin()
            self.num_displays += 1
            self.use_display3 = True
        else:
            self.display3 = None

        if display4_address:
            self.display4 = Matrix8x8.Matrix8x8(address=display4_address)
            self.display4.begin()
            self.num_displays += 1
            self.use_display4 = True
        else:
            self.display4 = None

        self.font = ImageFont.truetype(font_path, font_size)

        self.empty_image = None
        self.images = None
        self.images_message = None
        self.delay_time = 0.1
Пример #2
0
 def __init__(self, ):
     self.matrix = []
     self.matrix.append(Matrix8x8.Matrix8x8(address=0x70, busnum=1))
     self.matrix.append(Matrix8x8.Matrix8x8(address=0x71, busnum=1))
     self.matrix.append(Matrix8x8.Matrix8x8(address=0x72, busnum=1))
     self.matrix.append(Matrix8x8.Matrix8x8(address=0x73, busnum=1))
     for m in self.matrix:
         m.begin()
Пример #3
0
    def __init__(self):
        self.displays = [
            Matrix8x8.Matrix8x8(address=0x70),
            Matrix8x8.Matrix8x8(address=0x74),
            Matrix8x8.Matrix8x8(address=0x72),
            Matrix8x8.Matrix8x8(address=0x71)
        ]

        self.prev_api_req_time = datetime.datetime.now() - datetime.timedelta(
            minutes=60)
        self.condition = weather_api_request([47.4794433, 19.2530735], 'c')
        self.engine = create_engine(
            'mysql+pymysql://messenger:demopassword@localhost/messenger')
Пример #4
0
 def __init__(self, size=4, brightness=1):
     self.matrix = []
     for i in range(size):
         self.matrix.append(Matrix8x8.Matrix8x8(address=0x70 + i, busnum=1))
     for m in self.matrix:
         m.begin()
         m.set_brightness(brightness)
Пример #5
0
def updateDisplays(args):
    dotDisplay = Matrix8x8.Matrix8x8(address=0x71, busnum=1)
    dotDisplay.begin()
    dotDisplay.clear()
    
    if '+r' in args:
        printLetterQuadrant(dotDisplay, 0, 0, R_4x4)
    if '+c' in args:
        printLetterQuadrant(dotDisplay, 0, 4, C_4x4)
    if '+o' in args:
        printLetterQuadrant(dotDisplay, 4, 4, O_4x4)
    if '-t' in args:
        t = int(args['-t'])
        if t >= 1 and t <= 16:
            printTimeQuadrant(dotDisplay, 0, 4, t);
    
    clockDisplay = SevenSegment.SevenSegment()
    clockDisplay.begin()
    clockDisplay.clear()
    
    if '-gt' in args:
        gameTime = int(args['-gt'])
        printClockTimeSec(clockDisplay, gameTime)
    
    # Flush to both displays at the same time
    dotDisplay.write_display()
    clockDisplay.write_display()
    
    return;
Пример #6
0
def light():
    display = Matrix8x8.Matrix8x8()

    # Initialize the display. Must be called once before using the display.
    display.begin()

    display.clear()

    image = Image.new('1', (8, 8))
    draw = ImageDraw.Draw(image)
    draw.rectangle((0, 0, 7, 7), outline=255, fill=0)
    draw.rectangle((1, 1, 6, 6), outline=255, fill=0)
    draw.rectangle((2, 2, 5, 5), outline=255, fill=0)
    draw.rectangle((3, 3, 4, 4), outline=255, fill=0)

    display.set_image(image)
    display.write_display()
    time.sleep(1)

    for x in range(8):
        for y in range(8):
            display.clear()
            display.set_pixel(x, y, 0)
            display.write_display()
    display.clear()
    def __init__(self):
        """Init parameters"""
        '''
        List of system variables:
        0. Arduino connection
        1. IMU
        '''
        self.list_system_variables = np.array([0, 0])
        # Create display instance on default I2C address (0x70) and bus number.
        self.display = Matrix8x8.Matrix8x8()
        # Initialize the display. Must be called once before using the display.
        self.display.begin()

        self.demo_matrix()
        time.sleep(0.5)
Пример #8
0
    def __init__(self, ids, brightness=14):
        self.lcds = []
        self.rand = Randomizer(20)
        for id in ids:
            self.lcds.append(Matrix8x8.Matrix8x8(address=id))

        if 15 < brightness < 0:
            raise Exception("MatrixArray::brightness must be 0-15:",
                            brightness)

        for lcd in self.lcds:
            lcd.begin()
            lcd.set_brightness(brightness)
            lcd.clear()
            lcd.write_display()
def DisplayCounter(count):
    counter = count % 8
    # Alternatively, create a display with a specific I2C address and/or bus.
    display = Matrix8x8.Matrix8x8(address=0x70, busnum=1)

    # Initialize the display. Must be called once before using the display.
    display.begin()
    display.clear()

    # First create an 8x8 1 bit color image.
    image = Image.new('1', (8, 8))

    # Then create a draw instance.
    draw = ImageDraw.Draw(image)
    draw = DrawDigit(draw, counter & 1, 0)
    draw = DrawDigit(draw, (counter >> 1) & 1, 1)
    draw = DrawDigit(draw, (counter >> 2) & 1, 2)
    # Draw the image on the display buffer.
    display.set_image(image)
    # Draw the buffer to the display hardware.
    display.write_display()
    time.sleep(2)
Пример #10
0
    if display_:
        display_.clear()
        display_.write_display()
    return


# Main
# Optional args: [port number]
#
if __name__ == "__main__":

    portNumber = 3141 # get it?
    if len(sys.argv) > 1:
        portNumber = int(sys.argv[1])

    display_ = Matrix8x8.Matrix8x8()
    display_.begin()

    # Instantiate the server, and bind to host and port.
    server = socketserver.TCPServer(("localhost", portNumber), aTCPSocketHandler)
    try:
        # Activate the server; this will keep running until ctrl-C (or SIGINT?)
        printOrLog(f"Message server listening on port {portNumber}; default delay {displayDelay_}")
        server.serve_forever()
    except KeyboardInterrupt:
        server.server_close()
        clearDisplay()
        raise
    except:
        # report error and proceed
        raise
Пример #11
0
    "green"         : "#30ff30",
    "pure-green"    : "#0fff87",
    "yellow-green"  : "#a8ee19",
    "yellow"        : "#fdb71a",
    "blue"          : "#1ac4ff",
    "white"         : "#fefefe",
}

NX = 8
NY = 8
I2C_ADDRESS = 0x70
LED_ON_COLOR = LED_COLOR["red"]
LED_OFF_COLOR = LED_COLOR["off"]
TXT_FILE = "led8x8.txt"

matrix = Matrix8x8.Matrix8x8(address=I2C_ADDRESS)

class Application(Frame):
    """Tkinter Application to provide interaction with Adafruit 8x8 LED matrix."""

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid() 
        self.vars =[[IntVar() for x in xrange(NX)] for y in xrange(NY)]
        self.checks = [[self.__makecheck__(self.vars[x][y])
                        for x in xrange(NX)]
                        for y in xrange(NY)]

        for x in xrange(NX):
            for y in xrange(NY):
                self.checks[x][y].grid(row=x, column=y, padx=2, pady=2)
Пример #12
0
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import time

from PIL import Image
from PIL import ImageDraw

from Adafruit_LED_Backpack import Matrix8x8


# Create display instance on default I2C address (0x70) and bus number.
display = Matrix8x8.Matrix8x8()

# Alternatively, create a display with a specific I2C address and/or bus.
# display = Matrix8x8.Matrix8x8(address=0x74, busnum=1)

# On BeagleBone, try busnum=2 if IOError occurs with busnum=1
# display = Matrix8x8.Matrix8x8(address=0x74, busnum=2)

# Initialize the display. Must be called once before using the display.
display.begin()

# Run through each pixel individually and turn it on.
for x in range(8):
	for y in range(8):
		# Clear the display buffer.
		display.clear()
Пример #13
0
from PIL import Image
from PIL import ImageDraw
from Adafruit_LED_Backpack import Matrix8x8

import time

message = "The quick brown fox jumps over the lazy dog".upper()

# 70 - display 1
# 72 - display 2
# 71 - display 3
# 74 - display 4

#display1 = Matrix8x8.Matrix8x8(address=0x70)
#display1.begin()
display2 = Matrix8x8.Matrix8x8(address=0x72)
display2.begin()
#display3 = Matrix8x8.Matrix8x8(address=0x71)
#display3.begin()
#display4 = Matrix8x8.Matrix8x8(address=0x74)
#display4.begin()

font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 8)
#font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", 9)
# create new Image class for single color, 8x8 LED Pack with a black background
im = Image.new("1", (8, 8), "black")

# copy the empty image so it can be used to fill empty frames
empty_image = im.copy()

draw = ImageDraw.Draw(im)
Пример #14
0
from Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor
from Adafruit_LED_Backpack import Matrix8x8
from Matrix16x8 import Matrix16x8
from fonts import custom_font
from bluetooth import *

import os
import time
import atexit
import socket, subprocess

#create objects
mh = Adafruit_MotorHAT(addr=0x60)
display16x8 = Matrix16x8(address=0x72, busnum=1)
display8x8 = Matrix8x8.Matrix8x8(address=0x72, busnum=1)

#run the 8x8 first because 16x8 wont work at this time still figureing out
display8x8 = Matrix8x8.Matrix8x8(address=0x72, busnum=1)
display8x8.begin()
display8x8.clear()
display8x8.set_pixel(0, 0, 1)

#configure 16x8 lights
display16x8.set_brightness(8)
display16x8.display_16x8_buffer(custom_font.shapes['all_on'] +
                                custom_font.shapes['all_on'])
time.sleep(1)
display16x8.display_16x8_buffer(custom_font.shapes['all_off'] +
                                custom_font.shapes['all_off'])

#say hello
Пример #15
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import time

#  from PIL import Image
#  from PIL import ImageDraw

from Adafruit_LED_Backpack import Matrix8x8

# Create display instance on default I2C address (0x70) and bus number.
display = Matrix8x8.Matrix8x8(address=0x70, busnum=1)
# check using I2cdetect -y 1  to make sure the address is 70, if not edit the line above to change it
# the correct address
# Alternatively, create a display with a specific I2C address and/or bus.
# display = Matrix8x8.Matrix8x8(address=0x74, busnum=1)

# Initialize the display. Must be called once before using the display.
display.begin()
display.clear()

while True:
    # Run through each pixel individually and turn it on.
    for xled in range(1, 10):  # anodes numbers starts 1
        x = int((xled - 1) / 3) + 1  # anodes numbers starts 1
        y = (2 + xled) % 3  # cathodes number start 0
        # Clear the display buffer.
Пример #16
0
def draw(val, type=''):
    def digit(d, x0=0, y0=0):
        options = {
            0: zero,
            1: one,
            2: two,
            3: three,
            4: four,
            5: five,
            6: six,
            7: seven,
            8: eight,
            9: nine
        }
        options[d](x0, y0)

    def zero(x0, y0):
        draw.line((0 + x0, 0 + y0, 0 + x0, 4 + y0), fill=255)
        draw.line((1 + x0, 0 + y0, 1 + x0, 4 + y0), fill=255)

    def one(x0, y0):
        ## One
        draw.line((1 + x0, 0 + y0, 1 + x0, 4 + y0), fill=255)

    def two(x0, y0):
        ## Two
        draw.line((0 + x0, 0 + y0, 1 + x0, 0 + y0), fill=255)
        draw.line((1 + x0, 0 + y0, 1 + x0, 2 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 0 + x0, 2 + y0), fill=255)
        draw.line((0 + x0, 2 + y0, 0 + x0, 4 + y0), fill=255)
        draw.line((0 + x0, 4 + y0, 1 + x0, 4 + y0), fill=255)

    def three(x0, y0):
        ## Three
        draw.line((0 + x0, 0 + y0, 1 + x0, 0 + y0), fill=255)
        draw.line((1 + x0, 0 + y0, 1 + x0, 2 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 0 + x0, 2 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 1 + x0, 4 + y0), fill=255)
        draw.line((1 + x0, 4 + y0, 0 + x0, 4 + y0), fill=255)

    def four(x0, y0):
        draw.line((0 + x0, 0 + y0, 0 + x0, 2 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 1 + x0, 4 + y0), fill=255)

    def five(x0, y0):
        draw.line((0 + x0, 0 + y0, 1 + x0, 0 + y0), fill=255)
        draw.line((0 + x0, 0 + y0, 0 + x0, 2 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 0 + x0, 2 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 1 + x0, 4 + y0), fill=255)
        draw.line((0 + x0, 4 + y0, 1 + x0, 4 + y0), fill=255)

    def six(x0, y0):
        draw.line((0 + x0, 0 + y0, 0 + x0, 4 + y0), fill=255)
        draw.line((1 + x0, 2 + y0, 1 + x0, 4 + y0), fill=255)

    def seven(x0, y0):
        draw.line((0 + x0, 0 + y0, 1 + x0, 0 + y0), fill=255)
        draw.line((1 + x0, 1 + y0, 1 + x0, 4 + y0), fill=255)

    def eight(x0, y0):
        draw.line((0 + x0, 0 + y0, 1 + x0, 0 + y0), fill=255)
        draw.line((0 + x0, 1 + y0, 1 + x0, 1 + y0), fill=255)
        draw.line((0 + x0, 3 + y0, 1 + x0, 3 + y0), fill=255)
        draw.line((0 + x0, 4 + y0, 1 + x0, 4 + y0), fill=255)

    def nine(x0, y0):
        draw.line((1 + x0, 0 + y0, 1 + x0, 4 + y0), fill=255)
        draw.line((0 + x0, 0 + y0, 0 + x0, 2 + y0), fill=255)

    def negative(x0=0, y0=0):
        draw.line((0 + x0, 2 + y0, 1 + x0, 2 + y0), fill=255)

    def error_letter(x0=0, y0=0):
        draw.line((0 + x0, 0 + y0, 2 + x0, 0 + y0), fill=255)
        draw.line((0 + x0, 2 + y0, 1 + x0, 2 + y0), fill=255)
        draw.line((0 + x0, 4 + y0, 1 + x0, 4 + y0), fill=255)
        draw.line((0 + x0, 0 + y0, 0 + x0, 4 + y0), fill=255)
        #
        draw.line((3 + x0, 2 + y0, 3 + x0, 4 + y0), fill=255)
        draw.line((4 + x0, 2 + y0, 4 + x0, 2 + y0), fill=255)
        #
        draw.line((6 + x0, 2 + y0, 6 + x0, 4 + y0), fill=255)
        draw.line((7 + x0, 2 + y0, 7 + x0, 2 + y0), fill=255)

    def h_letter(x0=0, y0=0):
        draw.line((0 + x0, 0 + y0, 0 + x0, 2 + y0), fill=255)
        draw.line((0 + x0, 1 + y0, 2 + x0, 1 + y0), fill=255)
        draw.line((2 + x0, 0 + y0, 2 + x0, 2 + y0), fill=255)

    def t_letter(x0=0, y0=0):
        draw.line((0 + x0, 0 + y0, 2 + x0, 0 + y0), fill=255)
        draw.line((1 + x0, 0 + y0, 1 + x0, 2 + y0), fill=255)

    def getNum(val):
        isneg = 0
        if val < 0:
            isneg = 1
            val = abs(val)

        valstr = str(int(round(val)))

        if len(valstr) == 1:
            valstr = '0' + valstr

        if len(valstr) == 3 and isneg == 1:
            error_letter(0, 3)
        elif (len(valstr) == 3):
            digit(int(valstr[0]), 0, 3)
            digit(int(valstr[1]), 3, 3)
            digit(int(valstr[2]), 6, 3)
        elif (isneg == 1):
            negative(0, 3)
            digit(int(valstr[0]), 3, 3)
            digit(int(valstr[1]), 6, 3)
        else:
            digit(int(valstr[0]), 3, 3)
            digit(int(valstr[1]), 6, 3)

    # Create display instance on default I2C address (0x70) and bus number.
    display = Matrix8x8.Matrix8x8()

    # Initialize the display. Must be called once before using the display.
    display.begin()

    # Clear the display buffer.
    display.clear()

    display.set_brightness(1)

    if type == 'clear':
        # Draw the buffer to the display hardware.
        display.write_display()
        return

    # First create an 8x8 1 bit color image.
    image = Image.new('1', (8, 8))

    # Then create a draw instance.
    draw = ImageDraw.Draw(image)
    if type == 'temp':
        t_letter()
        getNum(val)
    elif type == 'humd':
        h_letter()
        getNum(val)
    elif type == 'error':
        error_letter()

    # Draw the image on the display buffer.
    display.set_image(image)

    # Draw the buffer to the display hardware.
    display.write_display()
Пример #17
0
                    current = current + 1
            self.display.write_display()
        else:
            self.display.clear()
            self.display.set_image(self.images[self.current])
            self.current = not self.current
            self.display.write_display()

    def stopthread(self):
        """ Called to stop the thread by setting stopcond to true."""
        self.stopcond = True


if __name__ == "__main__":
    # Initialise Display and thread.
    displays = Matrix8x8.Matrix8x8()
    displays.begin()
    displays.clear()
    displays.write_display()
    thread_watch = LoadThread(False, displays)
    thread_watch.start()
    try:  # Loop until keyboard interrupt
        while True:
            time.sleep(1)
    except (KeyboardInterrupt, SystemExit):
        thread_watch.stopthread()
    thread_watch.join()
    # Clear display
    displays.clear()
    displays.write_display()
Пример #18
0
# Set up DAC parameters
dac = MCP4725.DAC()
#sig = lambda t: 50 * np.sin(t*5*2*np.pi) + 50

# Set up ADC parameters
ADC.setup()
adcInPin = 'P9_39'  # AIN0

# Create 7-segment display instance (default I2C address = 0x70)
sevenSegDisplay = SevenSegment.SevenSegment(address=0x70, busnum=1)
sevenSegDisplay.begin()
sevenSegDisplay.set_colon(False)
sevenSegDisplay.clear()

# Create matrix display instance
matrixDisplay = Matrix8x8.Matrix8x8(address=0x71, busnum=1)
matrixDisplay.begin()
matrixDisplay.clear()
matrixImage = False

#tZero = time.time()
lastTime = time.time()
dacValue = 0
while True:
    currentTime = time.time()
    deltaTime = currentTime - lastTime

    if deltaTime > 0.25:
        # DAC
        #		dacValue = sig(currentTime-tZero)
        dacValue += 16
Пример #19
0
__author__ = 'youngsoul'
import time
from datetime import datetime
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from Adafruit_LED_Backpack import Matrix8x8

# 70 - display 1
# 72 - display 2
# 71 - display 3
# 74 - display 4

display = Matrix8x8.Matrix8x8(address=0x71)
display.begin()

font = ImageFont.truetype(
    "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", 9)

im = Image.new("1", (8, 8), "black")
draw = ImageDraw.Draw(im)
width, ignore = font.getsize("88 : 88 : 88")


def format_time():
    d = datetime.now()
    return "{:%H : %M : %S}".format(d)


message = format_time()
x = 8
__author__ = 'youngsoul'
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from Adafruit_LED_Backpack import Matrix8x8

import time

message = "The quick brown fox jumps over the lazy dog".upper()

# 70 - display 1
# 72 - display 2
# 71 - display 3
# 74 - display 4

display1 = Matrix8x8.Matrix8x8(address=0x70)
display1.begin()
display2 = Matrix8x8.Matrix8x8(address=0x72)
display2.begin()
display3 = Matrix8x8.Matrix8x8(address=0x71)
display3.begin()
display4 = Matrix8x8.Matrix8x8(address=0x74)
display4.begin()

font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 8)
#font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", 9)
# create new Image class for single color, 8x8 LED Pack with a black background
im = Image.new("1", (8, 8), "black")

# copy the empty image so it can be used to fill empty frames
empty_image = im.copy()
Пример #21
0
import RPi.GPIO as GPIO
from Adafruit_LED_Backpack import SevenSegment
from Adafruit_LED_Backpack import Matrix8x8
import Adafruit_GPIO.SPI as SPI

from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont

displayMode = True

try:
    print('testing I2C')

    # 8X8 led matrix
    matrixRight = Matrix8x8.Matrix8x8()
    matrixRight.begin()
    print('matrixRight loaded')
    matrixLeft = Matrix8x8.Matrix8x8(address=0x72)
    matrixLeft.begin()
    print('matrixLeft loaded')
    # 7-segment display
    display = SevenSegment.SevenSegment(address=0x71, busnum=1)
    display.begin()
    print('SevenSegment loaded')

except Exception as e:
    print('error loading I2C')
    print(e)
    displayMode = False
Пример #22
0
 def __init__(self):
     self.display = MX1.Matrix8x8()
     self.display.begin()
     self.image = Image.new('1', (8, 8))
     self.draw = ImageDraw.Draw(self.image)