def __init__(self,w):
       threading.Thread.__init__(self)
       self.rotX = 0
       self.rotY = 0
       self.rotZ = 0
       self.window = w
       self.sigue=True
       #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)
       self.wm = self.wiimotes[0][0]
Ejemplo n.º 2
0
def init():
    if os.name != 'nt': print 'Press 1&2'

    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)

    try:
        rum = 1
        while True:
            r = wiiuse.poll(wiimotes, nmotes)
            if r != 0:
                handle_event(wiimotes[0])
    except KeyboardInterrupt:
        for i in range(nmotes):
            wiiuse.set_leds(wiimotes[i], 0)
            wiiuse.rumble(wiimotes[i], 0)
            wiiuse.disconnect(wiimotes[i])
Ejemplo n.º 3
0
 def __init__(self, parent=None):
     self.parent = parent
     QtOpenGL.QGLWidget.__init__(self, parent)
     self.xRotDeg = 0.0
     self.yRotDeg = 0.0
     self.zRotDeg = 0.0
     #######iniciando Wiiii
     #####################
     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.5)
     wiiuse.rumble(self.wiimotes[0], 0)
     self.wm = self.wiimotes[0][0]
Ejemplo n.º 4
0
 def __init__(self):
     super(Grafico, self).__init__()
     self.l1=0
     self.l2=0
     self.l3=0
     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.5)
     wiiuse.rumble(self.wiimotes[0], 0)
     self.wm = self.wiimotes[0][0]
Ejemplo n.º 5
0
 def __init__(self, w):
     threading.Thread.__init__(self)
     self.rotX = 0
     self.rotY = 0
     self.rotZ = 0
     self.IRX = 0
     self.IRY = 0
     self.window = w
     self.sigue = True
     self.releasedButton = {
         "1": "2",
         "2": "1",
         "16": "-",
         "128": "HOME",
         "4096": "+",
         "8": "A",
         "1024": "ABAJO",
         "512": "DERECHA",
         "2048": "ARRIBA",
         "256": "IZQUIERDA",
         "4": "B",
         "3": "1+2"
     }
     self.pressedButton = {
         "2.86": "ARRIBA",
         "1.43": "ABAJO",
         "7.17": "DERECHA",
         "3.58": "IZQUIERDA",
         "1.12": "A",
         "5.60": "B",
         "2.24": "-",
         "1.79": "HOME",
         "5.73": "+",
         "2.80": "1",
         "1.40": "2",
         "2.75": "1+2"
     }
     #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)
     self.wm = self.wiimotes[0][0]
Ejemplo n.º 6
0
 def __init__(self, w):
     threading.Thread.__init__(self)
     self.window = w
     self.sigue = True
     #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.rumble(self.wiimotes[0], 10)
     time.sleep(0.1)
     wiiuse.rumble(self.wiimotes[0], 0)
     self.wm = self.wiimotes[0][0]
Ejemplo n.º 7
0
    def run(self):
        '''This runs in a separate thread'''
        # import here to avoid thread problems on windows
        global wiiuse
        import wiiuse
        
        self.wiimotes = wiiuse.init(self.nmotes)
        found = wiiuse.find(self.wiimotes, self.nmotes, self.timeout)
        self.actual_nmotes = wiiuse.connect(self.wiimotes, self.nmotes)

        for i in range(self.nmotes):
            wiiuse.set_leds(self.wiimotes[i], wiiuse.LED[i])

        self.go = self.actual_nmotes != 0

        self.startup.put(self.go)

        while self.go:
            try:
                if wiiuse.poll(self.wiimotes, self.nmotes):
                    for i in range(self.nmotes):
                        wm = self.wiimotes[i][0]
                        if wm.event:
                            self.event_cb(wm)

            except:
                pass

            # allow executing functions in this thread
            while True:
                try:
                    func, args = self.queue.get_nowait()
                except Empty:
                    break
                func(*args)
Ejemplo n.º 8
0
 def __init__(self, parent=None):
     self.parent = parent
     QtOpenGL.QGLWidget.__init__(self, parent)
     self.xRotDeg = 0.0
     self.yRotDeg = 0.0
     self.zRotDeg = 0.0
     #######iniciando Wiiii
     #####################
     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.5)
     wiiuse.rumble(self.wiimotes[0], 0)
     self.wm = self.wiimotes[0][0]
Ejemplo n.º 9
0
def init():
    if os.name != 'nt': print 'Press 1&2'

    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)

    try:
        rum = 1
        while True:
            r = wiiuse.poll(wiimotes, nmotes)
            if r != 0:
                handle_event(wiimotes[0])
    except KeyboardInterrupt:
        for i in range(nmotes):
            wiiuse.set_leds(wiimotes[i], 0)
            wiiuse.rumble(wiimotes[i], 0)
            wiiuse.disconnect(wiimotes[i])
 def __init__(self,w):
       threading.Thread.__init__(self)
       self.rotX = 0
       self.rotY = 0
       self.rotZ = 0
       self.window = w
       self.sigue=True
       self.releasedButton ={"1":"2","2":"1","16":"-","128":"HOME","4096":"+","8":"A","1024":"ABAJO",
                             "512":"DERECHA","2048":"ARRIBA","256":"IZQUIERDA","4":"B","3":"1+2"}
       self.pressedButton  ={"2.86":"ARRIBA","1.43":"ABAJO","7.17":"DERECHA","3.58":"IZQUIERDA","1.12":"A",
                             "5.60":"B","2.24":"-","1.79":"HOME","5.73":"+","2.80":"1","1.40":"2","2.75":"1+2"}
       #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)
       self.wm = self.wiimotes[0][0]
Ejemplo n.º 11
0
def disconnect(wiimotes, nmotes):
    wmp = wiimotes[0]
    wm = wmp[0]
    print
    for i in range(nmotes):
        wiiuse.set_leds(wiimotes[i], 0)
        wiiuse.rumble(wiimotes[i], 0)
        wiiuse.disconnect(wiimotes[i])
        print 'wiimote id %i disconnected' % wm.unid
Ejemplo n.º 12
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()
Ejemplo n.º 13
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()
 def __init__(self):
     super(Grafico, self).__init__()
     self.maxG1 =1.0
     self.maxG2 =1.0
     self.maxG3 =1.0
     self.minG1 =-1.0
     self.minG2 =-1.0
     self.minG3 =-1.0
     self.b1 = True
     self.b2 = True
     self.b3 = True
     self.l1 = None
     self.l2 = None
     self.l3 = None
     self.arr = [0 for i in range(0,350)]
     self.arr1 = [0 for i in range(0,350)]
     self.arr2 = [0 for i in range(0,350)]
     #######iniciando Wiiii
     #####################
     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.5)
     wiiuse.rumble(self.wiimotes[0], 0)
     self.wm = self.wiimotes[0][0]
     #wiiuse.motion_sensing(self.wiimotes, 0)
     ###############################
     #######iniciando wii
     ###iniciando hilos
     self.hilo = Wiibotones(self)
     self.hilo.start()
     #################
     
     """super(Example, self).__init__()
Ejemplo n.º 15
0
 def __init__(self):
     super(Grafico, self).__init__()
     self.maxG1 = 1.0
     self.maxG2 = 1.0
     self.maxG3 = 1.0
     self.minG1 = -1.0
     self.minG2 = -1.0
     self.minG3 = -1.0
     self.b1 = True
     self.b2 = True
     self.b3 = True
     self.l1 = None
     self.l2 = None
     self.l3 = None
     self.arr = [0 for i in range(0, 350)]
     self.arr1 = [0 for i in range(0, 350)]
     self.arr2 = [0 for i in range(0, 350)]
     #######iniciando Wiiii
     #####################
     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.5)
     wiiuse.rumble(self.wiimotes[0], 0)
     self.wm = self.wiimotes[0][0]
     #wiiuse.motion_sensing(self.wiimotes, 0)
     ###############################
     #######iniciando wii
     ###iniciando hilos
     self.hilo = Wiibotones(self)
     self.hilo.start()
     #################
     """super(Example, self).__init__()
Ejemplo n.º 16
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
Ejemplo n.º 17
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
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
    def __init__(self):
        self.nmotes = 1
        self.wiimotes = wiiuse.init(self.nmotes)

        found = wiiuse.find(self.wiimotes, self.nmotes, 5)
        if not found:
            print 'wiimote not found'

        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.'

        for i in range(self.nmotes):
            wiiuse.set_leds(self.wiimotes[i], wiiuse.LED[i])
            wiiuse.status(self.wiimotes[0])
Ejemplo n.º 21
0
def getConnected():
    #global wiimotes
    #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)
Ejemplo n.º 22
0
def getConnected():
    #global wiimotes
    #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)
Ejemplo n.º 23
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),
		)
Ejemplo n.º 24
0
def main():
    if os.name != 'nt': print('Press 1 & 2 to continue')

    wiimotes = wiiuse.init(nmotes)

    found = wiiuse.find(wiimotes, nmotes, 5)
    if not found:
        print('No Wii remote found, exiting with error code 1...')
        sys.exit(1)

    connected = wiiuse.connect(wiimotes, nmotes)
    if connected:
        print('Connected to %i Wii remote(s) (of %i found).' %
              (connected, found))
    else:
        print('Failed to connect to any Wii remote.')
        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)

    wm = WiiMIDI()

    try:
        rum = 1
        while True:
            r = wiiuse.poll(wiimotes, nmotes)
            if r != 0:
                wm.handle_event(wiimotes[0])
    except KeyboardInterrupt:
        for i in range(nmotes):
            wiiuse.set_leds(wiimotes[i], 0)
            wiiuse.rumble(wiimotes[i], 0)
            wiiuse.disconnect(wiimotes[i])

    print("Ended connection")
Ejemplo n.º 25
0
def connect():
    if os.name != 'nt': print 'Press 1&2'

    wiimotes = wiiuse.init(nmotes)

    found = wiiuse.find(wiimotes, nmotes, 5)
    if not found:
        st='not found'
        print st
        return st
    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)
    
    return wiimotes,nmotes
Ejemplo n.º 26
0
#!/usr/bin/python
# updated Nov 2011
import os, sys, time
import wiiuse as wii

MAX_WIIMOTES = 2
context = wii.init(MAX_WIIMOTES)
print(context)

found = wii.find(context, MAX_WIIMOTES, 5)
assert found
print('found wiimotes', found)

#connected = wii.connect( context, found )	# dont get confused by other connect function from bluez
connected = wii.wiiuse_connect(context, MAX_WIIMOTES)
assert connected

wii.set_leds(context[0], wii.WIIMOTE_LED_1)
Ejemplo n.º 27
0
#!/usr/bin/python
# updated Nov 2011
import os,sys, time
import wiiuse as wii

MAX_WIIMOTES = 2
context = wii.init( MAX_WIIMOTES )
print( context )

found = wii.find( context, MAX_WIIMOTES, 5 )
assert found
print( 'found wiimotes', found )

#connected = wii.connect( context, found )	# dont get confused by other connect function from bluez
connected = wii.wiiuse_connect( context, MAX_WIIMOTES )
assert connected

wii.set_leds( context[0], wii.WIIMOTE_LED_1 )



Ejemplo n.º 28
0
 def shut_down_wiimote(self):
     for i in range(self.nmotes):
         wiiuse.set_leds(self.wiimotes[i], 0)
         wiiuse.rumble(self.wiimotes[i], 0)
         wiiuse.disconnect(self.wiimotes[i])
Ejemplo n.º 29
0
 def quit(self):
     '''Go away.'''
     for i in range(self.nmotes):
         wiiuse.set_leds(self.wiimotes[i], 0)
         wiiuse.disconnect(self.wiimotes[i])
     self.go = False
Ejemplo n.º 30
0
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], 500, 500)

import serial
ser = serial.Serial()
ser.port = "/dev/ttyUSB0"  # may be called something different
ser.baudrate = 9600  # may be different
ser.open()
print "initialized Serial Controller"


def signal(w):

    if ser.isOpen():
Ejemplo n.º 31
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 "##"
Ejemplo n.º 32
0
import time

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
    
wiimotes = wiiuse.init(1)
found = wiiuse.find(wiimotes, 1, 5)
wiiuse.set_leds(wiimotes[0], wiiuse.LED[0])
if not found:
    print 'not found'
connected = wiiuse.connect(wiimotes, 1)
if connected:
	s = serial.Serial(7)		# COM7 virtual
	s.baudrate = 9600
	s.timeout = 0		# no espera a leer
	print " sa"
	while 1:
		r = wiiuse.poll(wiimotes, 1)	
		if r != 0:
			s.write(str(handle_event(wiimotes[0])))
			time.sleep(.005)
			print handle_event(wiimotes[0])	
Ejemplo n.º 33
0
def moveBloque():
	a = bloque.Fg* math.sin(math.radians(-angle))	
	bloque.Vx = a*dt
	bloque.x += bloque.Vx*dt/100
	if bloque.x > (tabla.length -bloque.length)/2: # Borde de la tabla
		bloque.x = (tabla.length -bloque.length)/2
	if bloque.x < -(tabla.length -bloque.length)/2:
		bloque.x = -(tabla.length -bloque.length)/2 
	print bloque.x

b = 0
wiimots = wiiuse.init(1)
encontrado = wiiuse.find(wiimots, 1, 5)
connected = wiiuse.connect(wiimots, 1)

wiiuse.set_leds(wiimots[0], wiiuse.LED[2])
wiiuse.rumble(wiimots[0],0)
sleep(1)


s = serial.Serial(8)		# COM8 virtual
s.baudrate = 4800

s.timeout = 0		# no espera a leer
alp = 0.0
while 1:
	#WiiMo(wiimotes[0])		
	#Wiis.an()
	alpha  = s.readline()
	
	try: