Пример #1
0
class EyeChanger():
    def __init__(self):
        self.grid = EightByEight(address=0x70)
        self.pixels = {}
        
    def eye_data(self, name, pixels):
        self.pixels[name] = pixels

    def show_eye(self, name):
        p = self.pixels[name]
        self.grid.clear()
        i = 0
        for x in range(0, 8):
            for y in range(0, 8):
                if p[i] == '1':
                    self.grid.setPixel(x, y)
                i = i + 1
Пример #2
0
#!/usr/bin/python
#
# Simple smiley for Adafruit 8x8 LED Backpack
#
# (C) 2014 PiClass - BSD License
#
from Adafruit_8x8 import EightByEight

grid = EightByEight(address=0x70)

# Clear the grid
grid.clear()

# Switch on leds line by line
grid.setPixel(0, 2)
grid.setPixel(0, 3)
grid.setPixel(0, 4)
grid.setPixel(0, 5)

grid.setPixel(1, 1)
grid.setPixel(1, 6)

grid.setPixel(2, 0)
grid.setPixel(2, 2)
grid.setPixel(2, 4)
grid.setPixel(2, 7)

grid.setPixel(3, 0)
grid.setPixel(3, 5)
grid.setPixel(3, 7)
Пример #3
0
#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import EightByEight

# source: https://github.com/pdp7/beaglebackpack/blob/master/README.md
# ===========================================================================
# 8x8 Pixel Example
# ===========================================================================
grid = EightByEight(address=0x70)
grid2 = EightByEight(address=0x71)

print "Press CTRL+Z to exit"

# Continually update the 8x8 display one pixel at a time
while (True):
    for x in range(0, 8):
        for y in range(0, 8):
            grid.setPixel(x, y)
            grid2.setPixel(x, y)
            time.sleep(0.1)
    time.sleep(0.5)
    grid.clear()
    grid2.clear()
    time.sleep(0.5)
Пример #4
0
#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import EightByEight
import LetterArrays

grid = EightByEight(address=0x70)

def drawFrame(frame, grid, dur=0):
    for pix in frame:
        grid.setPixel(pix[0],pix[1])
        time.sleep(dur)


word = LetterArrays.wordForOutput
#loop through the letters
while (True):
    for letter in word:
        if letter in LetterArrays.CHARS:
            c = LetterArrays.CHARS[letter]
            c = LetterArrays.CHARS[letter]
            drawFrame(c, grid)
            time.sleep(0.5)
            grid.clear()

    reload(LetterArrays)
    word = LetterArrays.wordForOutput
Пример #5
0
# source: https://github.com/pdp7/beaglebackpack/blob/master/README.md
# ===========================================================================
# title: beaglebone black with adafruit 8x8 LED matrix facebook notification display
# author: drew fustini (http://element14.com/fustini)
# blog: http://www.element14.com/community/community/knode/single-board_computers/next-gen_beaglebone/blog/
#
# method 1: get short term (2 hour) access_token from:
#    https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fnotifications
# method 2: get extended (60 days) access_token via instructions at:
#    http://fearofcoding.blogspot.com/2012/10/python-script-to-fetch-messages-from.html
#    note: install the needed python module with "pip install facepy"
# ===========================================================================

access_token = "CAAH9yZAk1AN8BABX35A2uZCvySRZAP00qrEsn9CcrHmvMChvXn8EuwnQvHN0tlI4SF2gWvfBTjWZAW3gYcHXhc2qutPgRBGF7V6u85mTsFRvNk96h3fg9rYtObZCkV8wd000ubiVTKXw5qiuGWKztmbeolxTWDh2O5gzQvdr3Pf3wyuLb0cVMqe8pGWx5GF8ZD"

grid = EightByEight(address=0x70)

print "Press CTRL+C to exit"

# Continually update the current unseen notification count on a 4 char, 7-segment display
while(True):
  grid.clear()
  graph = facebook.GraphAPI(access_token)
  notifications  = graph.get_object("me/notifications")
  print "notifications"
  print notifications
  summary = notifications['summary']
  if summary:
    num = summary['unseen_count']
    print num
    min=0
#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import EightByEight

# ===========================================================================
# 8x8 Pixel Example
# ===========================================================================
grid = EightByEight(address=0x70)

print("Press CTRL+Z to exit")

# Continually update the 8x8 display one pixel at a time
while(True):
  for x in range(0, 8):
    for y in range(0, 8):
      grid.setPixel(x, y)
      time.sleep(0.05)
  time.sleep(0.5)
  grid.clear()
  time.sleep(0.5)
Пример #7
0
#!/usr/bin/python

import os
import time
import datetime

from Adafruit_8x8 import EightByEight

import NSEphem

try:
   grid = EightByEight(address=0x70)
except IOError:
   print "LED Grid not connected, exiting"
   exit()

def flash(r,c,cnt,t):
   if ( cnt*2 > t ):
      if (t % 2 == 0 ):
        grid.setPixel(r,7-c,1)
      else:
        grid.setPixel(r,7-c,0)
   else:
      grid.setPixel(r,7-c,0)

ticks = 0
day_done = -1

while (True): 

   # refresh strings every day at 8AM
Пример #8
0
    digitCount += 1
    decimalPoint = ((digitCount + 1) == decimal)

    display.writeDigit(4, temp % 10, decimalPoint)  # Ones


#
# ======================================================================================================
# Clock using the DS1307 RTC, 7-segment and matrix 8x8 displays, and 10DOF IMU for temperature readings
# ======================================================================================================
#
#	Green 4 digit 7-Segment Display at address 0x70
sevenSeg = SevenSegment(address=0x70)

#	Green Small  Matrix 8x8 Display at address 0x73
matrix8x8 = EightByEight(address=0x73)

#	Bi-Color Matrix 8x8 Display at address 0x73
#bicolor8x8 = ColorEightByEight(address=0x73)

#	Don't need to set rotation for the mini 8x8 matrix displays
#matrix8x8.setRotation(3)
#bicolor8x8.setRotation(3)

print "Press CTRL+C to exit"

#
#	Settings variables that control the loops and frequency of displays
#
maxSeconds = 45
dateFreq = 15.0
Пример #9
0
 def __init__(self):
     self.grid = EightByEight(address=0x70)
     self.pixels = {}
Пример #10
0
#!/usr/bin/python

import time

from Adafruit_8x8 import EightByEight

# ===========================================================================
# 8x8 Pixel Example
# ===========================================================================
grid1 = EightByEight(address=0x70)
grid2 = EightByEight(address=0x71)

print "Press CTRL+Z to exit"

# Continually update the 8x8 display one pixel at a time
while (True):
    for x in range(0, 8):
        for y in range(0, 8):
            grid1.setPixel(x, y)
            grid2.setPixel(x, y)
            time.sleep(0.05)
    time.sleep(0.5)
    grid1.clear()
    grid2.clear()
    time.sleep(0.5)
Пример #11
0
#!/usr/bin/python

from Adafruit_ADS1x15 import ADS1x15
import time, math
import datetime
from Adafruit_8x8 import EightByEight
import Adafruit_LEDBackpack
from subprocess import *
from time import sleep, strftime
from datetime import datetime
from Alpha8x8 import Alpha8x8

# ===========================================================================
# 8x8 Pixel Example
# ===========================================================================
grid = EightByEight(address=0x70)
led = Adafruit_LEDBackpack.LEDBackpack(0x70)
led.setBrightness = 1

print "Press CTRL+C to exit"

display = 0

cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"


def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output
Пример #12
0
#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import EightByEight

grid = EightByEight(address=0x70)

smile_bmp = [
    0b00011110, 0b00100001, 0b11010010, 0b11000000, 0b11010010, 0b11001100,
    0b00100001, 0b00011110
]
neutral_bmp = [
    0b00011110, 0b00100001, 0b11010010, 0b11000000, 0b11011110, 0b11000000,
    0b00100001, 0b00011110
]
frown_bmp = [
    0b00011110, 0b00100001, 0b11010010, 0b11000000, 0b11001100, 0b11010010,
    0b00100001, 0b00011110
]

# Write a smiley face
for i in range(0, 8):
    grid.writeRowRaw(i, smile_bmp[i])
time.sleep(.33)

# Write a neutral face
for i in range(0, 8):
    grid.writeRowRaw(i, neutral_bmp[i])
time.sleep(.33)
Пример #13
0
# source: https://github.com/pdp7/beaglebackpack/blob/master/README.md
# ===========================================================================
# title: beaglebone black with adafruit 8x8 LED matrix facebook notification display
# author: drew fustini (http://element14.com/fustini)
# blog: http://www.element14.com/community/community/knode/single-board_computers/next-gen_beaglebone/blog/
#
# method 1: get short term (2 hour) access_token from:
#    https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fnotifications
# method 2: get extended (60 days) access_token via instructions at:
#    http://fearofcoding.blogspot.com/2012/10/python-script-to-fetch-messages-from.html
#    note: install the needed python module with "pip install facepy"
# ===========================================================================

access_token = "CAAH9yZAk1AN8BABX35A2uZCvySRZAP00qrEsn9CcrHmvMChvXn8EuwnQvHN0tlI4SF2gWvfBTjWZAW3gYcHXhc2qutPgRBGF7V6u85mTsFRvNk96h3fg9rYtObZCkV8wd000ubiVTKXw5qiuGWKztmbeolxTWDh2O5gzQvdr3Pf3wyuLb0cVMqe8pGWx5GF8ZD"

grid = EightByEight(address=0x70)

print "Press CTRL+C to exit"

# Continually update the current unseen notification count on a 4 char, 7-segment display
while (True):
    grid.clear()
    graph = facebook.GraphAPI(access_token)
    notifications = graph.get_object("me/notifications")
    print "notifications"
    print notifications
    summary = notifications['summary']
    if summary:
        num = summary['unseen_count']
        print num
        min = 0
Пример #14
0
#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import EightByEight
import LetterArrays

grid = EightByEight(address=0x70)


def drawFrame(frame, grid, dur=0):
    for pix in frame:
        grid.setPixel(pix[0], pix[1])
        time.sleep(dur)


word = LetterArrays.wordForOutput
#loop through the letters
while (True):
    for letter in word:
        if letter in LetterArrays.CHARS:
            c = LetterArrays.CHARS[letter]
            c = LetterArrays.CHARS[letter]
            drawFrame(c, grid)
            time.sleep(0.5)
            grid.clear()

    reload(LetterArrays)
    word = LetterArrays.wordForOutput
Пример #15
0
#!/usr/bin/python
#
# Tiny boat for Adafruit 8x8 LED Backpack
#
# (C) 2014 PiClass - BSD License
#
from Adafruit_8x8 import EightByEight

grid = EightByEight(address=0x70)

# Clear the grid
grid.clear()

# Switch on leds
grid.setPixel(0, 5)
grid.setPixel(1, 5)
grid.setPixel(1, 6)
grid.setPixel(2, 5)
grid.setPixel(2, 6)
grid.setPixel(2, 7)
grid.setPixel(3, 5)
grid.setPixel(3, 6)
grid.setPixel(3, 7)
grid.setPixel(4, 5)
grid.setPixel(4, 6)
grid.setPixel(4, 7)
grid.setPixel(5, 5)
grid.setPixel(5, 6)
grid.setPixel(5, 7)
grid.setPixel(6, 5)
grid.setPixel(6, 6)
Пример #16
0
#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import EightByEight
from flask import Flask
from flask.ext.restful import Api, Resource


app = Flask(__name__)
api = Api(app)
grid = []
for i in range(0,8):
  grid.append(EightByEight(address=0x70+i))

class 8X8Matrix(Resource):
    def get(self):
      pass

    def put(self, id):
      for x in range(0, 8):
      for y in range(0, 8):
        grid[id].setPixel(x, y)
        time.sleep(0.01)

    def delete(self, id):
      pass

api.add_resource(8X8Matrix, /8x8/<int:id>, endpoint = '8x8')

Пример #17
0
#!/usr/bin/python

from Adafruit_LEDBackpack import LEDBackpack
from Adafruit_8x8 import EightByEight
import time
import datetime

grid = EightByEight(address=0x70)

#smile_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11010010,0b11001100,0b00100001,0b00011110]
#neutral_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11011110,0b11000000,0b00100001,0b00011110]
#frown_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11001100,0b11010010,0b00100001,0b00011110]

smile_bmp = [
    0b00111100, 0b01000010, 0b10100101, 0b10000001, 0b10100101, 0b10011001,
    0b01000010, 0b00111100
]
frown_bmp = [
    0b00111100, 0b01000010, 0b10100101, 0b10000001, 0b10011001, 0b10100101,
    0b01000010, 0b00111100
]
scream_bmp = [
    0b00111100, 0b01000010, 0b10100101, 0b10000001, 0b10011001, 0b10111101,
    0b01000010, 0b00111100
]
neutral_bmp = [
    0b00111100, 0b01000010, 0b10100101, 0b10000001, 0b10111101, 0b10000001,
    0b01000010, 0b00111100
]
grin_bmp = [
    0b00111100, 0b01000010, 0b10100101, 0b10000001, 0b10111101, 0b10111101,
Пример #18
0
def handleDue(estimatedTime):
    if estimatedTime == '0':
        estimatedTime = '*'
    return estimatedTime


def printToMatrix(grid, stringInList, starty=0, startx=0):
    for letter, char in enumerate(handleDue(stringInList)):
        for ypos, bitRow in enumerate(font[char], starty):
            for xpos, bit in enumerate(bitRow,
                                       startx + letter * len(bitRow) + letter):
                grid.setPixel(ypos, xpos, bit)


lhs = EightByEight(address=0x70)
rhs = EightByEight(address=0x71)

url = 'https://api.tfl.gov.uk/line/e3,440,n11/arrivals/490010968V?direction=outbound&app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY'

while True:
    try:
        response = urlopen(url)
        data = loads(response.read())
        #print data
        #print '------------------------------------'
        nextThreeE3 = sorted([
            str(buses['timeToStation'] / 60)
            for buses in data if buses['lineId'] == 'e3'
        ],
                             key=int)[:3]
Пример #19
0
#!/usr/bin/python
#
# Tiny boat for Adafruit 8x8 LED Backpack
#
# (C) 2014 PiClass - BSD License
#
from Adafruit_8x8 import EightByEight
grid = EightByEight(address=0x70)
 
# Clear the grid
grid.clear()

# Switch on leds
grid.setPixel(0, 5)
grid.setPixel(0, 7)

grid.setPixel(1, 4)
grid.setPixel(1, 5)
grid.setPixel(1, 6)

grid.setPixel(2, 2)
grid.setPixel(2, 4)
grid.setPixel(2, 5)

grid.setPixel(3, 3)
grid.setPixel(3, 4)
grid.setPixel(3, 5)

grid.setPixel(4, 3)
grid.setPixel(4, 4)
grid.setPixel(4, 5)
Пример #20
0
 def __init__(self):
     self.grid1 = EightByEight(address=0x71)
     self.grid2 = EightByEight(address=0x70)
     self.ticker = []
     self.buffer = []
     self.display = []
Пример #21
0
#!/usr/bin/python

import time
from Adafruit_8x8 import EightByEight

MATRICES = 1
matrix = []

for i in range(0, MATRICES):
    matrix.append(EightByEight(address=0x70 + i))
    matrix[i].setTextWrap(False)  # Allow text to run off edges
    matrix[i].setRotation(3)
    matrix[i].setBrightness(15)

message = 'acegijlmnopqrsuvwxyz'

# Horiz. position of text -- starts off right edge
x = 7 * MATRICES

while True:
    for i in range(0, MATRICES):
        # Draw message in each matrix buffer, offseting each by 8 pixels
        matrix[i].clear()
        matrix[i].setCursor(x - i * 7, 0)
        matrix[i].printMessage(message)

    # Write data to matrices in separate loop so it's less jumpy
    for i in range(0, MATRICES):
        matrix[i].writeDisplay()

    #print('Test')
#!/usr/bin/python
# A bunch of random tests for drawing GFX on the matrices

import time
from glcdfont import glcdfont
from Adafruit_8x8 import EightByEight

grid1 = EightByEight(address=0x70)
grid2 = EightByEight(address=0x71)
grid3 = EightByEight(address=0x72)
grid1.setBrightness(8)
grid2.setBrightness(8)
grid3.setBrightness(8)
font = glcdfont().getfont()

#print(font)
grid1.fillScreen()
grid1.writeDisplay()
time.sleep(.25)
grid1.clear()

grid2.fillScreen()
grid2.writeDisplay()
time.sleep(.25)
grid2.clear()

grid3.fillScreen()
grid3.writeDisplay()
time.sleep(.25)
grid3.clear()
Пример #23
0
    digitCount += 1
    decimalPoint = ((digitCount + 1) == decimal)

    display.writeDigit(4, temp % 10, decimalPoint)  # Ones


#
# ======================================================================================================
# Clock using the DS1307 RTC, 7-segment and matrix 8x8 displays, and 10DOF IMU for temperature readings
# ======================================================================================================
#
#	Yellow 4 digit 7-Segment Display at address 0x70
sevenSeg = SevenSegment(address=0x70)

#	Yellow Matrix 8x8 Display at address 0x71
matrix8x8 = EightByEight(address=0x71)

#	Bi-Color Matrix 8x8 Display at address 0x73
#bicolor8x8 = ColorEightByEight(address=0x73)

matrix8x8.setRotation(3)
#bicolor8x8.setRotation(3)

bmp180 = BMP180(address=0x77)

print "Press CTRL+C to exit"

#
#	Settings variables that control the loops and frequency of displays
#
maxSeconds = 45
Пример #24
0
#!/usr/bin/python
# A bunch of random tests for drawing GFX on the matrices

import time
from glcdfont import glcdfont
from Adafruit_8x8 import EightByEight

grid1 = EightByEight(address=0x70)
grid2 = EightByEight(address=0x71)
grid3 = EightByEight(address=0x72)
grid1.setBrightness(8)
grid2.setBrightness(8)
grid3.setBrightness(8)
font = glcdfont().getfont()

#print(font)
grid1.fillScreen()
grid1.writeDisplay()
time.sleep(.25)
grid1.clear()

grid2.fillScreen()
grid2.writeDisplay()
time.sleep(.25)
grid2.clear()

grid3.fillScreen()
grid3.writeDisplay()
time.sleep(.25)
grid3.clear()