示例#1
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
示例#2
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,
示例#3
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')
示例#4
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)
示例#5
0
 def __init__(self):
     self.grid1 = EightByEight(address=0x71)
     self.grid2 = EightByEight(address=0x70)
     self.ticker = []
     self.buffer = []
     self.display = []
示例#6
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]
示例#7
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')

示例#8
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()