Example #1
0
def init():
    """Returns an OpenWestKit object and makes the brightness tolerable. :)"""
    openwestkit = OpenWestKit()
    openwestkit.brightness(16) #16 doesn't blind me when I stare

    return openwestkit
Example #2
0
# Flashing siren, use buttons to enable and disable
import signal
import sys
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()

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':
signal.signal(signal.SIGINT, handleSignal)


def changeSpeed(code, speed):
    if code == 'a':  # button 1 was pressed, speed up
        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)
Example #4
0
import math
import urllib2
import base64
import webbrowser
from xml.dom.minidom import parse, parseString
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()

# programming logic begins

new_emails = False
# 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
import urllib2
import base64
import webbrowser
from xml.dom.minidom import parse, parseString
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()

# programming logic begins

new_emails = False
# 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

def changeSpeed(code, speed):
    if code == 'a':  # button 1 was pressed, speed up
        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
Example #7
0
# Glowing Pixel - glows softly to full brightness and out looped
import signal
import sys
import time
import math

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()

# programming logic begins
angle_step = 0.05  # reduce the step to make the glow seq slower
angle = 0
while 1:
    # determine the strength of the pixel as white
    color = int(abs(math.sin(angle) * 155))  # set pixel brightness (max 255)
    openwestkit.setPixel(0, color, 0, 0)
    angle += angle_step
    time.sleep(0.001)
Example #8
0
import signal
import sys
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)
Example #9
0
import signal
import sys
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)
Example #10
0
import signal
import sys
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()

openwestkit.reset()
brightness = 65
while (1):
    openwestkit.brightness(brightness)
    time.sleep(1)

    for code in openwestkit.readData():
        if code == 'a':
            brightness -= 5
        elif code == 'b':
            brightness += 5

    # max
    if brightness > 255:
Example #11
0
    openwestkit.reset()
    sys.exit(0)

signal.signal(signal.SIGINT, handleSignal)

def inputs(code):
    if code == 'a':
        inputs.button1 = 1
    elif code == 'b':
        inputs.button2 = 1
    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)
Example #12
0
# Glowing Pixel - glows softly to full brightness and out looped
import signal
import sys
import time
import math

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()

# programming logic begins
angle_step = .05  # reduce the step to make the glow seq slower
angle = 0
while (1):
    # determine the strength of the pixel as white
    color = int(abs(math.sin(angle) * 155))  # set pixel brightness (max 255)
    openwestkit.setPixel(0, color, 0, 0)
    angle += angle_step
    time.sleep(.001)
Example #13
0
# lower the brightness
import signal
import sys
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()

openwestkit.reset()
brightness = 65
while(1):
    openwestkit.brightness(brightness)
    time.sleep(1)

    for code in openwestkit.readData():
        if code == 'a':
            brightness -= 5
        elif code == 'b':
            brightness += 5

    # max
    if brightness > 255:
Example #14
0
import signal
import sys
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()

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':
Example #15
0
signal.signal(signal.SIGINT, handleSignal)


def inputs(code):
    if code == 'a':
        inputs.button1 = 1
    elif code == 'b':
        inputs.button2 = 1
    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: