Esempio n. 1
0
import sys
import random
import colorsys
import threading

# Initiate motor controller
pz.init()
animation = None

# Control Setup
left_stick = 0.0
right_stick = 0.0

# ACTIVATE BLINKY LIGHTS
pz.setOutputConfig(5, 3)
pz.setBrightness(255)


class Animation(threading.Thread):
    daemon = True

    def __init__(self):
        super(Animation, self).__init__()
        self.style = None

    def run(self, target):
        while self.running:
            self.next_color()
            time.sleep(self.sleeptime)

    def stop(self):
Esempio n. 2
0
import piconzero as pz, time

pz.init()
pz.setOutputConfig(5, 3)    # set output 5 to WS2812
pz.setBrightness(15)

delay = 0.1
colour = [0,255,125] # colour format of LEDs 0 to 7 is G R B

# Set rear light to Red
for posistion in range(4, 8, 1):
    pz.setPixel(posistion, 0, 255, 0)

try:
    while True:
        for posistion in range(0,4,1):
            pz.setPixel(posistion, colour[0], colour[1], colour[2])
            time.sleep(delay)
            for off in range(0, 4, 1):
                pz.setPixel(off, 0,0,0)
            time.sleep(delay)
        for posistion in range(2, 0, -1):
            pz.setPixel(posistion, colour[0], colour[1], colour[2])
            time.sleep(delay)
            for off in range(0, 4, 1):
                pz.setPixel(off, 0, 0, 0)
            time.sleep(delay)
except KeyboardInterrupt:
    print ('finished')
finally:
    pz.cleanup()
Esempio n. 3
0
import piconzero as pz, time

pz.init()
pz.setOutputConfig(5, 3)  # set output 5 to WS2812
pz.setBrightness(15)

delay = 0.1
colour = [0, 255, 125]  # colour format of LEDs 0 to 7 is G R B

# Set rear light to Red
for posistion in range(4, 8, 1):
    pz.setPixel(posistion, 0, 255, 0)

try:
    while True:
        for posistion in range(0, 4, 1):
            pz.setPixel(posistion, colour[0], colour[1], colour[2])
            time.sleep(delay)
            for off in range(0, 4, 1):
                pz.setPixel(off, 0, 0, 0)
            time.sleep(delay)
        for posistion in range(2, 0, -1):
            pz.setPixel(posistion, colour[0], colour[1], colour[2])
            time.sleep(delay)
            for off in range(0, 4, 1):
                pz.setPixel(off, 0, 0, 0)
            time.sleep(delay)
except KeyboardInterrupt:
    print('finished')
finally:
    pz.cleanup()
Esempio n. 4
0
                #shutslot=2 #doesn't change. set in intialisation
                shutcount = 0  #reset shutcount
                change(-1)  #close mouth

        #now process brigthness level
        v = pz.readInput(0)  # read adc value from audio input
        b = min(100, 5 * (abs(v - offset)) + 5)  #calcuate next brigthness
        print(b)  #print to terminal

        #check for offset calibration button
        trigger = pz.readInput(1)  #check for button pressed
        if trigger == 0:  #normally high: 0 if pushed
            offset = v  #update offset value from current adc value

        #now adjust brightness if changed sufficiently
        if abs(
                blast - b
        ) > 10:  #check if brightness has changed by at least 10 to reduce noise
            pz.setBrightness(b)  #update brightness
            pz.updatePixels()  #update all pixels
            blast = b  #save brightness value

        time.sleep(
            0.01
        )  #short sleep to keep response time good, just enough to allow ctrl-C to get a look in

except KeyboardInterrupt:
    print
finally:
    pz.cleanup()  #reset picon zero board
Esempio n. 5
0
import sys
import random
import colorsys
import threading

# Initiate motor controller
pz.init()
animation = None

# Control Setup
left_stick = 0.0
right_stick = 0.0

# ACTIVATE BLINKY LIGHTS
pz.setOutputConfig(5,3)
pz.setBrightness(150)

class Animation(threading.Thread):

    daemon = True
    def __init__(self):
        super(Animation, self).__init__()
        self.style = None

    def run(self, *args):

        while self.run:
            self.next_color()
            time.sleep(self.sleeptime)

    def stop(self):
Esempio n. 6
0
def toggleLight():
        global light
        light = (light+1)%4
        if (light == 0):
                pz.setAllPixels(0,0,0)
        elif (light == 1) :
                pz.setAllPixels(255,255,255)
        elif (light == 2) :
                pz.setAllPixels(0,255,0)
        elif (light == 3) :
                pz.setAllPixels(255,0,0)
				
pz.init()
pz.setOutputConfig(0,2)
pz.setOutputConfig(5,3)
pz.setBrightness(100)
pz.setOutput(0,angle)
ultra.init()

app = Flask(__name__)

@app.route('/')
def index():
    """Video streaming home page."""
    return render_template('index.html')


def gen(camera):
    """Video streaming generator function."""
    while True:
		frame = camera.get_frame()