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
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
Example #3
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
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
 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)
 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)
    def event_cb(self, wm):
        '''Called when the library has some data for the user.'''
        
        if wm.btns:
            for name,b in list(wiiuse.button.items()):
                if wiiuse.is_just_pressed(wm, b):
                    pygame.event.post(pygame.event.Event(WIIMOTE_BUTTON_PRESS, button=name,
                                                         time=time.time(),
                                                         id=wm.unid))

        if wm.btns_released:
            for name,b in list(wiiuse.button.items()):
                if wiiuse.is_released(wm, b):
                    pygame.event.post(pygame.event.Event(WIIMOTE_BUTTON_RELEASE, button=name,
                                                         time=time.time(),
                                                         id=wm.unid))

        if wiiuse.using_acc(wm):
            pygame.event.post(pygame.event.Event(WIIMOTE_ACCEL, 
                                                 orient=(wm.orient.roll, wm.orient.pitch,
                                                         wm.orient.yaw),
                                                 accel=(wm.gforce.x, wm.gforce.y, wm.gforce.z),
                                                 time=time.time(),
                                                 id=wm.unid))
        if wiiuse.using_ir(wm):
            dots = [ (wm.ir.dot[i].visible, wm.ir.dot[i].x, wm.ir.dot[i].y) for i in range(4) ]
            pygame.event.post(pygame.event.Event(WIIMOTE_IR,
                                                 dots=dots,
                                                 cursor=(wm.ir.x, wm.ir.y, wm.ir.z),
                                                 time=time.time(),
                                                 id=wm.unid))

        if wm.exp.type == wiiuse.EXP_NUNCHUK:
            nc = wm.exp.u.nunchuk
            
            for name,b in list(wiiuse.nunchuk_button.items()):
                if wiiuse.is_just_pressed(nc, b):
                    pygame.event.post(pygame.event.Event(NUNCHUK_BUTTON_PRESS, button=name,
                                                         time=time.time(),
                                                         id=wm.unid))
                elif wiiuse.is_released(nc, b):
                    pygame.event.post(pygame.event.Event(NUNCHUK_BUTTON_RELEASE, button=name,
                                                         time=time.time(),
                                                         id=wm.unid))

            pygame.event.post(pygame.event.Event(NUNCHUK_ACCEL,
                                                 orient=(nc.orient.roll, nc.orient.pitch,
                                                         nc.orient.yaw),
                                                 accel=(nc.gforce.x, nc.gforce.y, nc.gforce.z),
                                                 time=time.time(),
                                                 id=wm.unid))
            pygame.event.post(pygame.event.Event(NUNCHUK_JOY,
                                                 angle=nc.js.ang,
                                                 mag=nc.js.mag,
                                                 time=time.time(),
                                                 id=wm.unid))
    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()
Example #9
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()
Example #10
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)
Example #11
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)
Example #12
0
 def run(self):
     while self.sigue:
         time.sleep(0.1)
         #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"""
             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"
                 if str(self.wm.orient_threshold)[:4] == "1.43":
                     print "abajo"
                 if str(self.wm.orient_threshold)[:4] == "7.17":
                     print "derecha"
                 if str(self.wm.orient_threshold)[:4] == "3.58":
                     print "izquierda"
                 if str(self.wm.orient_threshold)[:4] == "1.12":
                     print "A"
                 if str(self.wm.orient_threshold)[:4] == "5.60":
                     print "B"
                 if str(self.wm.orient_threshold)[:4] == "2.24":
                     print "-"
                 if str(self.wm.orient_threshold)[:4] == "1.79":
                     print "Home"
                 if str(self.wm.orient_threshold)[:4] == "5.73":
                     print "+"
                 if str(self.wm.orient_threshold)[:4] == "2.80":
                     print "1"
                 if str(self.wm.orient_threshold)[:4] == "1.40":
                     print "2"
                 if str(self.wm.orient_threshold)[:4] == "1.83" or str(
                         self.wm.orient_threshold)[:4] == "9.18":
                     print "1 y 2"
             if wiiuse.using_acc(self.wm):
                 print "acel"
         except:
             print "error"
Example #13
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
Example #14
0
 def run(self):
       while self.sigue:
             time.sleep(0.1)
             #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"""
                   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"
                         if str(self.wm.orient_threshold)[:4] =="1.43":
                               print "abajo"
                         if str(self.wm.orient_threshold)[:4] =="7.17":
                               print "derecha"
                         if str(self.wm.orient_threshold)[:4] =="3.58":
                               print "izquierda"
                         if str(self.wm.orient_threshold)[:4] =="1.12":
                               print "A"
                         if str(self.wm.orient_threshold)[:4] =="5.60":
                               print "B"
                         if str(self.wm.orient_threshold)[:4] =="2.24":
                               print "-"
                         if str(self.wm.orient_threshold)[:4] =="1.79":
                               print "Home"
                         if str(self.wm.orient_threshold)[:4] =="5.73":
                               print "+"
                         if str(self.wm.orient_threshold)[:4] =="2.80":
                               print "1"
                         if str(self.wm.orient_threshold)[:4] =="1.40":
                               print "2"
                         if str(self.wm.orient_threshold)[:4] =="1.83" or str(self.wm.orient_threshold)[:4] =="9.18":
                               print "1 y 2"
                   if wiiuse.using_acc(self.wm):
                         print "acel"
             except :
               print "error"
Example #15
0
    def motion_event(self):
        remote = self.first_wm[0]

        if wiiuse.using_acc(remote):
            print self.press_event()
            return (remote.orient.roll, remote.orient.pitch, remote.orient.yaw)
Example #16
0
            print "#####"
            #print str(wm.orient_threshold)[:3]
            print str(wm.orient_threshold)[:4]
            print hex(wm.accel_threshold)
            print str(wm.accel_threshold)
            print str(wm.event)
            print str(wm.gforce.x)
        #b.a= wm.event_buf
        #print b.a
        """for estructura in wm.event_buf:
            print estructura
            print sys.getsizeof(estructura)
        """
        #print wm.event_buf
        if wm.btns:
            for name,b in wiiuse.button.items():
                if wiiuse.is_just_pressed(wm, b):
                    print "algo se apreto"
        if wiiuse.using_acc(wm):
            print "acel"
    except :
        print "error"
    #print wm.gforce.x
    """print wiiuse.using_acc(wm)
    print wm.btns"""


#wiiuse.motion_sensing(wiimotes, 0)
###############################
#######iniciando wii
Example #17
0
    def motion_event(self):
        remote = self.first_wm[0]

        if wiiuse.using_acc(remote):
            print self.press_event()
            return (remote.orient.roll, remote.orient.pitch, remote.orient.yaw)
Example #18
0
        if str(wm.orient_threshold)[:4] != "0.0":
            print "#####"
            #print str(wm.orient_threshold)[:3]
            print str(wm.orient_threshold)[:4]
            print hex(wm.accel_threshold)
            print str(wm.accel_threshold)
            print str(wm.event)
            print str(wm.gforce.x)
        #b.a= wm.event_buf
        #print b.a
        """for estructura in wm.event_buf:
            print estructura
            print sys.getsizeof(estructura)
        """
        #print wm.event_buf
        if wm.btns:
            for name, b in wiiuse.button.items():
                if wiiuse.is_just_pressed(wm, b):
                    print "algo se apreto"
        if wiiuse.using_acc(wm):
            print "acel"
    except:
        print "error"
    #print wm.gforce.x
    """print wiiuse.using_acc(wm)
    print wm.btns"""

#wiiuse.motion_sensing(wiimotes, 0)
###############################
#######iniciando wii