def muestraAccel(self):
       wiiuse.motion_sensing(self.wiimotes,self.nmotes)
       wiiuse.poll(self.wiimotes, self.nmotes)
       t = self.wm.gforce.x
       temp=0
       try:
             temp = math.trunc(t)
       except:
             temp=0
       if temp< (self.rotX-3) or temp> (self.rotX+3):
             self.rotX= temp
             self.window.emit(SIGNAL("AccelX"), self.rotX)
       
       t = self.wm.gforce.y
       temp=0
       try:
             temp = math.trunc(t)
       except:
             temp=0
       if temp < (self.rotY-3) or temp > (self.rotY+3):
             self.rotY= temp
             self.window.emit(SIGNAL("AccelY"), self.rotY)
       t = self.wm.gforce.z
       temp=0
       try:
             temp = math.trunc(t)
       except:
             temp=0
       if temp != self.rotZ:
             self.rotZ= temp
             self.window.emit(SIGNAL("AccelZ"), self.rotZ)
Exemplo n.º 2
0
 def drawLines(self,
               qp):  ## este metodo hay que editarlo para que pinte yn punto
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     pen = QtGui.QPen(QtCore.Qt.black, 10, QtCore.Qt.DotLine)
     qp.setPen(pen)
     try:
         x = self.wm.ir.x
         y = 768 - self.wm.ir.y
         #print str(x)+" "+str(y)
         qp.drawPoint(x, y)
         puntosx = []
         puntosy = []
         for a in self.wm.ir.dot:
             if a.rx != 0:
                 qp.drawPoint(a.rx, y + (y / 2))
                 qp.drawPoint(a.rx, y - (y / 2))
                 qp.drawPoint(a.rx, y)
                 puntosx.append(a.rx)
                 puntosy.append(y - (y / 2))
                 puntosy.append(y + (y / 2))
         if self.wm.ir.aspect > 1:
             dx = puntosx[1] - puntosx[0]
             dy = puntosy[3] - puntosy[0]
             qp.drawEllipse(x, y, dx, dy)
         """win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,0,0)
         win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,0,0)"""
         self.l1.setText("x + " + str(self.wm.ir.x))
         self.l2.setText("y + " + str(self.wm.ir.y))
         self.l3 = 0
     except:
         print "error pintando"
 def drawLines(self, qp): ## este metodo hay que editarlo para que pinte yn punto
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     pen = QtGui.QPen(QtCore.Qt.black, 10, QtCore.Qt.DotLine)
     qp.setPen(pen)
     try:
         x=self.wm.ir.x
         y=768-self.wm.ir.y
         #print str(x)+" "+str(y)
         qp.drawPoint(x,y)
         puntosx=[]
         puntosy=[]
         for a in self.wm.ir.dot:
             if a.rx!=0:
                 qp.drawPoint(a.rx,y+(y/2))
                 qp.drawPoint(a.rx,y-(y/2))
                 qp.drawPoint(a.rx,y)
                 puntosx.append(a.rx)
                 puntosy.append(y-(y/2))
                 puntosy.append(y+(y/2))
         if self.wm.ir.aspect>1 :
             dx=puntosx[1]-puntosx[0]
             dy=puntosy[3]-puntosy[0]
             qp.drawEllipse( x,y,dx,dy)
         """win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,0,0)
         win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,0,0)"""
         self.l1.setText("x + "+str(self.wm.ir.x))
         self.l2.setText("y + "+str(self.wm.ir.y))
         self.l3=0
     except:
         print "error pintando"
Exemplo n.º 4
0
 def drawLines(self, qp): ## este metodo hay que editarlo para que pinte yn punto
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     pen = QtGui.QPen(QtCore.Qt.black, 10, QtCore.Qt.DotLine)
     qp.setPen(pen)
     try:
         T="(x,y)\t\tnum_dots\t\taspect\tpos\tstate\tax\tay\t\tdistance\tz\n"
         x=self.wm.ir.x
         y=self.wm.ir.y
         T+="("+str(x)+" , "+str(y)+")\t"+str(self.wm.ir.num_dots)+"\t\t"+str(self.wm.ir.pos)+"\t"+str(self.wm.ir.state)+"\t"+str(self.wm.ir.ax)+"\t"+str(self.wm.ir.ay)+"\t\t"+str(self.wm.ir.distance)+"\t"+str(self.wm.ir.z)
         #print str(x)+" "+str(y)
         qp.drawPoint(x,y)
         self.l1.setText("Accel X\t\tAccel Y\n"+str(self.wm.gforce.x)+"\t\t"+str(self.wm.gforce.y)+"")
         self.l2.setText(T)
         #print "##"
         T="(x,y)\t\torder\tVisible\trx\try\tsize\n"
         for a in self.wm.ir.dot:
             T+="( "+str(a.x)+" , "+str(a.y)+" )\t"+str(a.order)+"\t"+str(a.visible)+"\t"+str(a.rx)+"\t"+str(a.ry)+"\t"+str(a.size)+"\n"
             qp.drawPoint(a.rx,a.ry)
         T+="VRES\t"
         for a in self.wm.ir.vres:
             T+=str(a)+"\t"
         T+="\t###\tOfset\t"
         for a in self.wm.ir.offset:
             T+=str(a)+"\t"
         self.l3.setText(T)
         #print "##" 
         #self.l3.setText(str(self.wm.ir.dot))
     except:
         print "error pintando"
Exemplo n.º 5
0
def withYield():
    getConnected()
    while True:
        r = wiiuse.poll(wiimotes, nmotes)
        if r != 0:
            wmp=wiimotes[0]
            wm=wmp[0]
          
            if wm.btns:
                for name, b in wiiuse.button.items():
                    if wiiuse.is_pressed(wm, b):
                        print name,'pressed'
                if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
                    wiiuse.motion_sensing(wmp, 0)
                if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
                        wiiuse.motion_sensing(wmp, 1)
                if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
                    wiiuse.toggle_rumble(wmp) 
            if wiiuse.using_acc(wm):
                #global rollAngle
                global completeList
                #rollAngle=[wm.orient.roll]
                completeList=[wm.orient.roll, wm.orient.pitch, wm.orient.yaw, wm.gforce.x, wm.gforce.y, wm.gforce.z ]
                #yield rollAngle
                yield completeList
Exemplo n.º 6
0
def handle_event(wmp):
    wm = wmp[0]
    #print '--- EVENT [wiimote id %i] ---' % wm.unid
    
    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print name,'pressed'

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)         
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            wiiuse.set_ir(wmp, 0)
    
    if wiiuse.using_acc(wm):
        
        print 'roll  = %f' % wm.orient.roll
        print 'pitch = %f' % wm.orient.pitch
        print 'yaw   = %f' % wm.orient.yaw
        print 'x_acc = %f' % wm.gforce.x
        print 'y_acc = %f' % wm.gforce.y
        print 'z_acc = %f' % wm.gforce.z
Exemplo n.º 7
0
def handle_event(wmp):
    wm = wmp[0]
    print '--- EVENT [wiimote id %i] ---' % wm.unid
    
    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print name,'pressed'

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            wiiuse.set_ir(wmp, 0)
    
    if wiiuse.using_acc(wm):
        print 'roll  = %f' % wm.orient.roll
        print 'pitch = %f' % wm.orient.pitch
        print 'yaw   = %f' % wm.orient.yaw
		print 'x_force = %f' % wm.gforce.x
        print 'y_force = %f' % wm.gforce.y
        print 'z_force = %f' % wm.gforce.z
Exemplo n.º 8
0
    def muestraAccel(self):
        wiiuse.motion_sensing(self.wiimotes, self.nmotes)
        wiiuse.poll(self.wiimotes, self.nmotes)
        t = self.wm.gforce.x
        temp = 0
        try:
            temp = math.trunc(t)
        except:
            temp = 0
        if temp < (self.rotX - 3) or temp > (self.rotX + 3):
            self.rotX = temp
            self.window.emit(SIGNAL("AccelX"), self.rotX)

        t = self.wm.gforce.y
        temp = 0
        try:
            temp = math.trunc(t)
        except:
            temp = 0
        if temp < (self.rotY - 3) or temp > (self.rotY + 3):
            self.rotY = temp
            self.window.emit(SIGNAL("AccelY"), self.rotY)
        t = self.wm.gforce.z
        temp = 0
        try:
            temp = math.trunc(t)
        except:
            temp = 0
        if temp != self.rotZ:
            self.rotZ = temp
            self.window.emit(SIGNAL("AccelZ"), self.rotZ)
Exemplo n.º 9
0
def withYield():
    getConnected()
    while True:
        r = wiiuse.poll(wiimotes, nmotes)
        if r != 0:
            wmp = wiimotes[0]
            wm = wmp[0]

            if wm.btns:
                for name, b in wiiuse.button.items():
                    if wiiuse.is_pressed(wm, b):
                        print name, 'pressed'
                if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
                    wiiuse.motion_sensing(wmp, 0)
                if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
                    wiiuse.motion_sensing(wmp, 1)
                if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
                    wiiuse.toggle_rumble(wmp)
            if wiiuse.using_acc(wm):
                #global rollAngle
                global completeList
                #rollAngle=[wm.orient.roll]
                completeList = [
                    wm.orient.roll, wm.orient.pitch, wm.orient.yaw,
                    wm.gforce.x, wm.gforce.y, wm.gforce.z
                ]
                #yield rollAngle
                yield completeList
Exemplo n.º 10
0
def handle_event(wmp):
    wm = wmp[0]
    if wm.btns:
        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['A']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)       
	return wm.orient.pitch
Exemplo n.º 11
0
    def ingresaPuntoDeWiiMote(self):
        wiiuse.motion_sensing(self.wiimotes, self.nmotes)
        wiiuse.poll(self.wiimotes, self.nmotes)
        #print self.wm.flags
        #print wiiuse.api.read_data
        """if self.wm.btns:
            if wiiuse.is_pressed(self.wm, 0x0004):
                print "B"
            """
        """if wiiuse.is_just_pressed(self.wm, 0x1000):
            print "+"
        """
        #print self.wm.accel.x
        try:
            if wiiuse.using_acc(self.wm):
                print 'roll  = %i' % self.wm.orient.roll
                print 'pitch = %i' % self.wm.orient.pitch
                print 'yaw   = %i' % self.wm.orient.yaw
            if self.b1:
                for i in range(1, len(self.arr)):
                    self.arr[i - 1] = self.arr[i]
                self.arr[len(self.arr) - 1] = self.wm.gforce.x

            if self.b2:
                for i in range(1, len(self.arr1)):
                    self.arr1[i - 1] = self.arr1[i]
                self.arr1[len(self.arr1) - 1] = self.wm.gforce.y

            if self.b3 and str(self.wm.gforce.z) != 'inf':
                for i in range(1, len(self.arr2)):
                    self.arr2[i - 1] = self.arr2[i]
                self.arr2[len(self.arr2) - 1] = self.wm.gforce.z
            self.l1.setText(str(self.arr[len(self.arr) - 1]))
            self.l2.setText(str(self.arr1[len(self.arr1) - 1]))
            self.l3.setText(str(self.arr2[len(self.arr2) - 1]))
            ####escalando
            if self.arr[len(self.arr) - 1] > self.maxG1:
                self.maxG1 = self.arr[len(self.arr) - 1] * 1.0
            if self.arr[len(self.arr) - 1] < self.minG1:
                self.minG1 = self.arr[len(self.arr) - 1] * 1.0

            if self.arr1[len(self.arr1) - 1] > self.maxG2:
                self.maxG2 = self.arr1[len(self.arr1) - 1] * 1.0
            if self.arr1[len(self.arr1) - 1] < self.minG2:
                self.minG2 = self.arr1[len(self.arr1) - 1] * 1.0

            if self.arr2[len(self.arr2) - 1] > self.maxG3:
                self.maxG3 = self.arr2[len(self.arr2) - 1] * 1.0
            if self.arr2[len(self.arr2) - 1] < self.minG3:
                self.minG3 = self.arr2[len(self.arr2) - 1] * 1.0
        except:
            print "error"
        self.repaint()
    def ingresaPuntoDeWiiMote(self):
        wiiuse.motion_sensing(self.wiimotes, self.nmotes)
        wiiuse.poll(self.wiimotes, self.nmotes)
        #print self.wm.flags
        #print wiiuse.api.read_data
        """if self.wm.btns:
            if wiiuse.is_pressed(self.wm, 0x0004):
                print "B"
            """
        """if wiiuse.is_just_pressed(self.wm, 0x1000):
            print "+"
        """
        #print self.wm.accel.x
        try :
            if wiiuse.using_acc(self.wm):
                print 'roll  = %i' % self.wm.orient.roll
                print 'pitch = %i' % self.wm.orient.pitch
                print 'yaw   = %i' % self.wm.orient.yaw
            if self.b1:
                for i in range(1,len(self.arr)):
                    self.arr[i-1]=self.arr[i]
                self.arr[len(self.arr)-1]=self.wm.gforce.x
                
            if self.b2:
                for i in range(1,len(self.arr1)):
                    self.arr1[i-1]=self.arr1[i]
                self.arr1[len(self.arr1)-1]=self.wm.gforce.y

            if self.b3 and str(self.wm.gforce.z)!='inf':
                for i in range(1,len(self.arr2)):
                    self.arr2[i-1]=self.arr2[i]
                self.arr2[len(self.arr2)-1]=self.wm.gforce.z
            self.l1.setText(str(self.arr[len(self.arr)-1]))
            self.l2.setText(str(self.arr1[len(self.arr1)-1]))
            self.l3.setText(str(self.arr2[len(self.arr2)-1]))
            ####escalando
            if self.arr[len(self.arr)-1] > self.maxG1:
                self.maxG1=self.arr[len(self.arr)-1]*1.0
            if self.arr[len(self.arr)-1] < self.minG1:
                self.minG1=self.arr[len(self.arr)-1]*1.0

            if self.arr1[len(self.arr1)-1] > self.maxG2:
                self.maxG2=self.arr1[len(self.arr1)-1]*1.0
            if self.arr1[len(self.arr1)-1] < self.minG2:
                self.minG2=self.arr1[len(self.arr1)-1]*1.0

            if self.arr2[len(self.arr2)-1] > self.maxG3:
                self.maxG3=self.arr2[len(self.arr2)-1]*1.0
            if self.arr2[len(self.arr2)-1] < self.minG3:
                self.minG3=self.arr2[len(self.arr2)-1]*1.0
        except:
            print "error"
        self.repaint()
Exemplo n.º 13
0
 def update(self):
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     #print "\t######"
     #print self.wm.gforce.x
     if str(self.wm.gforce.x)!='inf':
         self.zRotDeg = 360-self.wm.gforce.x
     if str(self.wm.gforce.y)!='inf':
         self.xRotDeg = 360-self.wm.gforce.y
     """if str(self.wm.gforce.z)!='inf':
         self.yRotDeg = self.wm.gforce.z"""
     self.parent.statusBar().showMessage('x %f - y %f - z %f' % (self.xRotDeg,self.yRotDeg,self.zRotDeg))
     self.updateGL()
Exemplo n.º 14
0
def intro_prompt():
    if os.name != 'nt':
        print "\n\n*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************\n"
        time.sleep(STANDARD_SLEEP_TIME)
        print "Press 1 & 2 to connect"

        found_motes = wiiuse.find(
            wiimotes, num_motes,
            1)  # Find one remote, and wait up to 1 second to find it.

        # If no remotes are found...
        if not found_motes:
            print "No remotes found!  Exiting."
            sys.exit(1)
        else:
            print "... Found remote."

        connected = wiiuse.connect(wiimotes, num_motes)

        if connected:
            print 'Connected to %i wiimotes!' % connected
        else:
            print "Failed to connect.  Exiting."
            sys.exit(1)

        wiiuse.set_leds(first_wm, wiiuse.LED[0])

        print "Enabling motion sense..."
        time.sleep(STANDARD_SLEEP_TIME)
        wiiuse.motion_sensing(first_wm, 1)  # Enable motion sensing.
        time.sleep(STANDARD_SLEEP_TIME)

        print "Enabling IR...\n"
        time.sleep(STANDARD_SLEEP_TIME)
        wiiuse.set_ir(first_wm, 1)  # Enable IR (No sensor bar yet.)
        time.sleep(STANDARD_SLEEP_TIME)

        print "*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************\n"

        time.sleep(STANDARD_SLEEP_TIME)
        star_wave()
        print "\nLet's begin!\n"
        star_wave()
Exemplo n.º 15
0
 def update(self):
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     #print "\t######"
     #print self.wm.gforce.x
     if str(self.wm.gforce.x) != 'inf':
         self.zRotDeg = 360 - self.wm.gforce.x
     if str(self.wm.gforce.y) != 'inf':
         self.xRotDeg = 360 - self.wm.gforce.y
     """if str(self.wm.gforce.z)!='inf':
         self.yRotDeg = self.wm.gforce.z"""
     self.parent.statusBar().showMessage(
         'x %f - y %f - z %f' % (self.xRotDeg, self.yRotDeg, self.zRotDeg))
     self.updateGL()
Exemplo n.º 16
0
def handle_event(wmp):
    wm = wmp[0]
    print('--- EVENT [wiimote id %i] ---' % wm.unid)

    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print(name, 'pressed')

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            print("- pressed")
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            print("+ pressed")
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            print("B pressed")
            wiiuse.toggle_rumble(wmp)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            print("D-Pad Up pressed")
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            print("D-Pad Down Pressed")
            wiiuse.set_ir(wmp, 0)

    if wiiuse.using_acc(wm):
        print('roll  = %f' % wm.orient.roll)
        print('pitch = %f' % wm.orient.pitch)
        print('yaw   = %f' % wm.orient.yaw)

    if wiiuse.using_ir(wm):
        for i in range(4):
            if wm.ir.dot[i].visible:
                print('IR source %i: (%u, %u)' %
                      (i, wm.ir.dot[i].x, wm.ir.dot[i].y))
        print('IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y))
        print('IR z distance: %f' % wm.ir.z)

    if wm.exp.type == wiiuse.EXP_NUNCHUK:
        nc = wm.exp.u.nunchuk

        for name, b in wiiuse.nunchuk_button.items():
            if wiiuse.is_pressed(nc, b):
                print('Nunchuk: %s is pressed' % name)

        print('nunchuk roll  = %f' % nc.orient.roll)
        print('nunchuk pitch = %f' % nc.orient.pitch)
        print('nunchuk yaw   = %f' % nc.orient.yaw)
        print('nunchuk joystick angle:     %f' % nc.js.ang)
        print('nunchuk joystick magnitude: %f' % nc.js.mag)
 def drawLines(self, qp): 
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     pen = QtGui.QPen(QtCore.Qt.black, 10, QtCore.Qt.DotLine)
     qp.setPen(pen)
     try:
         #x=self.wm2.ir.x
         #y=768-self.wm2.ir.y
         #print str(x)+" "+str(y)
         #qp.drawPoint(x,y)
         puntosx=[]
         puntosy=[]
         """for a in self.wm.ir.dot:
             if a.rx!=0:
                 qp.drawPoint(a.rx,5)"""
         for b in self.wm.ir.dot:
             #print str(b.x)+" "+str(b.y)+"\t"+"\t"+str(b.rx)+"\t"+str(b.ry)
             if b.rx!=0 and b.rx<1030 and b.rx>0:
                 #qp.drawPoint(b.rx,a.rx)
                 puntosx.append(b.rx)
         for a in self.wm2.ir.dot:
             #print str(b.x)+" "+str(b.y)+"\t"+"\t"+str(b.rx)+"\t"+str(b.ry)
             if a.rx!=0 and a.rx<800 and  a.rx>0:
                 #qp.drawPoint(b.rx,a.rx)
                 puntosy.append(a.rx)
         puntos=[]
         for i in range(0,2):
             qp.drawPoint(puntosx[i],puntosy[i])
             puntos.append(puntosx[i])
             puntos.append(puntosy[i])
         #print "arr "+str(puntos)
         qp.drawLine(puntos[0],puntos[1],puntos[2],puntos[3])
         ##REcta perpendicular
         M2=(puntos[0]-puntos[2])/(puntos[3]-puntos[1])
         y1=puntos[1] - M2*(puntos[0]- 0)
         y2=puntos[3] - M2*(puntos[2]- 0)
         #arr=[-10,y1,10,y2]
         qp.drawLine(0,y1,puntos[0],puntos[1])
         qp.drawLine(0,y2,puntos[2],puntos[3])
         ##REcta perpendicular
         qp.drawEllipse(((puntos[2]+puntos[0])/2)-50,((puntos[3]+puntos[1])/2)-50,100,100)
         """print "arriba"
         print puntosx
         print puntosy
         print puntos
         print "abajo" """
         #self.l3.setText()
     except:
         print "error pintando"
Exemplo n.º 18
0
def intro_prompt():
    if os.name != 'nt':
        print "\n\n*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************\n"
        time.sleep(STANDARD_SLEEP_TIME)
        print "Press 1 & 2 to connect"

        found_motes = wiiuse.find(wiimotes, num_motes, 1)  # Find one remote, and wait up to 1 second to find it.

        # If no remotes are found...
        if not found_motes:
            print "No remotes found!  Exiting."
            sys.exit(1)
        else:
            print "... Found remote."

        connected = wiiuse.connect(wiimotes, num_motes)

        if connected:
            print 'Connected to %i wiimotes!' % connected
        else:
            print "Failed to connect.  Exiting."
            sys.exit(1)

        wiiuse.set_leds(first_wm, wiiuse.LED[0])

        print "Enabling motion sense..."
        time.sleep(STANDARD_SLEEP_TIME)
        wiiuse.motion_sensing(first_wm, 1)  # Enable motion sensing.
        time.sleep(STANDARD_SLEEP_TIME)

        print "Enabling IR...\n"
        time.sleep(STANDARD_SLEEP_TIME)
        wiiuse.set_ir(first_wm, 1)  # Enable IR (No sensor bar yet.)
        time.sleep(STANDARD_SLEEP_TIME)

        print "*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************"
        time.sleep(STANDARD_SLEEP_TIME)
        print "*************************************\n"

        time.sleep(STANDARD_SLEEP_TIME)
        star_wave()
        print "\nLet's begin!\n"
        star_wave()
Exemplo n.º 19
0
	def start( self ):
		found = wii.find( self._pointer, self._nmotes, 5 )
		assert found
		print( 'found wiimotes', found )
		connected = wii.wiiuse_connect( self._pointer, self._nmotes )	# NOT wii.connect
		assert connected
		print( 'connected wiimotes', connected )

		for i in range( self._nmotes ):
			wm = self._pointer[i]
			wii.motion_sensing(wm, 1)
			wii.set_leds( wm, wii.WIIMOTE_LED_2)

		self._active = True
		return found
Exemplo n.º 20
0
    def start(self):
        found = wii.find(self._pointer, self._nmotes, 5)
        assert found
        print('found wiimotes', found)
        connected = wii.wiiuse_connect(self._pointer,
                                       self._nmotes)  # NOT wii.connect
        assert connected
        print('connected wiimotes', connected)

        for i in range(self._nmotes):
            wm = self._pointer[i]
            wii.motion_sensing(wm, 1)
            wii.set_leds(wm, wii.WIIMOTE_LED_2)

        self._active = True
        return found
Exemplo n.º 21
0
    def handle_event(self, wmp):
        wm = wmp[0]
        print('--- EVENT [Wiimote ID %i] ---' % wm.unid)

        if wm.btns:
            for name, b in wiiuse.button.items():
                if wiiuse.is_pressed(wm, b):
                    print(name, 'pressed')

            if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
                wiiuse.motion_sensing(wmp, 0)
            if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
                wiiuse.motion_sensing(wmp, 1)
            if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
                wiiuse.toggle_rumble(wmp)
            if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
                wiiuse.set_ir(wmp, 1)
            if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
                wiiuse.set_ir(wmp, 0)

        if wiiuse.using_acc(wm):
            print('roll  = %f' % wm.orient.roll)
            print('pitch = %f' % wm.orient.pitch)
            print('yaw   = %f' % wm.orient.yaw)

        #if wiiuse.using_ir(wm):
        #    for i in range(4):
        #        if wm.ir.dot[i].visible:
        #            print 'IR source %i: (%u, %u)' % (i, wm.ir.dot[i].x, wm.ir.dot[i].y)
        #    print 'IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y)
        #    print 'IR z distance: %f' % wm.ir.z

        if wm.exp.type == wiiuse.EXP_NUNCHUK:
            nc = wm.exp.u.nunchuk

            if abs(nc.js.mag) < self.deadthres:
                self.end(self.ids[1])

            for name, b in wiiuse.nunchuk_button.items():
                if wiiuse.is_pressed(nc, b):
                    print('Nunchuk: %s is pressed' % name)

            print('nunchuk roll  = %f' % nc.orient.roll)
            print('nunchuk pitch = %f' % nc.orient.pitch)
            print('nunchuk yaw   = %f' % nc.orient.yaw)
            print('nunchuk joystick angle:     %f' % nc.js.ang)
            print('nunchuk joystick magnitude: %f' % nc.js.mag)
Exemplo n.º 22
0
 def run(self):
     #iniciar Wiimote
     self.nmotes = 1
     self.wiimotes = wiiuse.init(self.nmotes)
     found = wiiuse.find(self.wiimotes, self.nmotes, 5)
     if not found:
         print 'not found'
         sys.exit(1)
     connected = wiiuse.connect(self.wiimotes, self.nmotes)
     if connected:
         print 'Connected to %i wiimotes (of %i found).' % (connected,
                                                            found)
     else:
         print 'failed to connect to any wiimote.'
         sys.exit(1)
     for i in range(self.nmotes):
         wiiuse.set_leds(self.wiimotes[i], wiiuse.LED[i])
         wiiuse.status(self.wiimotes[0])
         wiiuse.set_ir(self.wiimotes[0], 1)
         wiiuse.set_ir_vres(self.wiimotes[i], 1000, 1000)
     """wiiuse.rumble(self.wiimotes[0], 10)
         time.sleep(0.1)
         wiiuse.rumble(self.wiimotes[0], 0)"""
     for i in range(4):
         wiiuse.set_leds(self.wiimotes[0], wiiuse.LED[3 - i])
         time.sleep(0.2)
     self.wm = self.wiimotes[0][0]
     #iniciar Wiimote
     while self.sigue:
         wiiuse.motion_sensing(self.wiimotes, self.nmotes)
         wiiuse.poll(self.wiimotes, self.nmotes)
         print wiiuse.using_acc(self.wm)
         print "gforce \t" + str(self.wm.gforce.x)
         print "gforce \t" + str(self.wm.gforce.y)
         print "gforce \t" + str(self.wm.gforce.z)
         print "accel \t" + str(self.wm.accel.x)
         print "orient \t" + str(self.wm.orient.roll)
         print "orient \t" + str(self.wm.orient.pitch)
         print "orient \t" + str(self.wm.orient.yaw)
         print "accel_calib \t" + str(self.wm.accel_calib.cal_g.x)
         print "state \t" + str(self.wm.state)
         print "lstate\t" + str(self.wm.lstate.orient.roll)
         print "lstate\t" + str(self.wm.lstate.orient.pitch)
         print "lstate\t" + str(self.wm.lstate.orient.yaw)
         print "#" * 30
         time.sleep(0.1)
Exemplo n.º 23
0
 def run(self):
       #iniciar Wiimote
       self.nmotes = 1
       self.wiimotes = wiiuse.init(self.nmotes)
       found = wiiuse.find(self.wiimotes, self.nmotes, 5)
       if not found:
             print 'not found'
             sys.exit(1)
       connected = wiiuse.connect(self.wiimotes, self.nmotes)
       if connected:
             print 'Connected to %i wiimotes (of %i found).' % (connected, found)
       else:
             print 'failed to connect to any wiimote.'
             sys.exit(1)
       for i in range(self.nmotes):
             wiiuse.set_leds(self.wiimotes[i], wiiuse.LED[i])
             wiiuse.status(self.wiimotes[0])
             wiiuse.set_ir(self.wiimotes[0], 1)
             wiiuse.set_ir_vres(self.wiimotes[i], 1000, 1000)
       """wiiuse.rumble(self.wiimotes[0], 10)
       time.sleep(0.1)
       wiiuse.rumble(self.wiimotes[0], 0)"""
       for i in range(4):
             wiiuse.set_leds(self.wiimotes[0], wiiuse.LED[3-i])
             time.sleep(0.2)
       self.wm = self.wiimotes[0][0]
       #iniciar Wiimote
       while self.sigue:
             wiiuse.motion_sensing(self.wiimotes, self.nmotes)
             wiiuse.poll(self.wiimotes, self.nmotes)
             print wiiuse.using_acc(self.wm)
             print "gforce \t"+str(self.wm.gforce.x)
             print "gforce \t"+str(self.wm.gforce.y)
             print "gforce \t"+str(self.wm.gforce.z)
             print "accel \t"+str(self.wm.accel.x)
             print "orient \t"+str(self.wm.orient.roll)
             print "orient \t"+str(self.wm.orient.pitch)
             print "orient \t"+str(self.wm.orient.yaw)
             print "accel_calib \t"+str(self.wm.accel_calib.cal_g.x)
             print "state \t"+str(self.wm.state)
             print "lstate\t"+str(self.wm.lstate.orient.roll)
             print "lstate\t"+str(self.wm.lstate.orient.pitch)
             print "lstate\t"+str(self.wm.lstate.orient.yaw)
             print "#"*30
             time.sleep(0.1)
Exemplo n.º 24
0
 def drawLines(self, qp): ## este metodo hay que editarlo para que pinte yn punto
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     pen = QtGui.QPen(QtCore.Qt.black, 10, QtCore.Qt.DotLine)
     qp.setPen(pen)
     try:
         x=1024-self.wm.ir.x
         y=768-self.wm.ir.y
         #print str(x)+" "+str(y)
         qp.drawPoint(x,y)
         win32api.SetCursorPos((x,y))
         """win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,0,0)
         win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,0,0)"""
         self.l1.setText("x + "+str(self.wm.ir.x))
         self.l2.setText("y + "+str(self.wm.ir.y))
         self.l3=0
     except:
         print "error pintando"
Exemplo n.º 25
0
def handle_event(wmp):
    wm = wmp[0]
    print '--- EVENT [wiimote id %i] ---' % wm.unid

    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print name,'pressed'

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            wiiuse.set_ir(wmp, 0)

    if wiiuse.using_acc(wm):
        print 'roll  = %f' % wm.orient.roll
        print 'pitch = %f' % wm.orient.pitch
        print 'yaw   = %f' % wm.orient.yaw

    if wiiuse.using_ir(wm):
        for i in range(4):
            if wm.ir.dot[i].visible:
                print 'IR source %i: (%u, %u)' % (i, wm.ir.dot[i].x, wm.ir.dot[i].y)
        print 'IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y)
        print 'IR z distance: %f' % wm.ir.z

    if wm.exp.type == wiiuse.EXP_NUNCHUK:
        nc = wm.exp.u.nunchuk

        for name,b in wiiuse.nunchuk_button.items():
            if wiiuse.is_pressed(nc, b):
                print 'Nunchuk: %s is pressed' % name

        print 'nunchuk roll  = %f' % nc.orient.roll
        print 'nunchuk pitch = %f' % nc.orient.pitch
        print 'nunchuk yaw   = %f' % nc.orient.yaw
        print 'nunchuk joystick angle:     %f' % nc.js.ang
        print 'nunchuk joystick magnitude: %f' % nc.js.mag
Exemplo n.º 26
0
	def __init__(self, index=0, pointer=None):
		assert pointer
		self.index = index
		self.pointer = pointer
		self.gain_x = 2.0
		self.gain_y = 2.0
		self.gain_z = 3.0

		self.baseline_x = 0.0
		self.baseline_y = -0.15
		self.baseline_z = 0.0

		wii.motion_sensing(pointer, 1)
		wii.set_leds( pointer, wii.WIIMOTE_LED_2)

		self.configure_device(
			axes=3,
			buttons=len(self.WIIMOTE_BUTTONS),
		)
Exemplo n.º 27
0
 def ir_points(self):
     try:
         wiiuse.motion_sensing(self.wiimotes, self.nmotes)
         wiiuse.poll(self.wiimotes, self.nmotes)
         puntosx = []
         puntosy = []
         for b in self.wm.ir.dot:
             if b.rx != 0 and b.rx < 1030 and b.rx > 0:
                 puntosx.append(b.rx)
         for a in self.wm2.ir.dot:
             if a.rx != 0 and a.rx < 800 and a.rx > 0:
                 puntosy.append(a.rx)
         puntos = []
         for i in range(0, 2):
             #qp.drawPoint(puntosx[i],puntosy[i])
             puntos.append(puntosx[i])
             puntos.append(puntosy[i])
     except:
         print "error de ir"
     return puntos
Exemplo n.º 28
0
 def ir_points(self):
       try:
           wiiuse.motion_sensing(self.wiimotes,self.nmotes)
           wiiuse.poll(self.wiimotes, self.nmotes)
           puntosx=[]
           puntosy=[]
           for b in self.wm.ir.dot:
               if b.rx!=0 and b.rx<1030 and b.rx>0:
                   puntosx.append(b.rx)
           for a in self.wm2.ir.dot:
               if a.rx!=0 and a.rx<800 and  a.rx>0:
                   puntosy.append(a.rx)
           puntos=[]
           for i in range(0,2):
               #qp.drawPoint(puntosx[i],puntosy[i])
               puntos.append(puntosx[i])
               puntos.append(puntosy[i])
       except:
           print "error de ir"
       return puntos
Exemplo n.º 29
0
 def drawLines(self,
               qp):  ## este metodo hay que editarlo para que pinte yn punto
     wiiuse.motion_sensing(self.wiimotes, self.nmotes)
     wiiuse.poll(self.wiimotes, self.nmotes)
     pen = QtGui.QPen(QtCore.Qt.black, 10, QtCore.Qt.DotLine)
     qp.setPen(pen)
     try:
         T = "(x,y)\t\tnum_dots\t\taspect\tpos\tstate\tax\tay\t\tdistance\tz\n"
         x = self.wm.ir.x
         y = self.wm.ir.y
         T += "(" + str(x) + " , " + str(y) + ")\t" + str(
             self.wm.ir.num_dots
         ) + "\t\t" + str(self.wm.ir.pos) + "\t" + str(
             self.wm.ir.state) + "\t" + str(self.wm.ir.ax) + "\t" + str(
                 self.wm.ir.ay) + "\t\t" + str(
                     self.wm.ir.distance) + "\t" + str(self.wm.ir.z)
         #print str(x)+" "+str(y)
         qp.drawPoint(x, y)
         self.l1.setText("Accel X\t\tAccel Y\n" + str(self.wm.gforce.x) +
                         "\t\t" + str(self.wm.gforce.y) + "")
         self.l2.setText(T)
         #print "##"
         T = "(x,y)\t\torder\tVisible\trx\try\tsize\n"
         for a in self.wm.ir.dot:
             T += "( " + str(a.x) + " , " + str(a.y) + " )\t" + str(
                 a.order) + "\t" + str(a.visible) + "\t" + str(
                     a.rx) + "\t" + str(a.ry) + "\t" + str(a.size) + "\n"
             qp.drawPoint(a.rx, a.ry)
         T += "VRES\t"
         for a in self.wm.ir.vres:
             T += str(a) + "\t"
         T += "\t###\tOfset\t"
         for a in self.wm.ir.offset:
             T += str(a) + "\t"
         self.l3.setText(T)
         #print "##"
         #self.l3.setText(str(self.wm.ir.dot))
     except:
         print "error pintando"
Exemplo n.º 30
0
#######iniciando Wiiii
####################
nmotes = 1
wiimotes = wiiuse.init(nmotes)
found = wiiuse.find(wiimotes, nmotes, 5)
if not found:
    print 'not found'
    sys.exit(1)
connected = wiiuse.connect(wiimotes, nmotes)
if connected:
    print 'Connected to %i wiimotes (of %i found).' % (connected, found)
else:
    print 'failed to connect to any wiimote.'
    sys.exit(1)
for i in range(nmotes):
    wiiuse.set_leds(wiimotes[i], wiiuse.LED[i])
    wiiuse.status(wiimotes[0])
    wiiuse.set_ir(wiimotes[0], 1)
    wiiuse.set_ir_vres(wiimotes[i], 1000, 1000)
wiiuse.rumble(wiimotes[0], 10)
time.sleep(0.1)
wiiuse.rumble(wiimotes[0], 0)
wm = wiimotes[0][0]
while True:
    wiiuse.motion_sensing(wiimotes,nmotes)
    wiiuse.poll(wiimotes, nmotes)
    print wm.ir.num_dots
    print wm.ir.x
    print wm.ir.y
    print "##"
 def run(self):
       while self.sigue:
             time.sleep(0.105)
             #wiiuse.motion_sensing(self.wiimotes,self.nmotes)
             wiiuse.poll(self.wiimotes, self.nmotes)
             try:
                   """print self.wm.orient_threshold
                   print self.wm.accel_threshold
                   print self.wm.event
                   print "#####"
                   print self.wm.gforce.x
                   print self.wm.gforce.y
                   print self.wm.gforce.z"""
                   s = str(self.wm.accel_threshold)
                   #print "thresold "+s
                   if s!="0":
                         if s=="1":
                               print "se solto el boton 2"
                               self.window.emit(SIGNAL("BotonSuelto"), "2")
                         if s=="2":
                               print "se solto el boton 1"
                               self.window.emit(SIGNAL("BotonSuelto"), "1")
                         if s=="16":
                               print "se solto el boton -"
                               self.window.emit(SIGNAL("BotonSuelto"), "-")
                         if s=="128":
                               print "se solto el boton HOME"
                               self.window.emit(SIGNAL("BotonSuelto"), "HOME")
                         if s=="4096":
                               print "se solto el boton +"
                               self.window.emit(SIGNAL("BotonSuelto"), "+")
                         if s=="8":
                               print "se solto el boton A"
                               self.window.emit(SIGNAL("BotonSuelto"), "A")
                         if s=="1024":
                               print "se solto el boton ABAJO"
                               self.window.emit(SIGNAL("BotonSuelto"), "ABAJO")
                         if s=="512":
                               print "se solto el boton DERECHA"
                               self.window.emit(SIGNAL("BotonSuelto"), "DERECHA")
                         if s=="2048":
                               print "se solto el boton ARRIBA"
                               self.window.emit(SIGNAL("BotonSuelto"), "ARRIBA")
                         if s=="256":
                               print "se solto el boton IZQUIERDA"
                               self.window.emit(SIGNAL("BotonSuelto"), "IZQUIERDA")
                         if s=="4":
                               print "se solto el boton B"
                               self.window.emit(SIGNAL("BotonSuelto"), "B")
                         if s=="3":
                               print "se solto el boton 1 y 2"
                               self.window.emit(SIGNAL("BotonSuelto"), "1 y 2")
                   if str(self.wm.orient_threshold)[:3] !="0.0":
                         #print "se presiono un boton -> "+str(self.wm.orient_threshold)
                         if str(self.wm.orient_threshold)[:4] =="2.86":
                               print "arriba"
                               self.window.emit(SIGNAL("Boton"), "ARRIBA")
                               #self.window.repaint()
                         if str(self.wm.orient_threshold)[:4] =="1.43":
                               print "abajo"
                               self.window.emit(SIGNAL("Boton"), "ABAJO")
                         if str(self.wm.orient_threshold)[:4] =="7.17":
                               print "derecha"
                               self.window.emit(SIGNAL("Boton"), "DERECHA")
                         if str(self.wm.orient_threshold)[:4] =="3.58":
                               print "izquierda"
                               self.window.emit(SIGNAL("Boton"), "IZQUIERDA")
                         if str(self.wm.orient_threshold)[:4] =="1.12":
                               print "A"
                               self.window.emit(SIGNAL("Boton"), "A")
                         if str(self.wm.orient_threshold)[:4] =="5.60":
                               print "B"
                               self.window.emit(SIGNAL("Boton"), "B")
                         if str(self.wm.orient_threshold)[:4] =="2.24":
                               print "-"
                               self.window.emit(SIGNAL("Boton"), "-")
                         if str(self.wm.orient_threshold)[:4] =="1.79":
                               print "Home"
                               self.window.emit(SIGNAL("Boton"), "HOME")
                         if str(self.wm.orient_threshold)[:4] =="5.73":
                               print "+"
                               self.window.emit(SIGNAL("Boton"), "+")
                         if str(self.wm.orient_threshold)[:4] =="2.80":
                               print "1"
                               self.window.emit(SIGNAL("Boton"), "1")
                         if str(self.wm.orient_threshold)[:4] =="1.40":
                               print "2"
                               self.window.emit(SIGNAL("Boton"), "2")
                         if str(self.wm.orient_threshold)[:4] =="1.83" or str(self.wm.orient_threshold)[:4] =="9.18":
                               print "1 y 2"
                               self.window.emit(SIGNAL("Boton"), "1 y 2")
                   wiiuse.motion_sensing(self.wiimotes, 1)
                   #wiiuse.poll(self.wiimotes, self.nmotes)
                   print "gforce "+str(self.wm.gforce.x)
                   print "gforce "+str(self.wm.gforce.y)
                   print "gforce "+str(self.wm.gforce.z)
                   print "accel "+str(self.wm.accel.x)
                   print "orient "+str(self.wm.orient.roll)
                   print "orient "+str(self.wm.orient.pitch)
                   print "orient "+str(self.wm.orient.yaw)
                   print "accel_calib "+str(self.wm.accel_calib.cal_g.x)
                   print "state "+str(self.wm.state)
                   print "lstate"+str(self.wm.lstate.orient.roll)
                   print "lstate"+str(self.wm.lstate.orient.pitch)
                   print "lstate"+str(self.wm.lstate.orient.yaw)
                   #wiiuse.motion_sensing(self.wiimotes, 0)
             except :
               print "error"
Exemplo n.º 32
0
 def run(self):
     while self.sigue:
         time.sleep(0.105)
         #wiiuse.motion_sensing(self.wiimotes,self.nmotes)
         wiiuse.poll(self.wiimotes, self.nmotes)
         try:
             """print self.wm.orient_threshold
                     print self.wm.accel_threshold
                     print self.wm.event
                     print "#####"
                     print self.wm.gforce.x
                     print self.wm.gforce.y
                     print self.wm.gforce.z"""
             s = str(self.wm.accel_threshold)
             #print "thresold "+s
             if s != "0":
                 if s == "1":
                     print "se solto el boton 2"
                     self.window.emit(SIGNAL("BotonSuelto"), "2")
                 if s == "2":
                     print "se solto el boton 1"
                     self.window.emit(SIGNAL("BotonSuelto"), "1")
                 if s == "16":
                     print "se solto el boton -"
                     self.window.emit(SIGNAL("BotonSuelto"), "-")
                 if s == "128":
                     print "se solto el boton HOME"
                     self.window.emit(SIGNAL("BotonSuelto"), "HOME")
                 if s == "4096":
                     print "se solto el boton +"
                     self.window.emit(SIGNAL("BotonSuelto"), "+")
                 if s == "8":
                     print "se solto el boton A"
                     self.window.emit(SIGNAL("BotonSuelto"), "A")
                 if s == "1024":
                     print "se solto el boton ABAJO"
                     self.window.emit(SIGNAL("BotonSuelto"), "ABAJO")
                 if s == "512":
                     print "se solto el boton DERECHA"
                     self.window.emit(SIGNAL("BotonSuelto"), "DERECHA")
                 if s == "2048":
                     print "se solto el boton ARRIBA"
                     self.window.emit(SIGNAL("BotonSuelto"), "ARRIBA")
                 if s == "256":
                     print "se solto el boton IZQUIERDA"
                     self.window.emit(SIGNAL("BotonSuelto"), "IZQUIERDA")
                 if s == "4":
                     print "se solto el boton B"
                     self.window.emit(SIGNAL("BotonSuelto"), "B")
                 if s == "3":
                     print "se solto el boton 1 y 2"
                     self.window.emit(SIGNAL("BotonSuelto"), "1 y 2")
             if str(self.wm.orient_threshold)[:3] != "0.0":
                 #print "se presiono un boton -> "+str(self.wm.orient_threshold)
                 if str(self.wm.orient_threshold)[:4] == "2.86":
                     print "arriba"
                     self.window.emit(SIGNAL("Boton"), "ARRIBA")
                     #self.window.repaint()
                 if str(self.wm.orient_threshold)[:4] == "1.43":
                     print "abajo"
                     self.window.emit(SIGNAL("Boton"), "ABAJO")
                 if str(self.wm.orient_threshold)[:4] == "7.17":
                     print "derecha"
                     self.window.emit(SIGNAL("Boton"), "DERECHA")
                 if str(self.wm.orient_threshold)[:4] == "3.58":
                     print "izquierda"
                     self.window.emit(SIGNAL("Boton"), "IZQUIERDA")
                 if str(self.wm.orient_threshold)[:4] == "1.12":
                     print "A"
                     self.window.emit(SIGNAL("Boton"), "A")
                 if str(self.wm.orient_threshold)[:4] == "5.60":
                     print "B"
                     self.window.emit(SIGNAL("Boton"), "B")
                 if str(self.wm.orient_threshold)[:4] == "2.24":
                     print "-"
                     self.window.emit(SIGNAL("Boton"), "-")
                 if str(self.wm.orient_threshold)[:4] == "1.79":
                     print "Home"
                     self.window.emit(SIGNAL("Boton"), "HOME")
                 if str(self.wm.orient_threshold)[:4] == "5.73":
                     print "+"
                     self.window.emit(SIGNAL("Boton"), "+")
                 if str(self.wm.orient_threshold)[:4] == "2.80":
                     print "1"
                     self.window.emit(SIGNAL("Boton"), "1")
                 if str(self.wm.orient_threshold)[:4] == "1.40":
                     print "2"
                     self.window.emit(SIGNAL("Boton"), "2")
                 if str(self.wm.orient_threshold)[:4] == "1.83" or str(
                         self.wm.orient_threshold)[:4] == "9.18":
                     print "1 y 2"
                     self.window.emit(SIGNAL("Boton"), "1 y 2")
             wiiuse.motion_sensing(self.wiimotes, 1)
             #wiiuse.poll(self.wiimotes, self.nmotes)
             print "gforce " + str(self.wm.gforce.x)
             print "gforce " + str(self.wm.gforce.y)
             print "gforce " + str(self.wm.gforce.z)
             print "accel " + str(self.wm.accel.x)
             print "orient " + str(self.wm.orient.roll)
             print "orient " + str(self.wm.orient.pitch)
             print "orient " + str(self.wm.orient.yaw)
             print "accel_calib " + str(self.wm.accel_calib.cal_g.x)
             print "state " + str(self.wm.state)
             print "lstate" + str(self.wm.lstate.orient.roll)
             print "lstate" + str(self.wm.lstate.orient.pitch)
             print "lstate" + str(self.wm.lstate.orient.yaw)
             #wiiuse.motion_sensing(self.wiimotes, 0)
         except:
             print "error"