コード例 #1
0
ファイル: wiiRead.py プロジェクト: leecarraher/wiichopper
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])
コード例 #2
0
ファイル: wiiRead.py プロジェクト: leecarraher/wiichopper
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])
コード例 #3
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
コード例 #4
0
def getData():
    getConnected()
    try:
        rum=1
        while True:
            r=wiiuse.poll(wiimotes, nmotes)
            print r
            if r!=0:
                a=handle_event(wiimotes[0])
                print a 

    except KeyboardInterrupt:
        for i in range(nmotes):
            wiiuse.disconnect(wiimotes[i])
コード例 #5
0
def getData():
    getConnected()
    try:
        rum = 1
        while True:
            r = wiiuse.poll(wiimotes, nmotes)
            print r
            if r != 0:
                a = handle_event(wiimotes[0])
                print a

    except KeyboardInterrupt:
        for i in range(nmotes):
            wiiuse.disconnect(wiimotes[i])
コード例 #6
0
ファイル: wiimidi.py プロジェクト: nathanstep55/wiimidi
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")
コード例 #7
0
 def disconnect(self):
     '''Disconnect this Wiimote'''
     WT.do(wiiuse.disconnect(self.wm))
コード例 #8
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
コード例 #9
0
ファイル: mainSys.py プロジェクト: leecarraher/wiichopper
        newcmdY = update(pidY, targetPositionY - positiony, positiony)
        if abs(newcmdY) < 10.0:
            print "Equilibrium Y"
        else:
            print "y:" + str(newcmdY) + ":" + str(command.throttle)
            command.throttle = command.throttle + newcmdY
            if command.throttle > 127: command.throttle = 127
            if command.throttle < 1: command.throttle = 1
            signal(command)

        time.sleep(.01)

        #drawing the interface thing (debug)
        canvas.delete(prevOval)
        AA = (positionx, 500 - positiony)
        #clock.config(text=str(positionx)+','+str(positiony))
        prevOval = canvas.create_oval(AA[0], AA[1], AA[0] + 2, AA[1] + 2)
        clock.after(10, tick)

    tick()
    root.mainloop()

except KeyboardInterrupt:
    for i in range(nmotes):
        #use as warnings, ie power is too low to hover/amount of power needed for equilibrium, a passive fuel meter
        #wiiuse.set_leds(wiimotes[i], 0)
        #wiiuse.rumble(wiimotes[i], 0)
        wiiuse.disconnect(wiimotes[i])

#positionz
コード例 #10
0
ファイル: mainSys.py プロジェクト: leecarraher/wiichopper
        else:
            print "y:"+str(newcmdY)+":"+str(command.throttle)
            command.throttle = command.throttle+newcmdY
            if command.throttle>127:command.throttle=127
            if command.throttle<1:command.throttle=1
            signal(command)

        time.sleep(.01)
        
        #drawing the interface thing (debug)
        canvas.delete(prevOval)
        AA = (positionx,500-positiony)
        #clock.config(text=str(positionx)+','+str(positiony))
        prevOval = canvas.create_oval(AA[0],AA[1],AA[0]+2,AA[1]+2)
        clock.after(10, tick)
    tick()
    root.mainloop( )
 

         
except KeyboardInterrupt:
    for i in range(nmotes):
        #use as warnings, ie power is too low to hover/amount of power needed for equilibrium, a passive fuel meter
        #wiiuse.set_leds(wiimotes[i], 0)
        #wiiuse.rumble(wiimotes[i], 0)
        wiiuse.disconnect(wiimotes[i])


    
#positionz
コード例 #11
0
ファイル: connect.py プロジェクト: LeviCRobinson/Wii-Blue
        elif button_pressed == wiiuse.button['A']:
            os.system('clear')
            writer_reader.print_gestures()
            main_prompt()

        elif button_pressed == wiiuse.button['+']:
            os.system('clear')
            print "Exiting!"
            time.sleep(2 * STANDARD_SLEEP_TIME)
            done = True

        elif button_pressed == wiiuse.button['Up']:
            os.system('clear')
            stat.reset_all_stats()
            stat.print_stats()
            gesture_creator.update_gestures()  # Update the gestures in memory
            gesture_matcher.update_known_gestures()  # Update the gestures in memory
            main_prompt()
        elif button_pressed == wiiuse.button['Down']:
            os.system('clear')
            stat.print_stats()
            main_prompt()

# Disconnect the wiimote and exit.
gesture_creator.update_gestures()
gesture_matcher.update_known_gestures()
stat.print_stats()
wiiuse.disconnect(first_wm)
sys.exit(1)
コード例 #12
0
ファイル: connect.py プロジェクト: LeviCRobinson/Wii-Blue
        elif button_pressed == wiiuse.button['A']:
            os.system('clear')
            writer_reader.print_gestures()
            main_prompt()

        elif button_pressed == wiiuse.button['+']:
            os.system('clear')
            print "Exiting!"
            time.sleep(2 * STANDARD_SLEEP_TIME)
            done = True

        elif button_pressed == wiiuse.button['Up']:
            os.system('clear')
            stat.reset_all_stats()
            stat.print_stats()
            gesture_creator.update_gestures()  # Update the gestures in memory
            gesture_matcher.update_known_gestures(
            )  # Update the gestures in memory
            main_prompt()
        elif button_pressed == wiiuse.button['Down']:
            os.system('clear')
            stat.print_stats()
            main_prompt()

# Disconnect the wiimote and exit.
gesture_creator.update_gestures()
gesture_matcher.update_known_gestures()
stat.print_stats()
wiiuse.disconnect(first_wm)
sys.exit(1)
コード例 #13
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])