Maslow Home Maslow Community Garden Newsletter

Webcontrol pendant software -tie- in - > entry point for external data in the code?

I have a wiimote and a raspberry pi. The raspberry pi is now programmatically taking button inputs in python from the wiimote via the bluetooth that is included on the raspberry pi 3.

The question:

What might be the best approach to integrate this in webcontrol… start a thread that runs the listener code and then insert a message in the queue? A new button or a macro button could be assigned to activate the bluetooth and search for the controller. You then push the buttons on the controller and it will connect to the pi - i have it rumble when it is connected. I haven’t gotten the light totally figured out or the buttons completely sorted, but it will get there.

1 Like

I think a thread that processes the inputs from the controller seems reasonable. Once the input is received, I’d just call with a suitably formatted json. The thread should be created in nonvisiblewidgets so it has access to the “data” class. Make sure to sleep the thread so it isn’t blocking.


I’ll see what I can do. I’m using a second pi to test this with the pyinstaller version of webcontrol. Once I think I have it working, who else would be willing to test it?

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/

       "type": "bool",
        "title": "wiimote Pendant installed",
        "desc": "Does the machine have a bluetooth wii remote pendant?",
        "key": "wiiPendantPresent",
        "default": 0,

Flag in DataStructures/ (just below manual ZAxisAdjust):

wiiPendantPresent = False

Pointer to the wiiPendant object in DataStructures/ (just below boardManager):

wiiPendant = None

import in

from wiiPendant import WiiPendant

added object instance in NonVisibleWidgets class:

wiiPendant = WiiPendant()

added setupData lines also in nonVisibleWidgets:

data.wiiPendant = self.wiiPendant
self.wiiPendant.setup() file has 2 variables:

wiiPendantRequest = “”
wm = None #controller object file has the following open connection routine:


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 not
if self.wm == None:
while not self.wm:
self.wm.rumble = False
self.wm.rumble = False
x = wiiPendantThread() = = threading.Thread(target=x.readbuttons) = True
except RuntimeError:
this is a silent fail if the wiimote is not there… should set something to know that it isn’t th$
else:“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.

It’s hard for me to tell… do you use github? If you forked my repo and made the changes to it, I could readily view it and see what’s going on.

Forked and added. It is the wiiPendant fork. Development version not yet running correctly on the raspberry pi, so I don’t know if the wiiPendantThread is set up correctly yet.