Example #1
0
def message_listener(client):
    global RECEIVED_MESSAGES
    pythoncom.CoInitialize()  #fix to Picoh speech issue

    while True:
        message = client.receive_message()
        RECEIVED_MESSAGES += 1
        print("Message received")
        # print( "    Data: «{}»".format(message.data) )
        # print( "    Properties: {}".format(message.custom_properties))
        # print( "    Total calls received: {}".format(RECEIVED_MESSAGES))
        print(message.data.decode('utf-8'))

        picoh.say(message.data.decode('utf-8'))
        picoh.setEyeShape("Heart")
        picoh.move(picoh.HEADTURN, randint(3, 7))
        picoh.move(picoh.HEADNOD, randint(4, 7))
        picoh.baseColour(random() * 10, random() * 10, random() * 10)
        picoh.wait(1)
        picoh.setEyeShape("Eyeball")
Example #2
0
from picoh import picoh
# Reset picoh's motors and wait a second for them to move to rest positions.
picoh.reset()
picoh.wait(1)

# Set Picoh's eye shape.
picoh.setEyeShape("Eyeball")

# Say a phrase.
picoh.say("Hello my name is Picoh. Good to meet you")

# Move the HEADTURN and EYETURN to position 3.
picoh.move(picoh.HEADTURN, 3)
picoh.move(picoh.EYETURN, 3)

picoh.wait(1)

# Move the HEADTURN and EYETURN to position 7.
picoh.move(picoh.HEADTURN, 7)
picoh.move(picoh.EYETURN, 7)

# Set the base to red:3/10 green: 4/10 and blue 2/10.
picoh.setBaseColour(3, 4, 2)

picoh.wait(1)

# Change the base to orange
picoh.setBaseColour(10, 3, 0)

# Set the eyeshape to SunGlasses
picoh.setEyeShape("SunGlasses")
Example #3
0
picoh.wait(0.2)

picoh.say("Commencing hardware tests")

picoh.say("Base to red")
picoh.setBaseColour(10, 0, 0)

picoh.say("Base to green")
picoh.setBaseColour(0, 10, 0)

picoh.say("Base to blue")
picoh.setBaseColour(0, 0, 10)

picoh.say("Matrix off")
picoh.move(picoh.LIDBLINK, 0)
picoh.setEyeShape("Full")

picoh.say("Matrix on")
picoh.move(picoh.LIDBLINK, 10)

picoh.say("Eyes to angry")
picoh.setEyeShape("Angry")

picoh.say("Reset Eyes")
picoh.setEyeShape("Eyeball")

picoh.say("HeadTurn motor 0 to 10")

for x in range(0, 10):

    picoh.move(picoh.HEADTURN, x)
Example #4
0
            picoh.move(picoh.HEADNOD, randint(4, 7))

            # wait for a random amount of time before moving again. 
            picoh.wait(random() * 4)

def baseCol():
    while True:
        # Set the base to a random rgb values between 0 and 10. 
        picoh.setBaseColour(random() * 10, random() * 10, random() * 10)
        # Wait between 10 and 20 seconds before changing again. 
        picoh.wait(randint(10, 20))

# Reset Picoh and wait for a second for motors to move to reset positions. 
picoh.reset()
picoh.wait(1)
picoh.setEyeShape(defaultEyeshape)

# Set the moving and blinking global variables to True. 
moving = True
blinking = True

# Create a thread for blinking.
t1 = threading.Thread(target=blinkLids, args=())

# Create a thread to make eyes look around randomly.
t2 = threading.Thread(target=randomLook, args=())

# Create a thread for random head nod positions.
t3 = threading.Thread(target=randomNod, args=())

# Create a thread for random head turn positions. 
Example #5
0
# Example of how to use the play sound function and change the base colour of Picoh.

from picoh import picoh
import random

picoh.reset()
picoh.wait(1)
picoh.close()
picoh.move(picoh.LIDBLINK, 0)

picoh.setEyeShape('Heart')
picoh.setEyeBrightness(0)
picoh.playSound('fanfare', untilDone=False)
picoh.wait(1.5)

picoh.move(picoh.LIDBLINK, 5)
picoh.setEyeBrightness(5)

picoh.wait(1)

picoh.move(picoh.LIDBLINK, 10)
picoh.setEyeBrightness(10)
picoh.wait(2)
picoh.setEyeBrightness(7)
picoh.wait(4)

picoh.playSound('ohbot', untilDone=False)

picoh.setEyeShape('Glasses')
for x in range(0, 40):
    picoh.setBaseColour(random.randrange(0, 10), random.randrange(0, 10),