// We made this script to play ORF SkiChallenge (skichallenge.orf.at) with the BalanceBoard // This script was done by Patrick Hübner and Andreas Böhler at the Upper Austria University // for Applied Sciences // It can be used to control whatever requires the cursor keys to be pressed. // // I'm not totally sure whether we got the calibration right, in our case two sensors were swapped. // Please test and report! // It is very likely, that something is swapped up or doesn't work as expected. We are in no way // responsible for any harm our script might do to you or your neighbour, etc. // // // Usage: // // Fire up GlovePie and connect your board. Run the script, the LED should become blue immediately. // For calibration, DON'T step on your BalanceBoard and press the button on the balance board once. // There are now two ways to determine the sensor's regions: // a) The old way: // Step on the back left corner and press '1'. // Next, step on the back right corner and press '2'. // Press '3' while stepping on the front right corner. // And finish with pressing '4' while steppin on the front left corner. // b) The new approach: // Instead of having to calibrate each sensor separately, just step onto the board and center // your weight as much as possible. Then let someone press the BalanceBoard's button for you // and calibration is complete! // Now calibration is complete. Enjoy. // ChangeLog: // v0.3, 2009/03/13 // New calibration routine; It may or may not be better! // // v0.2, 2009/03/13 // fixed calibration issues // added "touch-response" // // v0.1, 2008/12/11 // first public release with complete calibration Wiimote.BalanceBoard.LED = true var.thres_lr1 = 4e-1 var.thres_lr2 = 3e-1 var.thres_bf = 2e-1 var.tmp = 1 if wiimote.BalanceBoard.Button = true then var.check = true endif if key.1 then var.fullBL = (wiimote.BalanceBoard.BackLeft - var.cBL)*8e-1 endif if key.2 then var.fullBR = (wiimote.BalanceBoard.FrontLeft - var.cBR)*8e-1 endif if key.3 then var.fullFR = (wiimote.BalanceBoard.FrontRight - var.cFR)*8e-1 endif if key.4 then var.fullFL = (wiimote.BalanceBoard.BackRight - var.cFL)*8e-1 endif //debug = var.fullBR var.fBL = wiimote.BalanceBoard.BackLeft var.fBR = wiimote.BalanceBoard.FrontLeft var.fFL = wiimote.BalanceBoard.BackRight var.fFR = wiimote.BalanceBoard.FrontRight // debug = "BL: " + wiimote.BalanceBoard.BackLeft + "BR: " + wiimote.BalanceBoard.FrontLeft + "FL: " + wiimote.BalanceBoard.BackRight + "FR : " + wiimote.BalanceBoard.FrontRight if var.check = true then if var.zero = true then //debug = "Calibrate Full" var.fullFL = (wiimote.BalanceBoard.BackRight - var.cFL)//*15e-1 var.fullFR = (wiimote.BalanceBoard.FrontRight - var.cFR)//*15e-1 var.fullBR = (wiimote.BalanceBoard.FrontLeft - var.cBR)//*15e-1 var.fullBL = (wiimote.BalanceBoard.BackLeft - var.cBL)//*15e-1 var.check = false else //debug = "Calibrate Zero" var.cBL = wiimote.BalanceBoard.BackLeft var.cBR = wiimote.BalanceBoard.FrontLeft var.cFL = wiimote.BalanceBoard.Backright var.cFR = wiimote.BalanceBoard.FrontRight wait(1000ms) var.check = false var.zero = true endif endif var.tBL = abs((var.fBL - var.cBL)/var.fullBL) var.tBR = abs((var.fBR - var.cBR)/var.fullBR) var.tFL = abs((var.fFL - var.cFL)/var.fullFL) var.tFR = abs((var.fFR - var.cFR)/var.fullFR) // This is the Left-Right Code // If the pressure is betwen the two thresholds, wait between key presses, // otherwise continuously press the buttons! if ((var.tBL > var.tBR+var.thres_lr2) && (var.tBL <= var.tBR+var.thres_lr1)) || ((var.tFL > var.tFR+var.thres_lr2) && (var.tFL <= var.tFR+var.thres_lr1)) then key.Left = true key.Right = false wait(10ms) key.Left = false wait(10ms) elseif ((var.tBR > var.tBL+var.thres_lr2) && (var.tBR <= var.tBL+var.thres_lr1)) || ((var.tFR > var.tFL+var.thres_lr2) && (var.tFR <= var.tFL+var.thres_lr1)) then key.Right = true key.Left = false wait(10ms) key.Right = false wait(10ms) elseif (var.tBL > var.tBR+var.thres_lr1) || (var.tFL > var.tFR+var.thres_lr1) then key.Left = true key.Right = false elseif (var.tBR > var.tBL+var.thres_lr1) || (var.tFR > var.tFL+var.thres_lr1) then key.Right = true key.Left = false endif // This is the Back-Front Code if (var.tBL > var.tFL+var.thres_bf) || (var.tBR > var.tFR+var.thres_bf) then key.Down = true key.Up = false elseif (var.tFL > var.tBL+var.thres_bf) || (var.tFR > var.tBR+var.thres_bf) then key.Up = true key.Down = false else key.Up = false key.Down = false endif