Exemplo n.º 1
0
def neoPixelLight(direction):
    # setup neopixel output
    pz.setOutputConfig(5, 3)
    if direction == "forward":
        pz.setAllPixels(255, 0, 0)
    elif direction == "backward":
        pz.setAllPixels(255, 255, 0)
    elif direction == "left":
        pz.setAllPixels(127, 127, 255)
    elif direction == "right":
        pz.setAllPixels(255, 255, 255)
    elif direction == "off":
        pz.setAllPixels(0, 0, 0)
Exemplo n.º 2
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)
Exemplo n.º 3
0
def distance2Pixel(dist):
    pz.setAllPixels(0, 0, 0)
    if (dist > 80):
        dist = 80
    if (dist < 15):
        green = 0
        red = 255
        blue = 0
    elif (dist < 30):
        green = 165
        red = 255
        blue = 0
    else:
        green = 255
        red = 0
        blue = 0

    for i in range(8 - dist / 10):
        pz.setPixel(i, red, green, blue)
Exemplo n.º 4
0
def clearFace():
    pz.setAllPixels(0, 0, 0)
Exemplo n.º 5
0
#! /usr/bin/env python

#testLedNumbers.py
# Testing McRoboFace led positions.
# requires picon zero hardware plus software library

import piconzero as pz, time

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

try:
    while True:
        for i in xrange(0, 17):
            pz.setPixel(i, 0, 0, 255)
            time.sleep(0.5)
        pz.setAllPixels(0, 0, 0)
        time.sleep(0.5)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()  #reset picon zero board
Exemplo n.º 6
0
    pz.setPixel(5, 128, 0, 128, False)  #other end of mouth

    if t == 1:  #going for open mouth
        for i in xrange(1, 5):  #mouth set pixels for open state
            pz.setPixel(i, 128, 0, 128, False)
            pz.setPixel(i + 5, 128, 0, 128, False)
        for i in xrange(10, 14):  #pixels for closed mouth turned off
            pz.setPixel(i, 0, 0, 0, False)
    else:  #going for closed mouth
        for i in xrange(1, 5):  #mouth
            pz.setPixel(i, 0, 0, 0, False)
            pz.setPixel(i + 5, 0, 0, 0, False)
        for i in xrange(10, 14):  #pixels for closed mouth turned on
            pz.setPixel(i, 128, 0, 128, False)
    return


try:
    pz.setAllPixels(128, 0, 128)
    while True:
        change(1)
        pz.updatePixels()
        time.sleep(0.5)
        change(0)
        pz.updatePixels()
        time.sleep(0.5)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()
Exemplo n.º 7
0
def np_downlights():
    # DOWNLIGHTS
    pz.setAllPixels(255, 255, 255, True)
Exemplo n.º 8
0
 def next_color():
     color = self.colors[self.index]
     self.index = (self.index + 1) % len(self.colors)
     pz.setAllPixels(color)
Exemplo n.º 9
0
                    left_stick = 0.0
                print("Y: " + str(-left_stick))

            # right stick
            if event.code == "ABS_RZ":
                right_stick = event.state
                if right_stick > 130:
                    right_stick = -(right_stick - 130)
                elif right_stick < 125:
                    right_stick = ((-right_stick) + 125)
                else:
                    right_stick = 0.0
                print("Y: " + str(-right_stick))

            # engage the motors
            power_left = int((left_stick / 125.0) * 100)
            power_right = int((right_stick / 125.0) * 100)
            pz.setMotor(0, power_left)
            pz.setMotor(1, power_right)

            # print(event.ev_type, event.code, event.state)

except KeyboardInterrupt:

    # CTRL+C exit, disable all drives
    print("stop")
    pz.setAllPixels(0, 0, 0, True)
    pz.stop()
    pz.cleanup()
print("bye")
Exemplo n.º 10
0
#! /usr/bin/env python

# GNU GPL V3
# Test code for 4tronix Picon Zero

import piconzero as pz, time

pz.init()
pz.setOutputConfig(5, 3)  # set output 5 to WS2812
rev = pz.getRevision()
print rev[0], rev[1]
try:
    while True:
        pz.setAllPixels(255, 255, 255)
        time.sleep(1)
        pz.setAllPixels(0, 0, 0)
        time.sleep(1)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()
Exemplo n.º 11
0
        for i in xrange(1, 5):  #mouth set pixels for open state
            pz.setPixel(i, 128, 0, 128, False)
            pz.setPixel(i + 5, 128, 0, 128, False)
        for i in xrange(10, 14):  #pixels for closed mouth turned off
            pz.setPixel(i, 0, 0, 0, False)
    else:  #going for closed mouth
        for i in xrange(1, 5):  #mouth
            pz.setPixel(i, 0, 0, 0, False)
            pz.setPixel(i + 5, 0, 0, 0, False)
        for i in xrange(10, 14):  #pixels for closed mouth turned on
            pz.setPixel(i, 128, 0, 128, False)
    return


try:
    pz.setAllPixels(128, 0, 128)  #set an initial pixel state
    pz.setPixel(15, 0, 255, 0, False)  #eye
    pz.setPixel(16, 0, 255, 0)  #other eye
    pz.setPixel(14, 0, 0, 255)  #nose
    while True:
        #adjust counters depending upon whether mouth open or closed
        if openFlag == 1:
            opencount += 1  #increase count of number of cycles mouth is open
        else:
            shutcount += 1  #increase count of number of cycles mouth is closed

        if (b > threshold) and (shutcount > shutslot) and (
                openFlag == 0):  #open mouth triggered by audio
            opencount = 0  #reset count to 0
            openslot = int(b /
                           10)  #set openslot cycles according to brightness
Exemplo n.º 12
0
#! /usr/bin/env python

# GNU GPL V3
# Test code for 4tronix Picon Zero

import piconzero as pz, time

pz.init()
pz.setOutputConfig(5, 3)    # set output 5 to WS2812
rev = pz.getRevision()
print rev[0], rev[1]
try:
    while True:
        pz.setAllPixels(255,255,255)
        time.sleep(1)
        pz.setAllPixels(0,0,0)
        time.sleep(1)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()

Exemplo n.º 13
0
 def next_color(self):
     color = self.colors[self.index]
     self.index = (self.index+1) % len(self.colors)
     pz.setAllPixels(color[0],color[1],color[2])