<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dyadica.net</title>
	<atom:link href="http://blog.dyadica.net/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.dyadica.net</link>
	<description>Fun and Games in the Dyadic Sea</description>
	<lastBuildDate>Wed, 21 Jul 2010 14:04:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Where have you been since August</title>
		<link>http://blog.dyadica.net/archives/where-have-you-been-since-august</link>
		<comments>http://blog.dyadica.net/archives/where-have-you-been-since-august#comments</comments>
		<pubDate>Sun, 21 Feb 2010 01:30:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PhD]]></category>
		<category><![CDATA[Time]]></category>
		<category><![CDATA[Where are you?]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2469</guid>
		<description><![CDATA[I am still here however my PhD is taking up most of my time so I haven&#8217;t had much time to post much. However it will all be over soon   and things will get ...]]></description>
			<content:encoded><![CDATA[<p><span>I am still here however my PhD is taking up most of my time so I haven&#8217;t had much time to post much. However it will all be over soon <img src='http://blog.dyadica.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  and things will get back to normal. </span></p>
<p><span>Some major <span>Wii</span> updates on the way as I <span>write </span>them up for my thesis, I promise. For more up to date info check out my work site.</span></p>
<p><span><strong>Update</strong></span></p>
<p><span>If you are looking for Wii related info check out <a title="The Wii Controller Interface Suite" href="http://wiici.dyadica.net/journal">http://wiici.dyadica.net/journal</a>. The site is still in development but its where I have been publishing of late. </span></p>
<p><span>This site is to become primarily a personal blog with non a Wii related focus etc. So please update your links accordingly.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/where-have-you-been-since-august/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A view on the iPad from the Bunker</title>
		<link>http://blog.dyadica.net/archives/a-view-on-the-ipad-from-the-bunker</link>
		<comments>http://blog.dyadica.net/archives/a-view-on-the-ipad-from-the-bunker#comments</comments>
		<pubDate>Fri, 29 Jan 2010 15:05:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[Archos 9]]></category>
		<category><![CDATA[Funny]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[Microsoft Courier]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2467</guid>
		<description><![CDATA[Nick has just sent me this video and now my side hurt: A view on the iPad from the Bunker!]]></description>
			<content:encoded><![CDATA[<p>For those of you who dont know I like dem Apples, after all I have a MacBook Pro, iMac and even a Mac Pro at work, however I dont have an iPhone for me its got to be a nokia anyhooo Nick has just sent me this video and now my side hurt:</p>
<p><span class="onevid_big"><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/lQnT0zp8Ya4&#038;hl=en_GB&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/lQnT0zp8Ya4&#038;hl=en_GB&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></span></p>
<p>Its scary when you think like an evil dictator, roll on <a title="Microsofts Courier - Gizmodo" href="http://gizmodo.com/5365299/courier-first-details-of-microsofts-secret-tablet" target="_blank">courier</a> and for those who cant wait, theres always the <a title="The Archos 9 tablet" href="http://www.archos.com/products/nb/archos_9/index.html?country=gb&amp;lang=en" target="_blank">archos 9</a>. You cant help be left with the thought that they just had to be 2nd!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/a-view-on-the-ipad-from-the-bunker/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sheriff Fatman @ the Moon and Sixpence</title>
		<link>http://blog.dyadica.net/archives/sheriff-fatman-the-moon-and-sixpence</link>
		<comments>http://blog.dyadica.net/archives/sheriff-fatman-the-moon-and-sixpence#comments</comments>
		<pubDate>Sun, 02 Aug 2009 21:32:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Gig]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[Punk]]></category>
		<category><![CDATA[sheriff fatMan]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2410</guid>
		<description><![CDATA[Sheriff Fatman played at the Moon and Sixpence last night and as always a good time was had by all. 
In a contrast to the usual performance Dom took up the singing mantle to add ...]]></description>
			<content:encoded><![CDATA[<p>Sheriff Fatman played at the Moon and Sixpence last night and as always a good time was had by all. </p>
<p>In a contrast to the usual performance Dom took up the singing mantle to add a new flavor to the proceedings.</p>
<p>Check out the video:<br />
<span class="twovid_left"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/i2A7iq4SyII&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/i2A7iq4SyII&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></span><span class="twovid_right"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/TDJfRR7--GI&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/TDJfRR7--GI&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></span></p>
<p>For more videos of the gig visit my <a title="dyadica youtube" href="http://www.youtube.com/user/dyadica?feature=moby#play/user/A116C5E3523F5DC1">youTube</a> channel. For more info on the band visit <a title="Sheriff Fatman" href="http://www.sheriff-fatman.co.uk/">www.sheriff-fatman.co.uk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/sheriff-fatman-the-moon-and-sixpence/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding The Step Event</title>
		<link>http://blog.dyadica.net/archives/adding-the-step-event</link>
		<comments>http://blog.dyadica.net/archives/adding-the-step-event#comments</comments>
		<pubDate>Fri, 31 Jul 2009 22:26:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Balance Board]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Wii]]></category>
		<category><![CDATA[Balance]]></category>
		<category><![CDATA[balance board]]></category>
		<category><![CDATA[Quadrant]]></category>
		<category><![CDATA[Quadzone]]></category>
		<category><![CDATA[Stepping]]></category>
		<category><![CDATA[WiiFit]]></category>
		<category><![CDATA[wiimote]]></category>
		<category><![CDATA[wiimoteLib]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2337</guid>
		<description><![CDATA[In this Instruction we are going to modify WiimoteLib by including a new event trigger that is activated upon a change in either Quad or Zone value.
This is a very useful addition that allows for ...]]></description>
			<content:encoded><![CDATA[<p>In this Instruction we are going to modify WiimoteLib by including a new event trigger that is activated upon a change in either Quad or Zone value.</p>
<p>This is a very useful addition that allows for &#8220;singular&#8221; triggering so that you don&#8217;t have to rely on &#8220;flag checks&#8221; within the standard WiimoteState loop and thus allowing the Libary to do all the work!</p>
<p>Before we start, this instruction assumes you have previously completed the <a title="Areas Quad and Zone" href="http://blog.dyadica.net/pages/balance-board/areas-quad-and-zone">Areas Quad and Zone</a> Instruction.</p>
<p>Start off by opening up the Events.cs file and add the following code below the public class WiimoteChangedEventArgs:<span id="more-2337"></span></p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Argument sent through the BalanceBoardStepEvent<br />
/// &lt;/summary&gt;<br />
public class BalanceBoardStepEventArgs : EventArgs<br />
{<br />
/// &lt;summary&gt;<br />
/// The current state of the Balance Board<br />
/// &lt;/summary&gt;<br />
public BalanceBoardState BalanceBoard;</p>
<p>/// &lt;summary&gt;<br />
/// The Type of trigger that activated the event<br />
/// &lt;/summary&gt;<br />
public StepType StepType;</p>
<p>/// &lt;summary&gt;<br />
/// Constructor<br />
/// &lt;/summary&gt;<br />
/// &lt;param name=&#8221;bb&#8221;&gt;Wiimote Balance Board State&lt;/param&gt;<br />
/// &lt;param name=&#8221;type&#8221;&gt;Step trigger type: Standard/Damped Quad/Zone&lt;/param&gt;<br />
public BalanceBoardStepEventArgs(BalanceBoardState bb, StepType type)<br />
{<br />
BalanceBoard = bb;<br />
StepType = type;<br />
}<br />
}</p></blockquote>
<p>What we have done here is create a new class that provides access to two arguments:</p>
<ol>
<li>BalanceBoardState</li>
<li>StepType</li>
</ol>
<p>By passing BalanceBoardState we are provided direct access to all the relevant Balance Board calls that we would normally have via WiimoteState. The StepType argument provides us with a reference to the trigger that we can then use to filter/output a desired response etc.</p>
<p>To define StepType open up DataTypes.cs and add the following enum block below the BalanceBoardState struct:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// The type of Step Triggered<br />
/// &lt;/summary&gt;<br />
[DataContract]<br />
public enum StepType<br />
{<br />
/// &lt;summary&gt;<br />
/// Zone Change<br />
/// &lt;/summary&gt;<br />
Zone = 0,<br />
/// &lt;summary&gt;<br />
/// Quad Change<br />
/// &lt;/summary&gt;<br />
Quad = 1,<br />
};</p></blockquote>
<p>Next we need to add this enum to the BalanceBoardState struct itself. We do this as follows:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// The Action which has Triggered the Step Event<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public StepType StepType;</p></blockquote>
<p>With this done we now have all the foundations needed for the &#8220;Event&#8221;, now we need to add it! Open up Wiimote.cs and add the following block at the top just below the equivalent WiimoteChanged and WiimoteExtensionChanged handles.</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Event raised when a Balance Board Step is Triggered<br />
/// &lt;/summary&gt;<br />
public event EventHandler&lt;BalanceBoardStepEventArgs&gt; BalanceBoardStep;</p></blockquote>
<p>This defines our brand new BalanceBoardStep handle. With this in place we now need to be able to trigger it.  As we are going to use either a change in Zone or Quad location to trigger the call.</p>
<p>Update the Area struct (DataTypes.cs) to include two additional definitions as shown below:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Last Balance Board Zone Area<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public string LastZone;</p>
<p>/// &lt;summary&gt;<br />
/// Last Balance Board Quad Area<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public string LastQuad;</p></blockquote>
<p>These 2 new definitions simply provide us with a location to archive the states of both Zone and Quad. I chose to add them like this as there is likely to be other occasions when access to this information would provide useful! Also facility is provided for standard WiimoteState access (just in case).</p>
<p>With this complete we now need to add the code to facilitate the trigger. Still within Wiimote.cs add the following two blocks just below the Area.Quad and Area.Zone updates within ParseExtension:</p>
<blockquote><p>#region step filtering quad</p>
<p>// calculate if there is a Quad Step<br />
if (mWiimoteState.BalanceBoardState.Area.CurrentQuad != mWiimoteState.BalanceBoardState.Area.LastQuad)<br />
{<br />
// update the archived Quad<br />
mWiimoteState.BalanceBoardState.Area.LastQuad = mWiimoteState.BalanceBoardState.Area.CurrentQuad;<br />
// post a Standard Step event<br />
if (BalanceBoardStep != null)<br />
{ BalanceBoardStep(this, new BalanceBoardStepEventArgs(mWiimoteState.BalanceBoardState, StepType.Quad)); }<br />
}</p>
<p>#endregion step filtering quad</p>
<p>#region step filtering zone</p>
<p>// calculate if there is a Zone Step<br />
if (mWiimoteState.BalanceBoardState.Area.CurrentZone != mWiimoteState.BalanceBoardState.Area.LastZone)<br />
{<br />
// update the archived Zone<br />
mWiimoteState.BalanceBoardState.Area.LastZone = mWiimoteState.BalanceBoardState.Area.CurrentZone;<br />
// post a Standard Step event<br />
if (BalanceBoardStep != null)<br />
{ BalanceBoardStep(this, new BalanceBoardStepEventArgs(mWiimoteState.BalanceBoardState, StepType.Zone)); }<br />
}</p>
<p>#endregion step filtering zone</p></blockquote>
<p>All we are doing here is comparing states. If there is a change we then call the Event and also update the archived state for the next comparison.</p>
<p>With this done our new BalanceBoardStep Event is now complete.. well nearly!</p>
<p>So how do we use it? The easy answer is in exactly the same way you would both the UpdateWiimoteChanged and UpdateExtensionChanged Events provided in the Wiimote Test Example that comes with WiimoteLib.</p>
<p>First within WiimoteInfo.cs create a new delegate referance below the 2 existing ones for Wiimote State/Extension:</p>
<blockquote><p>private delegate void UpdateBalanceBoardStepDelegate(BalanceBoardStepEventArgs args);</p></blockquote>
<p>Next we need to add a function to invoke the delegate, this allows for cross thread calls and is triggered a call from the main application</p>
<blockquote><p>public void UpdateStep(BalanceBoardStepEventArgs args)<br />
{<br />
BeginInvoke(new UpdateBalanceBoardStepDelegate(UpdateBalanceBoardStep), args);<br />
}</p></blockquote>
<p>Finally we add our work function. This function receives the Event and then uses the arguments provided to detirmine the required action  to take in an equivalent manner of  the existing Wiimote State/Extension functions.</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Board Step example to show triggering of action via one of the two current step filters<br />
/// Quad &#8211; Triggered via a change in Quad Area<br />
/// Zone &#8211; Triggered via a change in Zone Area<br />
/// &lt;/summary&gt;<br />
private void UpdateBalanceBoardStep(BalanceBoardStepEventArgs args)<br />
{<br />
BalanceBoardState bb = args.BalanceBoard;</p>
<p>switch (args.StepType)<br />
{<br />
case StepType.Quad:<br />
// Quadrant output usefull for WiiFit Step game equivalents<br />
lblQuad.Text = bb.Area.CurrentQuad;<br />
Console.WriteLine(&#8220;Call from quad step&#8221;);<br />
break;<br />
case StepType.Zone:<br />
// Quadzone output usefull for WiiFit Step game equivalents<br />
lblZone.Text = bb.Area.CurrentZone;<br />
Console.WriteLine(&#8220;Call from zone step&#8221;);<br />
break;<br />
}<br />
}</p></blockquote>
<p>We now have everything in place but before we can use the new Event we need to register it with the Wiimote etc as you would with the existing ones.</p>
<p>In your connection call add (MultipleWiimoteForm.cs/SingleWiimoteForm.cs) the following below the WiimoteChanged and WiimoteExtensionChanged register calls:</p>
<blockquote><p>wm.BalanceBoardStep += wm_BalanceBoardStep;</p></blockquote>
<p>Finally also add the corresponding function which is used to call the update within the WiimoteInfo.cs just below the equivalent State/Extension ones:</p>
<blockquote><p>void wm_BalanceBoardStep(object sender, BalanceBoardStepEventArgs e)<br />
{<br />
WiimoteInfo wi = mWiimoteMap[((Wiimote)sender).ID];<br />
wi.UpdateStep(e);<br />
}</p></blockquote>
<p>That&#8217;s it debug the program and enjoy&#8230;!</p>
<p><strong>Update: Step ON and Step OFF</strong><br />
<a id="update" class="update"></a></p>
<p>Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are &#8220;ON/OFF&#8221; the Board.</p>
<p>To do this we are going to add a check for a defined &#8220;Minimum Weight&#8221;. If the WeightKg is greater than the Minimum Weight then we are classed as being &#8220;On&#8221; the board. Simple eh! Start off by adding a the following new definitions to the BalanceBoardState struct:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Are we on the Balance Board<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public bool OnBoard;</p>
<p>/// &lt;summary&gt;<br />
/// Balance Board Minimum Weight Tolerance<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public double Tolerance;</p></blockquote>
<p>Before we can use these new definitions we need to initialize them by assigning some default values. At the top of Wiimote.cs just above the Default constructor add the following :</p>
<blockquote><p>// Temporary Defaults<br />
private double Tolerance = 6;</p></blockquote>
<p>This enables access to the default value for customization at start up. This value can then be updated at run time, why? I have currently access to 2 boards. At rest one reads 2kg and the other 5kg, go figure!</p>
<p>Add the following to the SetBalanceBoardDefaults() function to set the default values.</p>
<blockquote><p>// set the default min weight used to trigger board use etc<br />
mWiimoteState.BalanceBoardState.Tolerance = Tolerance;<br />
mWiimoteState.BalanceBoardState.OnBoard = false;</p></blockquote>
<p>Please note I always assume the user not to be on the Board at startup. With these definitions in place we can now use them to check for both the stepping On and Off events but before we do that we need to add them to the StepType enum within DataTypes.cs as follows:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Step On<br />
/// &lt;/summary&gt;<br />
On = 2,<br />
/// &lt;summary&gt;<br />
/// Step Off<br />
/// &lt;/summary&gt;<br />
Off = 3,</p></blockquote>
<p>Ok, now everything is in place lets use it. The next step is to enclose the existing Quad Zone and Step code in an IF statement that polls the weight against the tolerance. Here is our statement without the contents:</p>
<blockquote><p>if (mWiimoteState.BalanceBoardState.WeightKg &gt; mWiimoteState.BalanceBoardState.Tolerance)<br />
{<br />
// step ON event check  &#8211; (we will cover this next)<br />
// calculate and set values for Quad<br />
// calculate and set values for Zone<br />
// step filtering Quad<br />
// step filtering Zone<br />
}<br />
else<br />
{<br />
// step OFF event check &#8211; (we will cover this next)<br />
}</p></blockquote>
<p>Please update your Wiimote.cs to reflect the above. Once complete the next step is to add Triggers for both the OFF and On events. These event call are similar to those of Quad and Zone. Replace the //step On event check comment with the following block:</p>
<blockquote><p>#region On Board Step Event Check</p>
<p>if (!mWiimoteState.BalanceBoardState.OnBoard)<br />
{<br />
mWiimoteState.BalanceBoardState.OnBoard = true;<br />
if (BalanceBoardStep != null)<br />
{ BalanceBoardStep(this, new BalanceBoardStepEventArgs(mWiimoteState.BalanceBoardState, StepType.On)); }<br />
}</p>
<p>#endregion On Board Step Event Check</p></blockquote>
<p>Next replace the // step OFF event check comment with:</p>
<blockquote><p>#region Off Board Step Event Check</p>
<p>if (mWiimoteState.BalanceBoardState.OnBoard)<br />
{<br />
mWiimoteState.BalanceBoardState.OnBoard = false;<br />
if (BalanceBoardStep != null)<br />
{ BalanceBoardStep(this, new BalanceBoardStepEventArgs(mWiimoteState.BalanceBoardState, StepType.Off)); }<br />
}</p>
<p>#endregion Off Board Step Event Check</p></blockquote>
<p>Finally all we need to do is update the UpdateBalanceBoardStep function within WiimoteInfo.cs by adding the following cases to the switch statement:</p>
<blockquote><p>case StepType.On:<br />
// Your Code<br />
break;<br />
case StepType.Off:<br />
// Your Code<br />
break;</p></blockquote>
<p>There you have it! additional facility for logging when a user gets ON/OFF the balance board.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 3051px; width: 1px; height: 1px;">
<p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">To do this we are going to add a check for a defined &#8220;Minimum Weight&#8221;. If the WeightKg is greater than the Minimum Weight then we are classed as being &#8220;On&#8221; the board. Simple eh! Start off by adding a the following new definitions to the BalanceBoardState struct:</a></p>
<blockquote><p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">/// &lt;summary&gt;<br />
/// Are we on the Balance Board<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public bool OnBoard;</a></p>
<p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">/// &lt;summary&gt;<br />
/// Balance Board Minimum Weight Tolerance<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public double Tolerance;</a></p></blockquote>
<p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">Before we can use these new definitions we need to initialize them by assigning some default values. At the top of Wiimote.cs just above the Default constructor add the following :</a></p>
<blockquote><p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">// Temporary Defaults<br />
private double Tolerance = 6;</a></p></blockquote>
<p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">This enables access to the default value for customization at start up. This value can then be updated at run time, why? I have currently access to 2 boards. At rest one reads 2kg and the other 5kg, go figure!</a></p>
<p><a id="update" class="update &gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok we could stop here but lets expand things a little bit more by adding to the step Event facility a check too see weather we are">Add the following to the </a><a title="SetBalanceBoardDefaults Function" href="http://blog.dyadica.net/pages/balance-board/grouping-the-cog-systems#update">SetBalanceBoardDefaults()</a> function to set the default values.</p>
<p>// set the default min weight used to trigger board use etc<br />
mWiimoteState.BalanceBoardState.Tolerance = Tolerance;<br />
mWiimoteState.BalanceBoardState.OnBoard = false;</p>
<p>Please note I always assume the user not to be on the Board at startup. With these definitions in place we can now use them to check for both the stepping On and Off events but before we do that we need to add them to the StepType enum within DataTypes.cs as follows:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Step On<br />
/// &lt;/summary&gt;<br />
On = 2,<br />
/// &lt;summary&gt;<br />
/// Step Off<br />
/// &lt;/summary&gt;<br />
Off = 3,</p></blockquote>
<p>Ok, now everything is in place lets use it. The next step is to enclose the existing Quad Zone and Step code in an IF statement that polls the weight against the tolerance. Here is our statement without the contents:</p>
<blockquote><p>if (mWiimoteState.BalanceBoardState.WeightKg &gt; mWiimoteState.BalanceBoardState.Tolerance)<br />
{<br />
// step ON event check  &#8211; (we will cover this next)<br />
// calculate and set values for Quad<br />
// calculate and set values for Zone<br />
// step filtering Quad<br />
// step filtering Zone<br />
}<br />
else<br />
{<br />
// step OFF event check &#8211; (we will cover this next)<br />
}</p></blockquote>
<p>Please update your Wiimote.cs to reflect the above. Once complete the next step is to add Triggers for both the OFF and On events. These event call are similar to those of Quad and Zone. Replace the //step On event check comment with the following block:</p>
<blockquote><p>#region On Board Step Event Check</p>
<p>if (!mWiimoteState.BalanceBoardState.OnBoard)<br />
{<br />
mWiimoteState.BalanceBoardState.OnBoard = true;<br />
if (BalanceBoardStep != null)<br />
{ BalanceBoardStep(this, new BalanceBoardStepEventArgs(mWiimoteState.BalanceBoardState, StepType.On)); }<br />
}</p>
<p>#endregion On Board Step Event Check</p></blockquote>
<p>Next replace the // step OFF event check comment with:</p>
<blockquote><p>#region Off Board Step Event Check</p>
<p>if (mWiimoteState.BalanceBoardState.OnBoard)<br />
{<br />
mWiimoteState.BalanceBoardState.OnBoard = false;<br />
if (BalanceBoardStep != null)<br />
{ BalanceBoardStep(this, new BalanceBoardStepEventArgs(mWiimoteState.BalanceBoardState, StepType.Off)); }<br />
}</p>
<p>#endregion Off Board Step Event Check</p></blockquote>
<p>Finally all we need to do is update the UpdateBalanceBoardStep function within WiimoteInfo.cs by adding the following cases to the switch statement:</p>
<blockquote><p>case StepType.On:<br />
// Your Code<br />
break;<br />
case StepType.Off:<br />
// Your Code<br />
break;</p></blockquote>
<p>There you have it! additional facility for logging when a user gets ON/OFF the balance board.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/adding-the-step-event/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging Quadzone and Quadrant</title>
		<link>http://blog.dyadica.net/archives/merging-quadzone-and-quadrant</link>
		<comments>http://blog.dyadica.net/archives/merging-quadzone-and-quadrant#comments</comments>
		<pubDate>Thu, 30 Jul 2009 22:24:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Balance Board]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Wii]]></category>
		<category><![CDATA[Area]]></category>
		<category><![CDATA[balance board]]></category>
		<category><![CDATA[Quad]]></category>
		<category><![CDATA[Quadrant]]></category>
		<category><![CDATA[Quadzone]]></category>
		<category><![CDATA[WiiFit]]></category>
		<category><![CDATA[wiimote]]></category>
		<category><![CDATA[wiimoteLib]]></category>
		<category><![CDATA[Zone]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2323</guid>
		<description><![CDATA[Here we have another step down the path towards full Balance Board Orientation. This time out we are going to merge the Quadrant and Quadzone functionality into a new collective known as &#8220;Area&#8221; (for want ...]]></description>
			<content:encoded><![CDATA[<p>Here we have another step down the path towards full Balance Board Orientation. This time out we are going to merge the Quadrant and Quadzone functionality into a new collective known as &#8220;Area&#8221; (for want of a better name).</p>
<p>Please note that this instruction assumes familiarity with the <a title="The Quadrant Filter" href="http://blog.dyadica.net/pages/balance-board/the-quadrant-filter">Quadrant</a> and <a title="The Quadzone Filter" href="http://blog.dyadica.net/pages/balance-board/the-quadzone-filter">Quadzone</a> instructions.</p>
<p>Similar to the <a title="Grouping The COG Systems" href="http://blog.dyadica.net/pages/balance-board/grouping-the-cog-systems">Grouping GOG</a> instruction we are going to start by modifying the DataTypes.cs file  by grouping the two existing definitions by grouping them together in a new struct.</p>
<p>Replace both the Quadrant and Quadzone definitions with the following singular block of code:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Area of most Weight/COG<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public Area Area;</p></blockquote>
<p>Next we are going to add the new struct so that we can use this definition. Below the BalanceBoardState struct add the following code:<span id="more-2323"></span></p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Area Types and Variables<br />
/// &lt;/summary&gt;<br />
[Serializable]<br />
[DataContract]<br />
public struct Area<br />
{<br />
/// &lt;summary&gt;<br />
/// Current Balance Board Zone Area<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public string CurrentZone;</p>
<p>/// &lt;summary&gt;<br />
/// Current Balance Board Quad Area<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public string CurrentQuad;</p>
<p>}</p></blockquote>
<p>What we have here are 2 definitions for the current Quad and Zone. All we really need to do now is to update the existing Quadrant and Quadzone definitions to reflect the new Area.Quad and Area.Zone setup.</p>
<p>Open up Wiimote.cs and add the following (or replace) the following definitions to the balance board case within ParseExtension. Just below the COG ones:</p>
<blockquote><p>// Shorthand the values for lazyness (Kg)<br />
float TLkg = mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft;<br />
float TRkg = mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight;<br />
float BLkg = mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft;<br />
float BRkg = mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight;</p></blockquote>
<p>The above stays the same as in the Quadrant and Quadzone instructions. The following is the new Quad:</p>
<blockquote><p>#region calculate and set values for quad</p>
<p>// Merged Version<br />
if (TLkg &gt; TRkg &amp;&amp; TLkg &gt; BRkg &amp;&amp; TLkg &gt; BLkg) { mWiimoteState.BalanceBoardState.Area.CurrentQuad = &#8220;Top Left&#8221;; }<br />
if (TRkg &gt; TLkg &amp;&amp; TRkg &gt; BRkg &amp;&amp; TRkg &gt; BLkg) { mWiimoteState.BalanceBoardState.Area.CurrentQuad = &#8220;Top Right&#8221;; }<br />
if (BLkg &gt; TLkg &amp;&amp; BLkg &gt; BRkg &amp;&amp; BLkg &gt; TRkg) { mWiimoteState.BalanceBoardState.Area.CurrentQuad = &#8220;Bottom Left&#8221;; }<br />
if (BRkg &gt; TLkg &amp;&amp; BRkg &gt; BLkg &amp;&amp; BRkg &gt; TRkg) { mWiimoteState.BalanceBoardState.Area.CurrentQuad = &#8220;Bottom Right&#8221;; }</p>
<p>#endregion calculate and set values for quad</p></blockquote>
<p>And here we have the new Zone:</p>
<blockquote><p>#region calculate and set values for zone</p>
<p>if ((TLkg + TRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(TLkg + TRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(TLkg + TRkg) &gt; (BLkg + BRkg))<br />
{<br />
mWiimoteState.BalanceBoardState.Area.CurrentZone = &#8220;Top&#8221;;<br />
}</p>
<p>if ((BLkg + BRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(BLkg + BRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(BLkg + BRkg) &gt; (TLkg + TRkg))<br />
{<br />
mWiimoteState.BalanceBoardState.Area.CurrentZone = &#8220;Bottom&#8221;;<br />
}</p>
<p>if ((TLkg + BLkg) &gt; (TLkg + TRkg) &amp;&amp;<br />
(TLkg + BLkg) &gt; (BLkg + BRkg) &amp;&amp;<br />
(TLkg + BLkg) &gt; (TRkg + BRkg))<br />
{<br />
mWiimoteState.BalanceBoardState.Area.CurrentZone = &#8220;Left&#8221;;<br />
}</p>
<p>if ((TRkg + BRkg) &gt; (TLkg + TRkg) &amp;&amp;<br />
(TRkg + BRkg) &gt; (BLkg + BRkg) &amp;&amp;<br />
(TRkg + BRkg) &gt; (TLkg + BLkg))<br />
{<br />
mWiimoteState.BalanceBoardState.Area.CurrentZone = &#8220;Right&#8221;;<br />
}</p>
<p>#endregion calculate and set values for zone</p></blockquote>
<p>And that&#8217;s it! You can call the new code definitions (ie from within WiimoteInfo.cs) as follows:</p>
<blockquote><p>// Quadrant output can also be run from here<br />
lblQuad.Text = ws.BalanceBoardState.Area.CurrentQuad;</p>
<p>// Quadzone output can also be run from here<br />
lblZone.Text = ws.BalanceBoardState.Area.CurrentZone;</p></blockquote>
<p>So why bother doing this, you may ask&#8230;. Well&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/merging-quadzone-and-quadrant/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wii Motion Plus Beta Support</title>
		<link>http://blog.dyadica.net/archives/wii-motion-plus-beta-support</link>
		<comments>http://blog.dyadica.net/archives/wii-motion-plus-beta-support#comments</comments>
		<pubDate>Thu, 23 Jul 2009 22:54:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Wiimote]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[brian peek]]></category>
		<category><![CDATA[wii motion plus]]></category>
		<category><![CDATA[wiimote]]></category>
		<category><![CDATA[wiimoteLib]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2319</guid>
		<description><![CDATA[Brian has done it again, check out the following cross-posting from brianpeek.com detailing beta support for the Wii Motion Plus:
I have posted a new version of WiimoteLib as a beta for people to play around ...]]></description>
			<content:encoded><![CDATA[<p>Brian has done it again, check out the following cross-posting from brianpeek.com detailing beta support for the Wii Motion Plus:</p>
<blockquote><p>I have posted a new version of <a href="http://wiimotelib.codeplex.com/" target="_blank">WiimoteLib</a> as a beta for people to play around with the <a href="http://www.amazon.com/dp/B001TOQ8NO/tag=brianpcom-20" target="_blank">Wii MotionPlus accessory</a>.  Please note that this is not a stable release and should only be used if you wish to mess around with the MotionPlus.  Also note that only C# source code is included in this release as it is not a final build.  Here’s the change log:</p>
<p><span style="text-decoration: underline;">v1.8.0.0</span></p>
<ul>
<li>Taiko Drum Master&#8217;s TaTaCon drum controller supported (Dean Herbert)</li>
<li>Bare-bones Wii MotionPlus support (wiibrew.org, testing by Tyler Tolley)</li>
<li>WiimoteTest UI changed to add MotionPlus data
<ul>
<li>Please note that the current version is VERY flakey and may not work at all for you.</li>
<li>Pair your Wiimote, plug in your MotionPlus, call InitializeMotionPlus()</li>
<li>Extensions plugged into the MotionPlus will give wacky results&#8230;not supported&#8230;yet!</li>
<li>Internal changes to perhaps fix some threading issues</li>
</ul>
</li>
</ul>
<p>So remember, it’s a beta, it may not work for you, and the data you’ll get back from the accessory is just the raw data it provides.  You won’t get real orientation values.</p>
<p>That said, head over to <a href="http://wiimotelib.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30401" target="_blank">CodePlex</a> and give it a try! (Brian Peek)</p></blockquote>
<p>Great work Brian!<a id="update" class="update" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/wii-motion-plus-beta-support/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Finally going mobile</title>
		<link>http://blog.dyadica.net/archives/finally-going-mobile</link>
		<comments>http://blog.dyadica.net/archives/finally-going-mobile#comments</comments>
		<pubDate>Fri, 17 Jul 2009 22:06:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Aprilia RS 125]]></category>
		<category><![CDATA[Bike]]></category>
		<category><![CDATA[CBT]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[Ped]]></category>
		<category><![CDATA[Speedfight 2]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2302</guid>
		<description><![CDATA[Well its been a good few weeks, first I finally cracked Balance Board Orientation and today I passed my CBT. This means that I can finally get mobile.
Originally I was going to rush out and ...]]></description>
			<content:encoded><![CDATA[<p>Well its been a good few weeks, first I finally cracked <a title="Balance Board Orientation" href="http://blog.dyadica.net/archives/real-balance-board-orientation">Balance Board Orientation</a> and today I passed my CBT. This means that I can finally get mobile.</p>
<p>Originally I was going to rush out and get me an <a title="Aprilia RS 125" href="http://mybikeshop.wordpress.com/2008/02/09/aprilia-rs-125/">Aprilia RS 125</a> but then common sense kicked in and I have opted to start out on a moped for a few months &#8211; then the Aprilia lol!</p>
<p><a title="speedfight 2" href="http://www.peugeotmoto.co.uk/speedfight.html"><img class="slarge" title="speedfight_post" src="../wp-content/uploads/2009/07/speedfight_post.gif" alt="speedfight_post" width="695" height="265" /></a></p>
<p>So without further ado let me introduce you to my current number one on the wish list, the Peugeot Speedfight 2 at 100cc.<span id="more-2302"></span></p>
<p>All &#8220;N&#8221; All the reviews are not to shabby for this ped and a little personal experience has swayed my opinion. I find them to be a fun ride, perfect for getting to work and back. Now I just need to source one.</p>
<p>Hopefully the price is going to drop a little too as the <a title="Speedfight 3" href="http://www.peugeotmoto.co.uk/speedfight_3.html">Speedfight 3</a> is out in the next week or so!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/finally-going-mobile/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dampened and Standard COG</title>
		<link>http://blog.dyadica.net/archives/dampened-and-standard-cog</link>
		<comments>http://blog.dyadica.net/archives/dampened-and-standard-cog#comments</comments>
		<pubDate>Wed, 15 Jul 2009 22:23:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Balance Board]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Wii]]></category>
		<category><![CDATA[balance board]]></category>
		<category><![CDATA[Cent]]></category>
		<category><![CDATA[Center Of Gravity]]></category>
		<category><![CDATA[Dampened COG]]></category>
		<category><![CDATA[WiiFit]]></category>
		<category><![CDATA[wiimote]]></category>
		<category><![CDATA[wiimoteLib]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2187</guid>
		<description><![CDATA[A bit of history: Inspired by endquotes WPF implementation of COG I developed an equivalent system for WiimoteLib that provides  facility for Dampened COG output. As stated, I find the two systems can be used ...]]></description>
			<content:encoded><![CDATA[<p>A bit of history: Inspired by endquotes <a title="endquotes COG" href="http://www.brianpeek.com/forums/t/928.aspx">WPF implementation of COG</a> I developed an equivalent system for WiimoteLib that provides  facility for Dampened COG output. As stated, I find the two systems can be used to compliment each other greatly depending upon the desired application requirement. To me the next obvious step was to group both of the outputs together as two available types under the single banner CenterOfGravity.</p>
<p>Using the format of the Wiimote Test application, once complete this instruction will enable access to each COG output as follows:</p>
<blockquote><p>// Standard COG<br />
lblCOG.Text = ws.BalanceBoardState.CenterOfGravity.Standard.ToString();<br />
// Dampened COG<br />
lblDampenedCOG.Text = ws.BalanceBoardState.CenterOfGravity.Dampened.ToString();</p></blockquote>
<p>Before you start this instruction assumes use of a raw copy of WiimoteLib 1.7 and have looked at the <a title="dampened cog instruction" href="http://blog.dyadica.net/pages/balance-board/dampened-cog">Adding Dampened COG to WiimoteLib</a> instruction.</p>
<p>Here is how its done:<span id="more-2187"></span></p>
<p>First we are going to add new public struct CenterOfGravity to Data Types.cs. Just below the existing BalanceBoardState struct add the following block of code:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Center Of Gravity Types and Variables<br />
/// &lt;/summary&gt;<br />
[Serializable]<br />
[DataContract]<br />
public struct CenterOfGravity<br />
{<br />
/// &lt;summary&gt;<br />
/// Center of gravity of Balance Board user<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public PointF Standard;<br />
/// &lt;summary&gt;<br />
/// Dampened Center of gravity of Balance Board<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public Point Dampened;<br />
/// &lt;summary&gt;<br />
/// Offset for Center of gravity Damping<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public Point DampOffset;<br />
/// &lt;summary&gt;<br />
/// Limits for Center of gravity Damping<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public int DampX, DampY;<br />
}</p></blockquote>
<p>As you can see this block contains all the same code as within the previous dampened COG instruction, however we have also added a new member &#8220;Standard&#8221;. Standard is going to reflect the existing COG setup when we are done.</p>
<p>Next (Assuming a raw copy of WiimoteLib 1.7) we need to remove the existing code block defining CenterOfGravity from the BalanceBoardState struct:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Center of gravity of Balance Board user<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public PointF CenterOfGravity;</p></blockquote>
<p>and replace it with the following new definition:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Center of gravity of Balance Board user<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public CenterOfGravity CenterOfGravity;</p></blockquote>
<p>Next we need to add the following two new functions to Wiimote.cs, I have included them just below the ParseExtension function. These functions are used to provide an initial damping offset (calibration value) and calculate the Dampened COG at run time. These functions are in essence the same as within the dampened COG instruction, however now containing the new updated syntax.</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Function used to set the damping offset<br />
/// &lt;/summary&gt;<br />
public void SetDampenOffset()<br />
{ mWiimoteState.BalanceBoardState.CenterOfGravity.DampOffset = GetDampenedCenterOfGravity(); }</p>
<p>/// &lt;summary&gt;<br />
/// Function to get Dampened COG without the offset so it can also be used to set the offset<br />
/// &lt;/summary&gt;<br />
private Point GetDampenedCenterOfGravity()<br />
{<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.X += -(mWiimoteState.BalanceBoardState.SensorValuesRaw.TopLeft + mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomLeft);<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.Y += -(mWiimoteState.BalanceBoardState.SensorValuesRaw.TopLeft + mWiimoteState.BalanceBoardState.SensorValuesRaw.TopRight);<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.X += (mWiimoteState.BalanceBoardState.SensorValuesRaw.TopRight + mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomRight);<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.Y += (mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomLeft + mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomRight);</p>
<p>if (mWiimoteState.BalanceBoardState.CenterOfGravity.DampX == 0 || mWiimoteState.BalanceBoardState.CenterOfGravity.DampY == 0)<br />
{<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.DampX = 500; // hack to cater for zero value at start up<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.DampY = 800; // hack to cater for zero value at start up<br />
}</p>
<p>int DampX = mWiimoteState.BalanceBoardState.CenterOfGravity.DampX;<br />
int DampY = mWiimoteState.BalanceBoardState.CenterOfGravity.DampY;</p>
<p>mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.X = mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.X / DampX;<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.Y = mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.Y / DampY;</p>
<p>return mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened;<br />
}</p></blockquote>
<p>As before, inclusion of the DampX and DampY variables enables individual axis stiffness customization, which is usefull due the rectangular nature of the Balance Board.</p>
<p>Next in order to use these functions we need to add the following code to the parse extension function. I do this just below the existing COG code:</p>
<blockquote><p>Point DCOG = GetDampenedCenterOfGravity();</p>
<p>mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.X = DCOG.X &#8211; mWiimoteState.BalanceBoardState.CenterOfGravity.DampOffset.X;<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Dampened.Y = DCOG.Y &#8211; mWiimoteState.BalanceBoardState.CenterOfGravity.DampOffset.Y;</p></blockquote>
<p>Whilst we are here we also need to update the existing COG code to reflect the new syntax. Just above the code you have just put in update the COG alocations to reflect the following:</p>
<blockquote><p>mWiimoteState.BalanceBoardState.CenterOfGravity.Standard.X = ((float)(Kx &#8211; 1) / (float)(Kx + 1)) * (float)(-BSL / 2);<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.Standard.Y = ((float)(Ky &#8211; 1) / (float)(Ky + 1)) * (float)(-BSW / 2);</p></blockquote>
<p>Ok, we are nearly done. Finally we need to add a call to the SetDampenOffset() function in order to define an offset value at start up. Still within Wiimote.cs add the following call within InitializeExtension() inside the ExtensionType.BalanceBoard case,  just above the break.</p>
<blockquote><p>SetDampenOffset();</p></blockquote>
<p>And thats it, now you should have acces to both the Standard and Dampened COG values via the new CenterOfGravity grouping. As a final thought, yes it has dawned on me that dampened may be better as damped lol!<a id="update" class="update"></a></p>
<p><strong>Update: The SetBalanceBoardDefaults() Function</strong></p>
<p>Whilst developing the code for the Orientation implementation, it became apparent that there was need for an initialize function that could be used to define defaults and provide facility for resetting etc.</p>
<p>I have decided to add the definition here as really Damped COG  is the first time that we needed its capabilities, remember the hack to cater for zero values at start up:</p>
<blockquote><p>if (mWiimoteState.BalanceBoardState.DampX == 0 || mWiimoteState.BalanceBoardState.DampY == 0)<br />
{<br />
mWiimoteState.BalanceBoardState.DampX = 500; // hack to cater for zero value at start up<br />
mWiimoteState.BalanceBoardState.DampY = 800; // hack to cater for zero value at start up<br />
}</p></blockquote>
<p>This modification will <span style="text-decoration: line-through;">not only allow us to remove it, but also</span> provide a location for defining other variables later on. Start off by adding the following variable definitions to the top of Wiimote.cs just above the default constructor:</p>
<blockquote><p>private int Dx = 500;<br />
private int Dy = 800;</p></blockquote>
<p>Next we need to add the function itself. Add the following right below the ParseExtension function:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Function used to set the initial defaults.<br />
/// These can be customised above and/or at runtime.<br />
/// &lt;/summary&gt;<br />
private void SetBalanceBoardDefaults()<br />
{<br />
// set the individual damping tolerances for both the<br />
// X and Y axies of the board (good for a rectangle)<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.DampX = Dx;<br />
mWiimoteState.BalanceBoardState.CenterOfGravity.DampY = Dy;<br />
}</p></blockquote>
<p>With this in place all we need to do now is to add a call to the function at startup. Add the following (Currently I am undecided about merging the two together!) right before the call to SetDampenOffset() within the InitializeExtension() function.</p>
<blockquote><p>SetBalanceBoardDefaults();</p></blockquote>
<p>With that done we are finished and now have provision for defining defaults etc!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/dampened-and-standard-cog/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Balance Board Quadzone Filter for WiimoteLib</title>
		<link>http://blog.dyadica.net/archives/the-balance-board-quadzone-filter-for-wiimotelib</link>
		<comments>http://blog.dyadica.net/archives/the-balance-board-quadzone-filter-for-wiimotelib#comments</comments>
		<pubDate>Tue, 14 Jul 2009 22:23:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Wii]]></category>
		<category><![CDATA[balance board]]></category>
		<category><![CDATA[Quadzone]]></category>
		<category><![CDATA[WiiFit]]></category>
		<category><![CDATA[wiimote]]></category>
		<category><![CDATA[wiimoteLib]]></category>
		<category><![CDATA[Zones]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2157</guid>
		<description><![CDATA[There are times when using the WiiFit Balance Board with WiimoteLib that I find it useful to have direct access to which particular &#8220;Zone&#8221; currently has focus (most weight or COG applied), just think WiiFit ...]]></description>
			<content:encoded><![CDATA[<p>There are times when using the WiiFit Balance Board with WiimoteLib that I find it useful to have direct access to which particular &#8220;Zone&#8221; currently has focus (most weight or COG applied), just think WiiFit areobics etc. Output is fed back as a string which can then be used as desired eg in a switch or if statement etc.</p>
<p>Here&#8217;s how its done:</p>
<p>First of all open up Data Types.cs and add the following code block within the BalanceBoardState struct:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Current Balance Board Zone<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public string Quadzone;</p></blockquote>
<p>Next open up Wiimote.cs and locate the parse extension function. For convenience sake the following block shorthands the values included with WiimoteLib to help with RSI. Add the following code below the existing COG code just above the break:<span id="more-2157"></span></p>
<blockquote><p>// Shorthand the values for lazyness (Raw)<br />
// float TLrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.TopLeft;<br />
// float TRrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.TopRight;<br />
// float BLrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomLeft;<br />
// float BRrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomRight;</p>
<p>// Shorthand the values for lazyness (Kg)<br />
float TLkg = mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft;<br />
float TRkg = mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight;<br />
float BLkg = mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft;<br />
float BRkg = mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight;</p></blockquote>
<p>As you can see I have included facility for using the raw values, but personally I have not found a need to yet! Next we need to add the code that will enable Zone output at run time. Below the shorthand code add the following block:</p>
<blockquote><p>if ((TLkg + TRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(TLkg + TRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(TLkg + TRkg) &gt; (BLkg + BRkg)) { mWiimoteState.BalanceBoardState.Quadzone = &#8220;Top&#8221;; }</p>
<p>if ((BLkg + BRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(BLkg + BRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
(BLkg + BRkg) &gt; (TLkg + TRkg)) { mWiimoteState.BalanceBoardState.Quadzone = &#8220;Bottom&#8221;; }</p>
<p>if ((TLkg + BLkg) &gt; (TLkg + TRkg) &amp;&amp;<br />
(TLkg + BLkg) &gt; (BLkg + BRkg) &amp;&amp;<br />
(TLkg + BLkg) &gt; (TRkg + BRkg)) { mWiimoteState.BalanceBoardState.Quadzone = &#8220;Left&#8221;; }</p>
<p>if ((TRkg + BRkg) &gt; (TLkg + TRkg) &amp;&amp;<br />
(TRkg + BRkg) &gt; (BLkg + BRkg) &amp;&amp;<br />
(TRkg + BRkg) &gt; (TLkg + BLkg)) { mWiimoteState.BalanceBoardState.Quadzone = &#8220;Right&#8221;; }</p></blockquote>
<p>If you want you can also add definitions for angle zones however as with the raw value definitions I dont really find much use for them, however here they are just in case:</p>
<blockquote><p>//if ((TLkg + BRkg) &gt; (TLkg + TRkg) &amp;&amp;<br />
//     (TLkg + BRkg) &gt; (BLkg + BRkg) &amp;&amp;<br />
//     (TLkg + BRkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
//     (TLkg + BRkg) &gt; (TRkg + BLkg)) { mWiimoteState.BalanceBoardState.Quadzone = &#8220;Left-Right&#8221;; }</p>
<p>//if ((TRkg + BLkg) &gt; (TLkg + TRkg) &amp;&amp;<br />
//     (TRkg + BLkg) &gt; (BLkg + BRkg) &amp;&amp;<br />
//     (TRkg + BLkg) &gt; (TLkg + BLkg) &amp;&amp;<br />
//     (TRkg + BLkg) &gt; (TLkg + BRkg)) { mWiimoteState.BalanceBoardState.Quadzone = &#8220;Right-Left&#8221;; }</p></blockquote>
<p>Once complete Quadzone is now available by the normal means for example:</p>
<blockquote><p>WiimoteState ws = state;<br />
BalanceBoardState bb = ws.BalanceBoardState;</p>
<p>string current_zone = bb.Quadzone;</p></blockquote>
<p>That&#8217;s all there is to it easy eh!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/the-balance-board-quadzone-filter-for-wiimotelib/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Balance Board Quadrant Filter for WiimoteLib</title>
		<link>http://blog.dyadica.net/archives/the-balance-board-quadrant-filter-for-wiimotelib</link>
		<comments>http://blog.dyadica.net/archives/the-balance-board-quadrant-filter-for-wiimotelib#comments</comments>
		<pubDate>Tue, 14 Jul 2009 22:23:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Wii]]></category>
		<category><![CDATA[balance board]]></category>
		<category><![CDATA[Balance Board Filters]]></category>
		<category><![CDATA[Quadrant]]></category>
		<category><![CDATA[Quadzone]]></category>
		<category><![CDATA[WiiFit]]></category>
		<category><![CDATA[wiimote]]></category>
		<category><![CDATA[wiimoteLib]]></category>

		<guid isPermaLink="false">http://blog.dyadica.net/?p=2163</guid>
		<description><![CDATA[There are times when using the WiiFit Balance Board with WiimoteLib that I find it useful to have direct access to which particular &#8220;Quadrant&#8221; currently has focus (most weight or COG applied), as with the ...]]></description>
			<content:encoded><![CDATA[<p>There are times when using the WiiFit Balance Board with WiimoteLib that I find it useful to have direct access to which particular &#8220;Quadrant&#8221; currently has focus (most weight or COG applied), as with the Quadzone Filter just think WiiFit areobics etc.</p>
<p>When used in conjunction with the Quadzone Filter you have the basic tools needed for very simple forms of navigation. As with the Quadzone filter, output is fed back as a string which can then be used as desired eg in a switch or if statement etc.</p>
<p>So without further ado heres how its done:</p>
<p>First of all open up Data Types.cs and add the following code block within the BalanceBoardState struct:</p>
<blockquote><p>/// &lt;summary&gt;<br />
/// Current Balance Board Quadrant, SJB<br />
/// &lt;/summary&gt;<br />
[DataMember]<br />
public string Quadrant;</p></blockquote>
<p>Next open up Wiimote.cs and locate the parse extension function. For convenience sake the following block shorthands the values included with WiimoteLib. The code is the same as that used in the Quadzone tutorial so if you have already implemented it there you can skip this step, otherwise add the following code below the existing COG code just above the break:<span id="more-2163"></span></p>
<blockquote><p>// Shorthand the values for lazyness (Raw)<br />
// float TLrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.TopLeft;<br />
// float TRrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.TopRight;<br />
// float BLrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomLeft;<br />
// float BRrkg = mWiimoteState.BalanceBoardState.SensorValuesRaw.BottomRight;</p>
<p>// Shorthand the values for lazyness (Kg)<br />
float TLkg = mWiimoteState.BalanceBoardState.SensorValuesKg.TopLeft;<br />
float TRkg = mWiimoteState.BalanceBoardState.SensorValuesKg.TopRight;<br />
float BLkg = mWiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft;<br />
float BRkg = mWiimoteState.BalanceBoardState.SensorValuesKg.BottomRight;</p></blockquote>
<p>As you can see I have included suggested functionality for using the raw values, but personally I have not found a need to yet. Its just there for reference! Next we need to add the code that will enable Quadrant output at run time. Below the shorthand code add the following block:</p>
<blockquote><p>// Calculate the heavest quadrant<br />
if (TLkg &gt; TRkg &amp;&amp; TLkg &gt; BRkg &amp;&amp; TLkg &gt; BLkg) { mWiimoteState.BalanceBoardState.Quadrant = &#8220;TL&#8221;; }<br />
if (TRkg &gt; TLkg &amp;&amp; TRkg &gt; BRkg &amp;&amp; TRkg &gt; BLkg) { mWiimoteState.BalanceBoardState.Quadrant = &#8220;TR&#8221;; }<br />
if (BLkg &gt; TLkg &amp;&amp; BLkg &gt; BRkg &amp;&amp; BLkg &gt; TRkg) { mWiimoteState.BalanceBoardState.Quadrant = &#8220;BL&#8221;; }<br />
if (BRkg &gt; TLkg &amp;&amp; BRkg &gt; BLkg &amp;&amp; BRkg &gt; TRkg) { mWiimoteState.BalanceBoardState.Quadrant = &#8220;BR&#8221;; }</p></blockquote>
<p>Once complete Quadrantis available by the normal means for example:</p>
<blockquote><p>WiimoteState ws = state;<br />
BalanceBoardState bb = ws.BalanceBoardState;</p>
<p>string current_quad = bb.Quadrant;</p>
<p>//Or following the Wiimote Test example<br />
lblQuad.Text = ws.BalanceBoardState.Quadrant;</p></blockquote>
<p>That&#8217;s all there is to it easy eh! If you haven&#8217;t seen the Quadzone tutorial yet, go check it out. The two methods compliment each other greatly!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dyadica.net/archives/the-balance-board-quadrant-filter-for-wiimotelib/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
