Пример #1
0
	def __init__(self, name, com, offset, server, sim=False):
		
		if not sim: # If not a simulation, do:
			""" TODO: Clear bluetooth connection """
			self._robot = Myro.makeRobot("Scribbler", com)
			
		else: # Else, setup Simulation
			self._sim = Myro.Simulation("Simulation", 600, 600, Graphics.Color("lightgrey"))
			# Add lights first:
			self._sim.addLight((200, 200), 25, Graphics.Color("orange"))
			# Add walls and other objects:
			self._sim.addWall((10, 10), (20, 20), Graphics.Color("black"))
			self._sim.addWall((100, 100), (120, 120))
			# Is movable:
			circle = Graphics.Circle((100, 200), 20)
			self._sim.setup()
			self._robot = Myro.makeRobot("SimScribbler", self._sim)

		self._controller = r3controller.R3Controller(name, server) # Replace second argument with IP parameter
		self._robot.setPosition(offset[0], offset[1])
		self.name = name
		self._robot.setName(name)

		self._robot.setIRPower(120) # This number may need tampering, or possibly dynamic assigning.
		
		# Runs checkstall in seperate thread parallel to other code
		t = threading.Thread(target=self.checkStall, args=())
		t.daemon = True
		t.start()
Пример #2
0
 def touchDown():
     self.pictureList = []  #Start with an empty list.
     self.pic = self.Banana.takePicture()
     for i in range(4):
         self.pictureList = self.pictureList + [self.pic
                                                ]  #Append the new picture
         self.Banana.turnBy(90)
     m.savePicture(self.pictureList,
                   r"C:\Users\allis\Desktop\StarFleet Pics"
                   )  #change filename as needed
     self.Banana.stop()
Пример #3
0
def drawState(win, state, color=None):
    retval = []
    for list in states[state]:
        polygon = Polygon(*[ll2xy(pair[0], pair[1]) for pair in list])
        if color is not None:
            state_colors[state] = Color(color)
        elif state not in state_colors:
            state_colors[state] = Color(Myro.pickOne(Myro.getColorNames()))
        polygon.fill = state_colors[state]
        polygon.draw(win)
        retval.append(polygon)
    return retval
Пример #4
0
def verificarChoqueReg():
    global juegoCorriendo, reloj
    for b in listaRegs:
        ancho=b.width
        alto=b.height
        if pato.x>=b.x-ancho/2 and pato.x<=b.x+ancho/2:
            if pato.y>=b.y-alto/2 and pato.y<=b.y+alto/2:
                reloj-=5
                listaRegs.remove(b)
                b.undraw()
                sound =Myro.makeSound("Punch_-_Sound_Effect.wav") 
                Myro.play("Punch_-_Sound_Effect.wav")
Пример #5
0
def verificarChoqueBomba():
    global juegoCorriendo
    global puntos
    for b in listaBombas:
        ancho=b.width
        alto=b.height
        if pato.x>=b.x-ancho/2 and pato.x<=b.x+ancho/2:
            if pato.y>=b.y-alto/2 and pato.y<=b.y+alto/2:
                puntos-=1
                listaBombas.remove(b)
                b.undraw()
                sound =Myro.makeSound("Punch_-_Sound_Effect.wav") 
                Myro.play("Punch_-_Sound_Effect.wav")
Пример #6
0
def verificarChoqueObjeto():
    global juegoCorriendo
    global puntos
    for b in listaObjetos:
        ancho=b.width
        alto=b.height
        if pato.x>=b.x-ancho/2 and pato.x<=b.x+ancho/2:
            if pato.y>=b.y-alto/2 and pato.y<=b.y+alto/2:
                puntos+=1
                listaObjetos.remove(b)
                b.undraw()
                sound =Myro.makeSound("You_win_sound_effect_1.wav") 
                Myro.play("You_win_sound_effect_1.wav")
Пример #7
0
def plotMoreSound(function, color, width=500):
    win = Myro.getWindow()
    width = 44100
    array = [0] * width
    function(array, 0)
    prev = (0, width)
    for i in range(0, width, 2):
        l = Graphics.Line(prev, (i/2, array[i]))
        l.color = Myro.Color(color)
        l.draw(win)
        prev = (i/2, array[i])
Пример #8
0
    def __init__ (self, comPort = 3, width = 250, height = 250, speed = 0.5, scale = 0.5, lookX = 0, lookY = 1):
        #set global variables
        self.Speed = speed
        self.__Scale = scale

        self.__TowardsX = lookX
        self.__TowardsY = lookY

        self.__MidpointX = width / 2
        self.__MidpointY = height / 2

        multiplyBy = int(1.0 / scale)

        multiplyBy = int(1.0 / scale)

        self.Plot = [[MemoryType.Unknown] * width * multiplyBy for col in range(height * multiplyBy)]

        self.__MidpointX *= multiplyBy
        self.__MidpointY *= multiplyBy

        Myro.init("COM" + str(comPort))
Пример #9
0
    def __init__(self, title, width, height, data, x_label=None, y_label="Count"):
        self.colors = ["yellow", "red", "blue", "green", "orange", "purple"] + Myro.getColorNames()
        self.title = title
        self.x_label = x_label
        self.y_label = y_label
        self.width = width
        self.height = height
        self.data = data
        self.left, self.right, self.top, self.bottom = 100, 50, 100, 100
        self.rotate = 45
        self.use_height = .50
        self.use_width = .75
        self.win = Window(self.title, self.width, self.height)
        self.background = Rectangle((self.left, self.top),
                               (self.width - self.right, self.height - self.bottom))
        self.background.fill = Color("white")
        self.background.draw(self.win)
        self.button = Button((self.width - 70, self.height - 50), "Rescale")
        self.button.draw(self.win)
        self.button.connect("click", rescale)

        title = Text((self.width/2,self.top/2), self.title)
        title.color = Color("black")
        title.draw(self.win)

        if self.y_label:
            y_label = Text((self.left/2, self.height/2), self.y_label)
            y_label.fontSize = 12
            y_label.rotate(90)
            y_label.color = Color("black")
            y_label.draw(self.win)

        if self.x_label:
            x_label = Text((self.left + (self.width - self.left - self.right)/2,
                           (self.height - self.bottom) + self.bottom/2), self.x_label)
            x_label.fontSize = 12
            x_label.color = Color("black")
            x_label.draw(self.win)

        self.bars = {}
        self.draw()
Пример #10
0
import Myro
Myro.init()

pic = Myro.takePicture()
Myro.show(pic)

Myro.robot.backward(1, 1)
Myro.robot.forward(1, 1)
Myro.robot.beep(1, 440)
Myro.robot.beep(1, 440, 880)
Myro.robot.forward(.5, 2)
Myro.robot.backward(.5, 2)
print(Myro.robot.get("all"))
print(Myro.robot.getAll())
print(Myro.robot.getBattery())
print(Myro.robot.getBlob())
# print(Myro.robot.getBright())
print(Myro.robot.getConfig())
print(Myro.robot.getData())
print(Myro.robot.getIR())
print(Myro.robot.getIRMessage())
print(Myro.robot.getInfo())
print(Myro.robot.getLight())
print(Myro.robot.getLine())
print(Myro.robot.getName())
# print(Myro.robot.getObstacle())
print(Myro.robot.getPassword())
print(Myro.robot.getStall())
Myro.robot.motors(.5, .5)
Myro.robot.move(1, 1)
Myro.robot.move(-1, -1)
Пример #11
0
import Myro
import os
import System

data = {"name": "Test",
        "system_name": "test",
        "mime_type": "text/x-test",
        "extension": "test",
        "comment": "##"}

data = Myro.ask(data, "New Language Details")
if data is None:
    raise Exception("Language Creation Aborted")

def mkdirs(path): # missing in IronPython os?
    parts = os.path.split(path)
    root = ""
    for part in parts:
        root = os.path.join(root, part)
        if not os.path.exists(root):
            os.mkdir(root)

data_dir = os.path.join(calico.path, "..", "data")

if (Myro.askQuestion("Where do you want to put your language?",
                     ["Calico Global Languages", "My Local Languages"]) == "Calico Global Languages"):
    dest_dir = os.path.join(calico.path, "..", "languages")
else:
    dest_dir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)
    dest_dir = os.path.join(dest_dir, "calico", "languages")
Пример #12
0
def main():
    fondo5=makePicture("Nivel 5.jpg")
    fondo5.border=0
    fondo5.draw(v)    
    fondo4=makePicture("Nivel 4.jpg")
    fondo4.border=0
    fondo4.draw(v)
    fondo3=makePicture("Nivel 2.jpg")
    fondo3.border=0
    fondo3.draw(v)    
    fondo2=makePicture("Nivel 3.jpg")
    fondo2.border=0
    fondo2.draw(v)
    fondo1=makePicture("Nivel 1.jpg")
    fondo1.border=0
    fondo1.draw(v)
    global fondo1, fondo2, fondo3, fondo4
    fTiempo=RoundedRectangle((50, 35), (150, 60), 10)
    fTiempo.fill=Color("black")
    fTiempo.draw(v)
    txtTiempo.color=Color("white")
    txtTiempo.draw(v)
    fPuntos=RoundedRectangle((650, 35), (750, 65), 10)
    fPuntos.fill=Color("black")
    fPuntos.draw(v)
    txtPuntos.color=Color("white")
    txtPuntos.draw(v)
    escogerPersonaje()
    
    onKeyPress(atenderTeclado)
    global reloj
    tiempo=0
    tiempo2=0
    limite=1
    limite2=3
    

    while True:
        v.step(0.034)
        global juegoCorriendo
        global nivel, listaObjetos
        global puntos, highS, txtHS, p
        
        if juegoCorriendo:
            tiempo+=0.05
            if tiempo>=limite:
                tiempo=0
                reloj-=1
                txtTiempo.text="Tiempo "+str(reloj)
                txtPuntos.text="Puntos:"+str(puntos)
                if reloj<=0: 
                    juegoCorriendo=False                                       
                    perder=makePicture("Roasted.jpg")                    
                    txtPerder=Text((400,50),"GAME OVER")
                    txtPerder.color=Color("white")
                    perder.draw(v)
                    txtPerder.draw(v)                    
                    sound =Myro.makeSound("Wrong_Buzzer_-_Sound_Effect.wav") 
                    Myro.play("Wrong_Buzzer_-_Sound_Effect.wav")
                    highS=((nivel-1)*20)+puntos
                    entrada=open("highScore.txt","r")
                    cadena=entrada.read()
                    if highS>int(cadena):     
                        salida=open("highScore.txt","w")
                        salida.write(str(highS))
                        salida.close()
                        txtHS.text="HIGH SCORE:"+str(highS)
                        txtHS.color=Color("white")
                        txtHS.draw(v)
                    else:
                        print(cadena)
                        txtHS.text="HIGH SCORE:"+ str(cadena)
                        txtHS.color=Color("white")
                        txtHS.draw(v)
                    entrada.close()
                    btnSalir=Button((400,550), "Salir" )
                    btnSalir.draw(v)
                    btnSalir.connect("click",salirVentana )

                    
                if nivel==1:
                    obj=makePicture("barco.png")
                    crearObjetos1(obj)
                    crearBombas()                            
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo1.undraw()                                                           
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==2:
                    obj=makePicture("congo.png")
                    crearObjetos(obj)
                    crearBombas()
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo2.undraw()
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==3:
                    obj=makePicture("queso.png")
                    crearObjetos(obj)
                    crearBombas()
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo3.undraw()
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==4:
                    obj=makePicture("koo.png")
                    crearObjetos(obj)
                    crearBombas()
                    if puntos>=p:
                        nivel+=1
                        reloj=60
                        puntos=0
                        fondo4.undraw()
                        for b in listaObjetos:
                            b.undraw()
                        listaObjetos=[]
                if nivel==5:
                    obj=makePicture("sushi.png")
                    crearObjetos(obj)
                    crearBombas()
                    crearRegresos()
                    if puntos>=p:
                        juegoCorriendo=False
                        a=makePicture("winner.png")
                        a.draw(v)
                        fondo5.undraw()
                        sound =Myro.makeSound("Sonic_Unleashed_Soundtrack_-_Clear_Fanfare_2.wav") 
                        Myro.play("Sonic_Unleashed_Soundtrack_-_Clear_Fanfare_2.wav")
                        highS=100
                        txtHS=Text((400,75),"HIGH SCORE:"+ str(highS))
                        txtHS.color=Color("white")
                        txtHS.draw(v)
                        btnSalir=Button((400,550), "Salir" )
                        btnSalir.draw(v)
                        btnSalir.connect("click",salirVentana )
                        
                        
            if nivel==4:
                tiempo2+=0.05            
                if tiempo2>=limite2:
                    tiempo2=0
                    crearRegresos()
                        
            if nivel==1:
                moverBombas()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                   
            if nivel==2:
               moverLento()
               moverBombas()
               verificarChoqueObjeto()
               verificarChoqueBomba()
           
            if nivel==3:
                moverRapido()
                moverBombas()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                
            if nivel==4:
                moverRapido()
                moverBombas()
                moverRegs()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                verificarChoqueReg()
                
            if nivel==5:
                moverRapido()
                moverBombas()
                moverRegs()
                verificarChoqueObjeto()
                verificarChoqueBomba()
                verificarChoqueReg()
Пример #13
0
    def goForward(self, duration):
        #if line is up and down
        if (self.__TowardsX - self.__X == 0):
            Myro.robot.motors(self.Speed, self.Speed)
            Myro.wait(abs(duration))
            Myro.robot.stop()
            #get the amount of points forward
            divisible = duration // self.__Scale

            if (self.__TowardsY > self.__Y):
                #add them to the direction
                self.__TowardsY += divisible
                tempY = self.__Y

                #add them to plot
                for y in xrange(self.__Y + self.__Scale, divisible + tempY + self.__Scale):
                    if (y % self.__Scale == 0):
                        try:
                            self.Plot[(int) (self.__X)][y] = MemoryType.Visited
                        except IndexError:
                            print("Error: Ran out of space. Expanding the plot\r\n")
                            self.ExpandPlot(5)
                            y -= 1

                #increase y
                self.__Y += divisible
                self.Y += divisible
                return

            else:
                #subtract them from the direction
                self.__TowardsY -= divisible
                tempY = self.__Y

                #add them to plot
                for y in xrange(self.__Y - divisible,  tempY + self.__Scale):
                    if (y % self.__Scale == 0):
                        try:
                            self.Plot[(int) (self.__X)][y] = MemoryType.Visited
                        except IndexError:
                            print("Error: Ran out of space. Expanding the plot\r\n")
                            self.ExpandPlot(5)
                            y -= 1

                #increase y
                self.__Y -= divisible
                self.Y -= divisible
                return


        #calc slope
        slope = (self.__TowardsY - self.__Y) / (self.__TowardsX - self.__X)
        tempX = self.__X
        tempY = self.__Y

        #go forward
        Myro.robot.motors(self.Speed, self.Speed)
        Myro.wait(abs(duration))

        Myro.robot.stop()

        #get the amount of points forward
        divisible = duration // self.__Scale

        #add them to the direction
        self.__TowardsX += divisible
        self.__TowardsY += divisible
        divisible = duration / self.__Scale

        Xs = []
        Ys = []

        if (slope >= 0):
            #positive slope
            for x in xrange(self.__X + self.__Scale, (tempX + divisible) + self.__Scale, self.__Scale):
                #get point
                y = (slope * (x - self.__X)) + self.__Y
                #find out if it is a plottable point
                if (y % self.__Scale == 0.0):
                    Xs.append(int(x))
                    Ys.append(int(y))

        else:
            #negative slope
            for x in xrange((tempX - divisible), self.__X, self.__Scale):
                #get point
                y = (slope * (x - self.__X)) + self.__Y
                #find out if it is a plottable point
                if (y % self.__Scale == 0.0):
                    Xs.append(int(x))
                    Ys.append(int(y))

        #Plot the points
        for i in xrange(0, len(Xs)):
            try:
                self.Plot[Xs[i]][Ys[i]] = MemoryType.Visited
            except IndexError:
                print("Error: Ran out of space. Expanding the plot.\r\n")
                self.ExpandPlot(5)
                i -= 1

        multiplyBy = 1.0 / self.__Scale

        if (slope >= 0):
            try:
                self.__X = Xs[len(Xs) - 1]
                self.__Y = Ys[len(Ys) - 1]
            except IndexError:
                print("Error: No measurable progression.\r\n")

        else:
            try:
                self.__X = Xs[0]
                self.__Y = Ys[0]
            except IndexError:
                print("Error: No measurable progression.\r\n")

        self.X = self.__X - self.__MidpointX
        self.Y = self.__Y - self.__MidpointY
Пример #14
0
    def curve(self, speedLeft, speedRight, duration): #TODO correct screwed up direction after curve
        #set temp
        tempX = self.__X
        tempY = self.__Y

        #set scale
        greaterSpeed = 0
        lesserSpeed = 0
        if (abs(speedLeft) > abs(speedRight)):
            greaterSpeed = speedLeft
            lesserSpeed = speedRight
        elif (abs(speedRight) > abs(speedLeft)):
            greaterSpeed = speedRight
            lesserSpeed = speedLeft
        else:
            duration = (duration / self.Speed) * speedLeft
            self.goForward(duration)
            return

        #move robot
        Myro.robot.motors(speedLeft, speedRight)
        Myro.wait(abs(duration))
        Myro.robot.stop()

        stretch = (1 / self.__Scale) * (greaterSpeed / lesserSpeed)

        divisible = duration // self.__Scale

        Xs = []
        Ys = []
        tempXs = []
        tempYs = []

        overAfterPoint = False

        timesOver = 1
        maxAmount = tempX + divisible + self.__Scale
        minAmount = self.__X + self.__Scale
        #stretch
        for x in xrange(minAmount, maxAmount, self.__Scale):
            #get point
            try:
                y = stretch * sqrt(1 - pow(((x - self.__X - stretch) / stretch), 2)) + self.__Y
                overAfterPoint = True
            except ValueError: #Support for > half circle turns
                if overAfterPoint == True:
                    try:
                        x -= (timesOver * self.__Scale + timesOver)
                        y = -stretch * (sqrt(1 - pow(((x - self.__X - stretch) / stretch), 2))) + self.__Y
                        timesOver += 1
                        maxAmount -= x
                    except ValueError:
                        continue
                else:
                    continue
            #find out if it is a plottable point
            tempXs.append(x)
            tempYs.append(y)

        theta = 90 - degrees(atan(self.getSlope()))

        sina = sin(theta)
        cosa = cos(theta)
    
        for i in xrange(0, len(tempXs)):
            pX = self.__X - self.__MidpointX
            pY = self.__Y - self.__MidpointY

            tempXs[i] = (cosa * pX - sina * pY) + tempXs[i]
            tempYs[i] = (sina * pX + cosa * pY) + tempYs[i]

            if (tempXs[i] % self.__Scale == 0 and tempYs[i] % self.__Scale == 0):
                Xs.append(tempXs[i])
                Ys.append(tempYs[i])

        #Plot the points
        for i in xrange(0, len(Xs)):
            try:
                self.Plot[int(Xs[i])][int(Ys[i])] = MemoryType.Visited
            except IndexError:
                print("Error: Ran out of space. Expanding the plot.\r\n")
                self.ExpandPlot(5)
                i -= 1

        multiplyBy = 1.0 / self.__Scale

        if (stretch >= 0):
            try:
                self.__X = Xs[len(Xs) - 1]
                self.__Y = Ys[len(Ys) - 1]
            except IndexError:
                print("Error: No measurable progression.\r\n")
                return

        else:
            try:
                self.__X = Xs[0]
                self.__Y = Ys[0]
            except IndexError:
                print("Error: No measurable progression.\r\n")
                return

        #add it to the direction using derivative
        slope = 0
        try:
            slope = (tempX - self.__X)/ (stretch * sqrt(1 - (pow(tempX - self.__X, 2)/pow(stretch, 2))))
        except ValueError:
            if (stretch < 0):
                self.__TowardsX = self.__X
                self.__TowardsY = self.__Y + 1
                self.X = self.__X - self.__MidpointX
                self.Y = self.__Y - self.__MidpointY
                return
            else:
                self.__TowardsX = self.__X
                self.__TowardsY = self.__Y - 1
                self.X = self.__X - self.__MidpointX
                self.Y = self.__Y - self.__MidpointY
                return

        theta = 90 - degrees(atan(self.getSlope()))

        sina = sin(theta)
        cosa = cos(theta)

        pX = tempX - self.__MidpointX
        pY = tempY - self.__MidpointY

        if (stretch >= 0):
            newY = slope * (self.__X + 1 - tempX) + tempY
        else:
            newY = slope * (self.__X - 1 - tempX) + tempY

        self.__TowardsX = (cosa * pX - sina * pY) + tempX
        self.__TowardsY = (sina * pX + cosa * pY) + newY

        self.X = self.__X - self.__MidpointX
        self.Y = self.__Y - self.__MidpointY
Пример #15
0
 def animate():
     while bc.win.isRealized():
         bc.animate([Myro.pickOne(*range(4)) for x in range(100)])
Пример #16
0
def main():
    lavender= M.makeColor(164, 131, 196)
    teal= M.makeColor(140, 253, 153)
    cyan= M.makeColor(90, 200, 250)
    pink= M.makeColor(255, 153, 204)

    pic= M.makePicture('phoebe.jpg')
    pixels= M.getPixels(pic)
    for pixel in pixels:
        r= M.getRed(pixel)
        b= M.getBlue(pixel)
        g= M.getGreen(pixel)
        if r<35 and g<35 and b<35:
            M.setColor(pixel, lavender)
        elif r<100 and g<100 and b<100:
            M.setColor(pixel, teal)
        elif g<150 and b<200:
            M.setColor(pixel, pink)
        else:
            M.setColor(pixel, cyan)
    M.show(pic)
Пример #17
0
                    row.append(self.Plot[i][j]);
                except IndexError:
                    row.append(MemoryTypes.OffGrid)
            nearby.append(row)
        return nearby

    #gets point at position
    def getPointAtPosition(self, x, y):
        return mem.Plot[x + int(self.__MidpointX)][y + int(self.__MidpointY)]

    #Expands the array
    def expandPlot(self, radius):
        topBottom = [MemoryType.Unknown for height in xrange(len(self.Plot))]
        dupe = self.Plot
        self.Plot = []
        for i in xrange(radius):
            self.Plot.append(topBottom)
        for i in xrange(radius - 1, len(dupe)):
            temp = [MemoryType.Unknown for width in xrange(radius)]
            temp.extend(dupe[i])
            temp.extend([MemoryType.Unknown for width in xrange(radius)])
            self.Plot.append(temp)
        for i in xrange(radius):
            self.Plot.append(topBottom)

print ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
sim = Myro.Simulation("test", 250, 250, Myro.Color("White"))
r = Myro.makeRobot("SimScribbler", sim)
r.setPose(125, 125, -90)
mem = RobotMemory(3, 20, 20, 1, 1, 0, 1)
mem.start(0, 0)
Пример #18
0
    array = [0] * width
    function(array, 0)
    prev = (0, width)
    for i in range(0, width, 2):
        Graphics.Line(prev, (i/2, array[i])).draw(win)
        prev = (i/2, array[i])

def plotMoreSound(function, color, width=500):
    win = Myro.getWindow()
    width = 44100
    array = [0] * width
    function(array, 0)
    prev = (0, width)
    for i in range(0, width, 2):
        l = Graphics.Line(prev, (i/2, array[i]))
        l.color = Myro.Color(color)
        l.draw(win)
        prev = (i/2, array[i])

#Myro.play(0, wave)

tone440 = makeTone(440)
tone441 = makeTone(441)
tone = make2Tone(440, 441)

plotSound(tone)
plotMoreSound(tone440, "red")
plotMoreSound(tone441, "blue")

Myro.play(2, tone)
Пример #19
0
	def backward(self, distance):
		angle = self._robot.getAngle()
		(x, y) = self._controller.getForwardCoords(angle, distance)
		Myro.doTogether([self._robot.moveBy, 0-x, 0-y], [self._controller.setCoords, self.getPosition()])
Пример #20
0
            x1 = self.left + (count * col_width) + col_off/2 + col_width * .45
            y1 = self.height - self.bottom * .75
            text = Text((x1, y1), str(bin))
            text.fontSize = 12
            text.rotate(self.rotate)
            text.color = Color("black")
            text.draw(self.win)
            count += 1

        # Draw ticks:

        for percent in range(0, int(110 + (1.0 - self.use_height) * 200), 10):
            x = self.left
            y = self.height - self.bottom - (percent/100 * (self.height - self.top - self.bottom) * self.use_height)
            tick = Line((x - 10, y), (x, y))
            tick.draw(self.win)
            text = Text((x - 25, y), str(percent/100 * self.max_count))
            text.fontSize = 8
            text.color = Color("black")
            text.draw(self.win)
            text.tag = "rescale"


if __name__ == "<module>":
    #BarChart("test 2", 800, 600, ["1", "2"])
    #BarChart("test 3", 640, 480, range(10))
    bc = BarChart("Barchart Test #1", 800, 600, [Myro.pickOne(*range(4)) for x in range(100)], x_label="Choice")
    def animate():
        while bc.win.isRealized():
            bc.animate([Myro.pickOne(*range(4)) for x in range(100)])
    animate()
Пример #21
0
	def speak(self, words):
		Myro.speak(words)
Пример #22
0
 def __init__(self, alarm=1):
     self.Banana = m.makeRobot("Scribbler", "com14")
     self.alarm = 1
     self.resetAlarm()
     self.Command = 0
Пример #23
0
import Myro
import Rhyduino

with Rhyduino.Arduino("COM5") as arduino:
    arduino.Connect()
    pin = arduino.DigitalPins[13]
    pin.SetPinMode(Rhyduino.PinMode.Output)

    count = 0
    for t in Myro.timer(10):
        if count % 2 == 0:
            pin.SetPinValue(Rhyduino.DigitalPinValue.Low)
        else:
            pin.SetPinValue(Rhyduino.DigitalPinValue.High)
        count += 1
        Myro.wait(1)
Пример #24
0
 def readit(self, what):
     # FIXME: can't call from the clib?
     # Same problem when trying to exit and ask to save?
     import Myro
     return Myro.ask(what)
Пример #25
0
# This Python program was automatically generated by Calico Jigsaw
# http://calicoproject.org

import Common
import Myro

t = .3
s1 = Myro.makeSound(calico.relativePath("../examples/sounds/closed-hat-trimmed.wav"))
s2 = Myro.makeSound(calico.relativePath("../examples/sounds/crash-trimmed.wav"))
s3 = Myro.makeSound(calico.relativePath("../examples/sounds/kick-trimmed.wav"))
s4 = Myro.makeSound(calico.relativePath("../examples/sounds/open-hat-trimmed.wav"))
s5 = Myro.makeSound(calico.relativePath("../examples/sounds/snare-trimmed.wav"))
for _ in xrange(3):
  for _ in xrange(4 * 2):
    s1.Play()
    Myro.wait(t)
  for _ in xrange(4):
    s1.Play()
    Myro.wait(t)
    s3.Play()
    Myro.wait(t)
  for _ in xrange(2):
    s1.Play()
    Myro.wait(t)
    s5.Play()
    Myro.wait(t)
    s1.Play()
    Myro.wait(t)
    s2.Play()
    Myro.wait(t)
  for _ in xrange(2):
Пример #26
0
#
# Calico - Scripting Environment
#
# Copyright (c) 2011, Doug Blank <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# $Id: $

import Myro
Myro.init("/dev/rfcomm1")

Myro.robot.beep(.5, 784)
Myro.robot.beep(.5, 880)
Myro.robot.beep(.5, 698)
Myro.robot.beep(.5, 349)
Myro.robot.beep(.5, 523)