Ejemplo n.º 1
0
 def __init__(self, address=0x70, segments=1, debug=False):
     "Construct a display consisting of one or more 4-digit segments."
     # Save the upper limit for convenience
     self.maxDigit = 4 * segments
     self.debug = debug
     for segment in range(segments):
         addr = address + segment
         if (debug):
             print "Initializing a new instance of LEDBackpack at 0x%02X" % addr
         self.disp.append(LEDBackpack(address=addr, debug=debug))
Ejemplo n.º 2
0
 def __init__(self, address=0x70, debug=False):
     if (debug):
         print "Initializing a new instance of LEDBackpack at 0x%02X" % address
     self.disp = LEDBackpack(address=address, debug=debug)
Ejemplo n.º 3
0
#!/usr/bin/env python

import time, sys
from Adafruit_LEDBackpack import LEDBackpack
from LEDLetterValues import *
from timeit import default_timer
grids = [LEDBackpack(address=i) for i in range(0x70, 0x74)]

wait_time = float(
    sys.argv[2] if len(sys.argv) > 2 else raw_input("Wait time: "))
text = sys.argv[1] if len(
    sys.argv) > 1 else raw_input("What should I scroll: ")
printcon = textTo2D(text)

print "Press CTRL+C to exit"


def main():
    scrolled = 0
    while True:
        start = default_timer()
        for y, v in enumerate(printcon):
            buffers = [0x00, 0x00, 0x00, 0x00]
            for x, i in enumerate(v):
                if i:
                    a = x - scrolled
                    if a >= 0 and a < len(grids) * 16:
                        buffers[a // 16] = buffers[a // 16] | 1 << (a % 16)
            for i, grid in enumerate(grids):
                grid.setBufferRow(y, buffers[i], update=False)
Ejemplo n.º 4
0
# function to return a datastream object. This either creates a new datastream,
# or returns an existing one
def get_datastream(feed):
    try:
        datastream = feed.datastreams.get("external_temp")
        return datastream
    except:
        datastream = feed.datastreams.create("external_temp", tags="temp_01")
        return datastream


# ===========================================================================
# Clock Example
# ===========================================================================
led = LEDBackpack(address=0x70)

segment = SevenSegment(address=0x70)

try:
    interval = int(sys.argv[1])
except:
    print 'Interval required'
    sys.exit(1)

daybrightness = 15
nightbrightness = 5

minbrightness = 1
maxbrightness = 15
Ejemplo n.º 5
0
# Blink rate
__HT16K33_BLINKRATE_OFF = 0x00
__HT16K33_BLINKRATE_2HZ = 0x01
__HT16K33_BLINKRATE_1HZ = 0x02
__HT16K33_BLINKRATE_HALFHZ = 0x03

#Colors

__HT16K33_OFF = 0
__HT16K33_GREEN = 1
__HT16K33_RED = 2
__HT16K33_YELLOW = 3

# setup backpack
grid = ColorEightByEight(address=0x72)
backpack = LEDBackpack(address=0x72)

# command from RasPiConnect Execution Code


def completeCommand():

    f = open("/home/pi/MouseAir/state/MouseCommand.txt", "w")
    f.write("DONE")
    f.close()


def processCommand():

    f = open("/home/pi/MouseAir/state/MouseCommand.txt", "r")
    command = f.read()
Ejemplo n.º 6
0
 def __init__(self, address=0x70, debug=False):
     self.disp = LEDBackpack(address=address, debug=debug)
Ejemplo n.º 7
0
#!/usr/bin/env python

import time
import datetime
from Adafruit_7Segment import SevenSegment
from Adafruit_LEDBackpack import LEDBackpack
import signal
import sys

segment = SevenSegment(address=0x70)
seven = LEDBackpack(address=0x70)

# Kinda pack-rat-ish.. these are crumbs I'd like to implement
seven.setBrightness(15)


def exit_gracefully(signum, frame):
    # let's restore the original signal handlers
    signal.signal(signal.SIGTERM, original_sigterm)
    signal.signal(signal.SIGINT, original_sigint)
    signal.signal(signal.SIGHUP, original_sighup)

    # clean up gracefully here. bail when done.
    seven.clear()
    sys.exit(0)

    #just in case we do something during cleanup that means we *shouldn't" exit, we want our handler to stay intact.
    signal.signal(signal.SIGTERM, exit_gracefully)
    signal.signal(signal.SIGINT, exit_gracefully)
    signal.signal(signal.SIGHUP, exit_gracefully)