Example #1
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]
 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]
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
Example #5
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])
Example #6
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])
Example #7
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]
 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]
 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]
 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]
 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]
Example #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()
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['-']):
            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 __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__()
Example #15
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()
Example #16
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__()
Example #17
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 #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)
 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)
Example #20
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
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)
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)
Example #23
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
Example #24
0
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():
        cmd = chr(int(w.yaw)) + chr(int(w.pitch)) + chr(int(w.throttle)) + chr(
            int(w.yawCorrect))
Example #25
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 "##"