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,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, 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]
Exemple #4
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])
Exemple #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]
 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):
     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]
Exemple #8
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]
Exemple #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])
Exemple #10
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
 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__()
Exemple #12
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__()
Exemple #13
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")
Exemple #14
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 "##"
	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:
		alp = float(alpha)/100	
Exemple #16
0
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])

print 'done'
    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])

    print 'done'

Exemple #18
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])