Status update. I’m not a fan of the shotgun approach that is modern software engineering, but this is my attempt to conform. I have not gotten it to run yet and there are many many parts I don’t fully understand, but have in place simply copying other functions that do work. Thoughts?
setting in settings/settings.py
{
"type": "bool",
"title": "wiimote Pendant installed",
"desc": "Does the machine have a bluetooth wii remote pendant?",
"key": "wiiPendantPresent",
"default": 0,
},
Flag in DataStructures/data.py (just below manual ZAxisAdjust):
wiiPendantPresent = False
Pointer to the wiiPendant object in DataStructures/data.py (just below boardManager):
wiiPendant = None
import in nonVisibleWidgets.py:
from wiiPendant import WiiPendant
added object instance in NonVisibleWidgets class:
wiiPendant = WiiPendant()
added setupData lines also in nonVisibleWidgets:
data.wiiPendant = self.wiiPendant
.
.
.
self.wiiPendant.setUpData(data)
self.wiiPendant.setup()
wiiPendant.py file has 2 variables:
wiiPendantRequest = “”
wm = None #controller object
wiiPendant.py file has the following open connection routine:
Code:
def openConnection(self):
‘’’
if the wiiPendantFlag in the config is True, then check if the wiiPendant is already connected
if not connected, then set t
‘’’
if self.data.wiiPendantPresent:
if not self.data.wiiPendantConnected:
if self.wm == None:
while not self.wm:
try:
self.wm=cwiid.Wiimote()
self.wm.rumble=True
time.sleep(.3)
self.wm.rumble = False
time.sleep(0.2)
self.wm.rumble=True
time.sleep(.3)
self.wm.rumble = False
x = wiiPendantThread()
x.data = self.data
self.th = threading.Thread(target=x.readbuttons)
self.th.daemon = True
self.th.start()
except RuntimeError:
‘’’
this is a silent fail if the wiimote is not there… should set something to know that it isn’t th$
‘’’
else:
self.data.ui_queue1.put(“Action”, “connectionStatus”,{‘status’: ‘True’})
I don’t know if the init routine of the self.wm=cwiid.Wiimote() line is blocking and I’m wondering if a button should be put in for turning on the pairing rather than having it scheduled for every 5 seconds similar to the serial port. If it fails silently, probably no big deal… if it blocks every 5 seconds, HUGE problem.