Example #1
0
    def __init__(self):
        raw_input(
            "Press the 'sync' button on the back of your Wiimote Plus " +
            "or buttons (1) and (2) on your classic Wiimote.\n" +
            "Press <return> once the Wiimote's LEDs start blinking.")

        self.axis = None
        self.straightAngle = 500
        self.treshold = 50

        if len(sys.argv) == 1:
            addr, name = wiimote.find()[0]
        elif len(sys.argv) == 2:
            addr = sys.argv[1]
            name = None
        elif len(sys.argv) == 3:
            addr, name = sys.argv[1:3]
        print("Connecting to %s (%s)" % (name, addr))
        self.wm = wiimote.connect(addr, name)

        while True:
            if self.wm.buttons["Up"] or self.wm.buttons["Down"]:
                print "Use y-axis"
                self.axis = 1
            elif self.wm.buttons["Right"] or self.wm.buttons["Left"]:
                print "Use x-axis"
                self.axis = 0
            else:
                pass

            if self.axis is not None:
                self.checkAngle()

            time.sleep(0.05)
 def scan_for_wiimotes(self, event):
     self.ui.btn_scan_wiimotes.setText("Scanning...")
     self.ui.list_available_wiimotes.clear()
     results = wiimote.find()
     for mote in results:
         address, name = mote
         self.ui.list_available_wiimotes.addItem(address)
     if len(results) > 0:
         self.ui.list_available_wiimotes.setCurrentRow(0)
     self.ui.btn_scan_wiimotes.setText("Scan")
    def get_wiimote(self):
        if len(sys.argv) == 1:
            addr, name = wiimote.find()[0]
        elif len(sys.argv) == 2:
            addr = sys.argv[1]
            name = None
        elif len(sys.argv) == 3:
            addr, name = sys.argv[1:3]
        print("Connecting to %s (%s)" % (name, addr))

        self.wiimoteNode.text.setText(addr)
        self.wiimoteNode.connect_wiimote()
    def get_wiimote(self):
        if len(sys.argv) == 1:
            addr, name = wiimote.find()[0]
        elif len(sys.argv) == 2:
            addr = sys.argv[1]
            name = None
        elif len(sys.argv) == 3:
            addr, name = sys.argv[1:3]
        print("Connecting to %s (%s)" % (name, addr))

        self.wiimoteNode.text.setText(addr)
        self.wiimoteNode.connect_wiimote()
    def __discover__(self):
        try:
            pairs = wiimote.find()
            if (pairs):
                for addr, name in pairs:
                    if addr in self.connecteds:
                        # already connected
                        continue
                    self.__connect__(addr, name)

        except:
            pass
Example #6
0
def getWiimote():
    raw_input("Press the 'sync' button on the back of your Wiimote Plus " +
              "or buttons (1) and (2) on your classic Wiimote.\n" +
              "Press <return> once the Wiimote's LEDs start blinking.")
    if len(sys.argv) == 1:
        addr, name = wiimote.find()[0]
    elif len(sys.argv) == 2:
        addr = sys.argv[1]
        name = None
    elif len(sys.argv) == 3:
        addr, name = sys.argv[1:3]
    print("Connecting to %s (%s)" % (name, addr))
    return wiimote.connect(addr, name)
def getWiimote():
    raw_input(
        "Press the 'sync' button on the back of your Wiimote Plus " +
        "or buttons (1) and (2) on your classic Wiimote.\n" +
        "Press <return> once the Wiimote's LEDs start blinking.")
    if len(sys.argv) == 1:
        addr, name = wiimote.find()[0]
    elif len(sys.argv) == 2:
        addr = sys.argv[1]
        name = None
    elif len(sys.argv) == 3:
        addr, name = sys.argv[1:3]
    print("Connecting to %s (%s)" % (name, addr))
    return wiimote.connect(addr, name)
def init_wiimote():
    """
    Tries to connect to a wiimote with the Mac-Addresss given via command line parameter
    :return: The successfully connected wiimote object
    """
    input("Press the 'sync' button on the back of your Wiimote Plus " +
          "or buttons (1) and (2) on your classic Wiimote.\n" +
          "Press <return> once the Wiimote's LEDs start blinking.")

    if len(sys.argv) == 1:
        addr, name = wiimote.find()[0]
    elif len(sys.argv) == 2:
        addr = sys.argv[1]
        name = None
    elif len(sys.argv) == 3:
        addr, name = sys.argv[1:3]
    print(("Connecting to %s (%s)" % (name, addr)))
    wm = wiimote.connect(addr, name)
    return wm
Example #9
0
import wiimote
import time
import sys
"""
A simple demo script for the wiimote.py module.
Start as `python3 wiimote_demo.py [bluetooth address of Wiimote]` and follow
instructions.
"""

input("Press the 'sync' button on the back of your Wiimote Plus " +
      "or buttons (1) and (2) on your classic Wiimote.\n" +
      "Press <return> once the Wiimote's LEDs start blinking.")

if len(sys.argv) == 1:
    addr, name = wiimote.find()[0]
elif len(sys.argv) == 2:
    addr = sys.argv[1]
    name = None
elif len(sys.argv) == 3:
    addr, name = sys.argv[1:3]
print(("Connecting to %s (%s)" % (name, addr)))
wm = wiimote.connect(addr, name)

# Demo Time!
patterns = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1],
            [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]
for i in range(5):
    for p in patterns:
        wm.leds = p
        time.sleep(0.05)
Example #10
0
#!/usr/bin/env python3

import wiimote
import time
import sys

input("Press the 'sync' button on the back of your Wiimote Plus " +
          "or buttons (1) and (2) on your classic Wiimote.\n" +
          "Press <return> once the Wiimote's LEDs start blinking.")

if len(sys.argv) == 1:
    addr, name = wiimote.find()[0]
elif len(sys.argv) == 2:
    addr = sys.argv[1]
    name = None
elif len(sys.argv) == 3:
    addr, name = sys.argv[1:3]
print(("Connecting to %s (%s)" % (name, addr)))
wm = wiimote.connect(addr, name)

# Demo Time!
patterns = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[0,0,1,0],[0,1,0,0],[1,0,0,0]]
for i in range(5):
    for p in patterns:
        wm.leds = p
        time.sleep(0.05)


def print_ir(ir_data):
    if len(ir_data) == 0:
        return