Wiimote Roll Help

Official forum for open source FreePIE discussion and development.
Post Reply
MeteorFalling2
One Eyed Hopeful
Posts: 42
Joined: Thu Dec 08, 2016 10:23 pm

Wiimote Roll Help

Post by MeteorFalling2 »

Hello,

I have been trying write a script that causes my wiimote to press a button if I roll it. But, The problem that I am facing is, if there is too much movement, the negative rotation values(left) and positive rotation values(right) become easily confused and display incorrect values at any 'real' rotation. This causes positive numbers to display when rotating left, or negative numbers when rotation right.

I have been trying to look at filters to see if I can get correct readings, but it seems like I cannot progress in this aspect. The script acts as though it is not polling the rotational values fast enough, causing the previous values to influence new values.

is there a way I can get the rotational values to always be correct? I am transitioning from glovepie, and it was able to apply rotational values quite consistently.

the Freepie code that I use is:

Code: Select all

def update():
	diagnostics.watch(wiimote[0].ahrs.roll)
	
	if filters.stopWatch((wiimote[0].ahrs.roll < -60), 200): ## if rotated left for 200ms, press Z.
		keyboard.setKeyDown(Key.Z)
		keyboard.setKeyUp(Key.Z)
	
if starting:
	system.threadExecutionInterval = 2
	wiimote[0].motionplus.update += update
	wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
	 
The code I am trying to mimic from Glovepie:

Code: Select all

   if HeldDown((wiimote.roll < -60), 200ms) {
        press(keyboard.z)
        wait 10ms
        release(keyboard.z)
    }
Post Reply

Return to “FreePIE”