dyadica.net

Fun and Games in the Dyadic Sea

Adding UK Stones measure to WiimoteLib 1.5.2

permalink image comments image
Monday, 16 June '08 :
this post has been permanently archived at http://blog.dyadica.net/pages/wii/balance-board/adding-uk-stones-measure-to-wiimotelib-1.5.2

Open up Datatypes.cs and add the following definitions to the public struct BalanceBoardState:

/// <summary>
/// Stones per sensor
/// </summary>
public BalanceBoardSensorsF SensorValuesSt;

and

/// <summary>
/// Total stones on the Balance Board
/// </summary>
public float WeightSt;

Next open up Wiimote.cs and add the following variable above the default constructor just below the Kg – Lb vars:

// kilograms to stones
private const float KG2ST = 6.35029318f;

Next we are going to add the code that populates these definitions/variables

Still within Wiimote.cs add the following code to the BalanceBoard case of the ParseExtension function just below the Kg – Lb equivalent code:

mWiimoteState.BalanceBoardState.SensorValuesSt.TopLeft = (mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft / KG2ST);
mWiimoteState.BalanceBoardState.SensorValuesSt.TopRight = (mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight / KG2ST);
mWiimoteState.BalanceBoardState.SensorValuesSt.BottomLeft = (mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft / KG2ST);
mWiimoteState.BalanceBoardState.SensorValuesSt.BottomRight = (mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight / KG2ST);

The above block of code enables calls to be made to obtain values for each of the four sensors in exactly the same way as you would for Kg’s and Lb’s e.g.

TopLeftInStones = ws.BalanceBoardState.SensorValuesSt.TopLeft;

Finally for total weight in stones add the following line below the equivalent Kg / Lb definitions:

mWiimoteState.BalanceBoardState.WeightSt = (mWiimoteState.BalanceBoardState.SensorValuesSt.TopLeft + mWiimoteState.BalanceBoardState.SensorValuesSt.TopRight + mWiimoteState.BalanceBoardState.SensorValuesSt.BottomLeft + mWiimoteState.BalanceBoardState.SensorValuesSt.BottomRight) / 4.0f;

And there you have it your balance board will now cater for the UK Stones measure and calls can be made using equivalent code to that provided for Kg’s and Lb’s.

Tags: , , , , ,

page meta

get trackback image get trackback image
details
  • Posted: Monday, 16 June '08
  • Edited: Thursday, 29 January '09
  • Category: C#, Wii, technology
  • Author: admin

say what do you think

RSS feed | Trackback URI

css | xhtml | dyadica.net © admin 2010 | powered: wordpress | fuel: ps-wii-elite | top | sign-up