コード例 #1
0
def randomTurn():
    global moving
    while True:
        if moving:
            # Move Picoh's HEADTURN motor to a random position between 3 and 7.
            picoh.move(picoh.HEADTURN, randint(3, 7))

            # wait for a random amount of time before moving again. 
            picoh.wait(random() * 4)
コード例 #2
0
def randomNod():
    global moving
    while True:
        if moving:

            # Move Picoh's HEADNOD motor to a random position between 4 and 7.
            picoh.move(picoh.HEADNOD, randint(4, 7))

            # wait for a random amount of time before moving again. 
            picoh.wait(random() * 4)
コード例 #3
0
def randomLook():
    global moving 
    while True:
        # if moving is True. 
        if moving:
            # Look in a random direction.
            picoh.move(picoh.EYETILT, randint(2, 8))
            picoh.move(picoh.EYETURN, randint(2, 8))

            # Wait for between 0 and 5 seconds. 
            picoh.wait(random() * 5)
コード例 #4
0
def sel():
    global button, stage, lipMaxRaw, lipMinRaw

    if stage == 2:
        root.destroy()

        picoh.reset()

        picoh.wait(1)

        picoh.close()

        sys.exit()

    if stage == 1:
        ResetRangeToRawMin()
        label.config(text="All done!")
        stage = 2
        button.config(text="Close")

    if stage == 0:
        selection = "Value = " + str(var.get())
        label.config(
            text=
            "Slowly move the slider to the right, stop when the bottom lip pops the top lip into a smile."
        )

        button.config(text="Set Smile Point")

        ResetRangeToRawCentre()
        stage = 1

        # Set headnod to 5
        picoh.move(picoh.HEADNOD, 10)
        # Move bottom lip to 4
        picoh.move(picoh.BOTTOMLIP, 4)

        # Wait 250ms
        picoh.wait(0.25)

        # Move bottom lip to 6
        picoh.move(picoh.BOTTOMLIP, 6)
コード例 #5
0
ファイル: picohub.py プロジェクト: lokijota/AzurePicoh
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")
コード例 #6
0
def blinkLids():
    global blinking
    
    # While True - Loop forever.
    while True:
        # if blinking is True.
        if blinking:
            # for the numbers 10 to 0 set the lidblink position. 
            for x in range(10, 0, -1):
                picoh.move(picoh.LIDBLINK,x)
                picoh.wait(0.01)
                
            # for the numbers 0 to 10 set the lidblink position.
            for x in range(0, 10):
                picoh.move(picoh.LIDBLINK,x)
                picoh.wait(0.01)

            # wait for a random amount of time for realistic blinking
            picoh.wait(random() * 6)
コード例 #7
0
ファイル: helloWorldPicoh.py プロジェクト: ohbot/picoh-python
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")
コード例 #8
0
ファイル: movementExample.py プロジェクト: ohbot/picoh-python
picoh.move(picoh.HEADNOD, 9)
picoh.say("head nod to 9")
# Move the HEADNOD motor to 5.
picoh.move(picoh.HEADNOD, 5)
picoh.say("head nod to 5")
'''
The picoh.move() function can also take an optional third arguement 'spd'
to change the speed of the movement. If unspecified speed defaults to 5. 
'''

# Move HEADTURN motor to position 0 at speed 1.
picoh.move(picoh.HEADTURN, 0, spd=1)
picoh.say("Head turn to 0, speed 1")

# Wait for motor to move
picoh.wait(2)

# Move HEADTURN motor to position 10 at speed 1.
picoh.move(picoh.HEADTURN, 10, spd=1)
picoh.say("Head turn to 10, speed 1")

# Wait for motor to move
picoh.wait(1)

# Move HEADTURN motor to position 0 at speed 10.
picoh.move(picoh.HEADTURN, 0, spd=10)
picoh.say("Head turn to 0, speed 10")

# Wait for motor to move
picoh.wait(0.5)
コード例 #9
0
ファイル: pico2waveSpeech.py プロジェクト: ohbot/picoh-python
# Install pico2wave using sudo apt-get install libttspico-utils
# Ensure you are running the latest version of the library by running sudo pip3 install picoh --upgrade

from picoh import picoh

picoh.reset()

picoh.setSynthesizer("pico2wave")

picoh.say("now I can speak using pico2wave text to speech as well")

picoh.wait(1)

picoh.close()

コード例 #10
0
def on_closing():
    picoh.reset()
    picoh.wait(1)
    picoh.close()
    win.destroy()
コード例 #11
0
from picoh import picoh
import random

picoh.reset()

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")
コード例 #12
0
import tkinter as Tk

from lxml import etree

global button, stage, lipMinRaw, lipMaxRaw, tempMin, tempMax
import sys

stage = 0

picoh.move(picoh.HEADNOD, 8)

# Move bottom lip to 4
picoh.move(picoh.BOTTOMLIP, 4)

# Wait 250ms
picoh.wait(0.25)

# Move bottom lip to 8
picoh.move(picoh.BOTTOMLIP, 8)

# Get min and max positions.
lipMinRaw = picoh.motorMins[picoh.BOTTOMLIP]
lipMaxRaw = picoh.motorMaxs[picoh.BOTTOMLIP]
lipRange = lipMaxRaw - lipMinRaw

# Extend Ranges

if lipMinRaw - lipRange / 5 > 0:
    lipMinRaw = lipMinRaw - lipRange / 5
else:
    lipMinRaw = 0
コード例 #13
0
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))
コード例 #14
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),
コード例 #15
0
ファイル: changingVoices.py プロジェクト: ohbot/picoh-python
from picoh import picoh

import random

# Run 'say -v?' in Terminal to list options for voices. speechSpeed is 90 +.

picoh.reset()

picoh.say("Hi it is great to be here, i am finally running on a mac, wow")

picoh.wait(2)

picoh.setVoice("Karen")

picoh.setSpeechSpeed(150)

picoh.move(picoh.HEADTURN, random.randint(3, 6))

picoh.say("hello i am Karen")

picoh.setVoice("Alex")

picoh.setSpeechSpeed(90)

picoh.move(picoh.HEADTURN, random.randint(2, 6))

picoh.say("hello i am Alex slow")

picoh.setVoice("Oliver")

picoh.move(picoh.HEADTURN, random.randint(1, 6))