Exemple #1
0

# signal handler that resets the board when ctrl-c is pressed
def handleSignal(signal, frame):
    openwestkit.reset()
    sys.exit(0)

signal.signal(signal.SIGINT, handleSignal)

openwestkit = OpenWestKit()

on = True
while (1):
    if on:
        openwestkit.clear()
        openwestkit.setPixel(0, 0, 0, 255)
        openwestkit.setPixel(3, 0, 0, 255)
        time.sleep(.1)
        openwestkit.clear()
        openwestkit.setPixel(1, 255, 0, 0)
        openwestkit.setPixel(2, 255, 0, 0)
        time.sleep(.1)

    for code in openwestkit.readData():
        if code == 'a':
            on = False
            for pos in range(0, 4):
                openwestkit.setPixel(pos, 0, 0, 0)
        elif code == 'b':
            on = True
        speed -= .05
    elif code == 'b':  # button 2 was pressed, slow down
        speed += .05

    # Safety check as we can't sleep for less than zero time
    if speed <= 0:
        speed = .05

    return speed

openwestkit = OpenWestKit(debug=True)

speed = 1
while (1):
    for pixelNum in range(0, 4):

        # Pick a random color
        r, g, b = random.randrange(255), random.randrange(255), random.randrange(255)

        openwestkit.setPixel(pixelNum, r, g, b)
        for code in openwestkit.readData():
            speed = changeSpeed(code, speed)

        print "Current speed", speed

        time.sleep(speed)

        openwestkit.setPixel(pixelNum, 0, 0, 0)
        for code in openwestkit.readData():
            speed = changeSpeed(code, speed)
# store the first email link
first_entry_link = None

gmail_username = ""
gmail_password = ""
gmail_atom_feed_url = "https://mail.google.com/mail/feed/atom"

global_count = 0

angle_step = .05 # reduce the step to make the glow seq slower
angle = 0
while (1):
    if (new_emails):
        # determine the strength of the pixel as white
        color = int(abs(math.sin(angle) * 155)) # set pixel brightness (max 255)
        openwestkit.setPixel(0, 0, color, 0)
        angle += angle_step
        
        # check for button press to read new emails
        for code in openwestkit.readData():
            if code == 'a' or code == 'b':
                # open browser window
                new_emails = False
                try:
                    # try to invoke a browser
                    webbrowser.open(first_entry_link, 2)
                except:
                    pass

    else:
        # no new emails, let's reset the pixel and angle
first_entry_link = None

gmail_username = ""
gmail_password = ""
gmail_atom_feed_url = "https://mail.google.com/mail/feed/atom"

global_count = 0

angle_step = .05  # reduce the step to make the glow seq slower
angle = 0
while (1):
    if (new_emails):
        # determine the strength of the pixel as white
        color = int(abs(math.sin(angle) *
                        155))  # set pixel brightness (max 255)
        openwestkit.setPixel(0, 0, color, 0)
        angle += angle_step

        # check for button press to read new emails
        for code in openwestkit.readData():
            if code == 'a' or code == 'b':
                # open browser window
                new_emails = False
                try:
                    # try to invoke a browser
                    webbrowser.open(first_entry_link, 2)
                except:
                    pass

    else:
        # no new emails, let's reset the pixel and angle
        speed += .05

    # Safety check as we can't sleep for less than zero time
    if speed <= 0:
        speed = .05

    return speed


openwestkit = OpenWestKit(debug=True)

speed = 1
while (1):
    for pixelNum in range(0, 4):

        # Pick a random color
        r, g, b = random.randrange(255), random.randrange(
            255), random.randrange(255)

        openwestkit.setPixel(pixelNum, r, g, b)
        for code in openwestkit.readData():
            speed = changeSpeed(code, speed)

        print "Current speed", speed

        time.sleep(speed)

        openwestkit.setPixel(pixelNum, 0, 0, 0)
        for code in openwestkit.readData():
            speed = changeSpeed(code, speed)
Exemple #6
0
import time

from openwestkit import OpenWestKit


# signal handler that resets the board when ctrl-c is pressed
def handleSignal(signal, frame):
    openwestkit.reset()
    sys.exit(0)


signal.signal(signal.SIGINT, handleSignal)

openwestkit = OpenWestKit()

while 1:
    # Green light
    openwestkit.clear()
    openwestkit.setPixel(2, 0, 255, 0)
    time.sleep(3)

    # Yellow light
    openwestkit.clear()
    openwestkit.setPixel(1, 255, 255, 0)
    time.sleep(1)

    # Red light
    openwestkit.clear()
    openwestkit.setPixel(0, 255, 0, 0)
    time.sleep(3)
import time

from openwestkit import OpenWestKit


# signal handler that resets the board when ctrl-c is pressed
def handleSignal(signal, frame):
    openwestkit.reset()
    sys.exit(0)


signal.signal(signal.SIGINT, handleSignal)

openwestkit = OpenWestKit()

while (1):
    # Green light
    openwestkit.clear()
    openwestkit.setPixel(2, 0, 255, 0)
    time.sleep(3)

    # Yellow light
    openwestkit.clear()
    openwestkit.setPixel(1, 255, 255, 0)
    time.sleep(1)

    # Red light
    openwestkit.clear()
    openwestkit.setPixel(0, 255, 0, 0)
    time.sleep(3)
    elif code == 'A':
        inputs.button1 = 0
    elif code == 'B':
        inputs.button2 = 0

openwestkit = OpenWestKit(debug=True)

inputs.button1 = 0
inputs.button2 = 0
while (1):

    # Pick a random color
    r, g, b = random.randrange(255), random.randrange(255), random.randrange(255)

    time.sleep(0.05)

    for code in openwestkit.readData():
        inputs(code)

    if inputs.button1 == 1:
        openwestkit.setPixel(0, r, g, b)
        openwestkit.setPixel(1, 50, 50, 50)
    else:
        openwestkit.setPixel(1, 0, 0, 0)

    if inputs.button2 == 1:
        openwestkit.setPixel(3, r, g, b)
        openwestkit.setPixel(2, 25, 25, 25)
    else:
        openwestkit.setPixel(2, 0, 0, 0)
Exemple #9
0
# signal handler that resets the board when ctrl-c is pressed
def handleSignal(signal, frame):
    openwestkit.reset()
    sys.exit(0)


signal.signal(signal.SIGINT, handleSignal)

openwestkit = OpenWestKit()

on = True
while (1):
    if on:
        openwestkit.clear()
        openwestkit.setPixel(0, 0, 0, 255)
        openwestkit.setPixel(3, 0, 0, 255)
        time.sleep(.1)
        openwestkit.clear()
        openwestkit.setPixel(1, 255, 0, 0)
        openwestkit.setPixel(2, 255, 0, 0)
        time.sleep(.1)

    for code in openwestkit.readData():
        if code == 'a':
            on = False
            for pos in range(0, 4):
                openwestkit.setPixel(pos, 0, 0, 0)
        elif code == 'b':
            on = True
Exemple #10
0
    elif code == 'B':
        inputs.button2 = 0


openwestkit = OpenWestKit(debug=True)

inputs.button1 = 0
inputs.button2 = 0
while (1):

    # Pick a random color
    r, g, b = random.randrange(255), random.randrange(255), random.randrange(
        255)

    time.sleep(0.05)

    for code in openwestkit.readData():
        inputs(code)

    if inputs.button1 == 1:
        openwestkit.setPixel(0, r, g, b)
        openwestkit.setPixel(1, 50, 50, 50)
    else:
        openwestkit.setPixel(1, 0, 0, 0)

    if inputs.button2 == 1:
        openwestkit.setPixel(3, r, g, b)
        openwestkit.setPixel(2, 25, 25, 25)
    else:
        openwestkit.setPixel(2, 0, 0, 0)