<?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>lithium flowers bloom &#187; Processing</title>
	<atom:link href="http://leejayxia.com/blog/tag/processing/feed/" rel="self" type="application/rss+xml" />
	<link>http://leejayxia.com/blog</link>
	<description>the weblog</description>
	<lastBuildDate>Sat, 15 May 2010 20:52:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Communication Setup for Blinded</title>
		<link>http://leejayxia.com/blog/communication-setup-for-blinded/</link>
		<comments>http://leejayxia.com/blog/communication-setup-for-blinded/#comments</comments>
		<pubDate>Sat, 15 May 2010 20:52:00 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Sociable Objects Workshop]]></category>
		<category><![CDATA[Kinetic]]></category>
		<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[xbee]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=857</guid>
		<description><![CDATA[Li and I worked on a group of robotic/kinetic creatures to create an ironic and self-balanced networked system called Blinded. A very detailed documentation of the construction iterations are up on Li&#8217;s website, so I&#8217;ll just write a bit about the communication between the creatures. For the first iteration we had only one creature fully [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://leejayxia.com/blog/wp-content/uploads/2010/05/4573919919_ab5486a201_o.jpg" rel="lightbox[857]"><img src="http://leejayxia.com/blog/wp-content/uploads/2010/05/4573919919_ab5486a201_o.jpg" alt="" title="4573919919_ab5486a201_o" width="720" height="465" class="alignnone size-full wp-image-858" /></a></p>
<p><a href="http://im-li.com">Li</a> and I worked on a group of robotic/kinetic creatures to create an ironic and self-balanced networked system called <em><a href="http://im-li.com/blinded/">Blinded</a></em>. </p>
<p>A very <a href="http://im-li.com/project-blinded/">detailed documentation</a> of the construction iterations are up on Li&#8217;s website, so I&#8217;ll just write a bit about the communication between the creatures.</p>
<p>For the first iteration we had only one creature fully assembled so I built a quick &#8220;single character communication protocol&#8221; that allows the creature to be remotely controlled from a computer. I have two pre-paired series one xbees which are perfect for this basic cable replacement purpose. </p>
<p>The arduino on the creature side is expecting specific &#8220;single character&#8221; functions from the serial channel via xbee, available instructions are:</p>
<p>1. L &#8211; turn left<br />
2. R &#8211; turn right<br />
3. F &#8211; step forward<br />
4. anything else &#8211; stop</p>
<p>At the same time, for monitoring purpose the arduino is reporting if the creature is on its target by comparing its left and right sensors and their historic readings, the reported status is written into the serial channel simply with notation of 1 (on-target) and 0 (target lost).</p>
<p>Because we had only one creature ready back then, the pursuing status is not entirely making sense, so the computer mainly served as a remote controller. The controller setup is pretty simple though, it can be just an xbee explorer board and any serial terminal program can be used to send commands to the remote creature. Following video shows one of our field tests in the park.</p>
<p><object type="application/x-shockwave-flash" width="500" height="375" data="http://www.flickr.com/apps/video/stewart.swf?v=71377" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="flashvars" value="intl_lang=en-us&#038;photo_secret=736789bd13&#038;photo_id=4573469454&#038;flickr_show_info_box=true"></param><param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=71377"></param><param name="bgcolor" value="#000000"></param><param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=71377" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&#038;photo_secret=736789bd13&#038;photo_id=4573469454&#038;flickr_show_info_box=true" height="375" width="500"></embed></object> </p>
<p>After more creatures were added to the group, the situation became much more complicated and I have to put up a processing sketch to coordinate input from multiple creatures. I did not use the xbee library for processing although it did look pretty promising in the examples and taking care a lot of the heavy liftings. But I dig into the source code a little bit and got a feeling that it might be a pain to use with series 2 xbees. So I just wrote some very simple parsing functions to take apart I/O packets and make sure I have access to any digital or analog pins without too much hack. </p>
<p>For physical setup, I switched all remote xbees to series 2 and put their firmware to router-at mode. The base station that stays with the computer is in coordinator-api mode. I used 4 pins of the remote xbees, 2 for digital output (remote commands), 2 for analog input (transferring sensor values to the remote computer/coordinator). Each remote xbee will still need to handle status reporting and command receiving, and the arduino on the creature remains as local intelligence that parses the sensor information and actually controls the motion.</p>
<p>Commands for Xbee configuration:</p>
<p>ATD04<br />
ATD14<br />
ATD22<br />
ATD32</p>
<p>During runtime, the computer is able to set the remote xbee digital pin state through processing sketch. Code snippet for setting</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">void</span> setRemotePin<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>address, <span style="color: #003399;">String</span> command, <span style="color: #000066; font-weight: bold;">int</span> value<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>address.<span style="color: #006633;">length</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;invalid address&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>command.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;invalid command&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0x7E<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// start byte</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0x0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// high part of length (always zero)</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0x10<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// low part of length (the number of bytes that follow, not including checksum)</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0x17<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 0x17 is a remote AT command</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0x0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// frame id set to zero for no reply</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// ID of recipient, or use 0xFFFF for broadcast</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>address<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp;<span style="color: #666666; font-style: italic;">/* broadcast */</span><br />
&nbsp;<span style="color: #666666; font-style: italic;">/*<br />
&nbsp; serialSelector.port.write(00);<br />
&nbsp; serialSelector.port.write(00);<br />
&nbsp; serialSelector.port.write(00);<br />
&nbsp; serialSelector.port.write(00);<br />
&nbsp; serialSelector.port.write(00);<br />
&nbsp; serialSelector.port.write(00);<br />
&nbsp; serialSelector.port.write(0xFF); // 0xFF for broadcast<br />
&nbsp; serialSelector.port.write(0xFF); // 0xFF for broadcast<br />
&nbsp; */</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// 16 bit of recipient or 0xFFFE if unknown</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0xFF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0xFE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>0x02<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 0x02 to apply changes immediately on remote</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// command name in ASCII characters</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>command.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>command.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// command data in as many bytes as needed</span><br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">// checksum is all bytes after length bytes</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">int</span> sum <span style="color: #339933;">=</span> 0x17 <span style="color: #339933;">+</span> 0xFF <span style="color: #339933;">+</span> 0xFE <span style="color: #339933;">+</span> 0x02 <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>command.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#40;</span>command.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> value<span style="color: #339933;">;</span><br />
&nbsp;<br />
&nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;sum <span style="color: #339933;">+=</span> address<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; serialSelector.<span style="color: #006633;">port</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span> 0xFF <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span> sum <span style="color: #339933;">&amp;</span> 0xFF<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// calculate the proper checksum</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//delay(10); // safety pause to avoid overwhelming the serial port (if this function is not implemented properly)</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/communication-setup-for-blinded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sensor Network: Data Logging and Visualization</title>
		<link>http://leejayxia.com/blog/sensor-network-data-logging-and-visualization/</link>
		<comments>http://leejayxia.com/blog/sensor-network-data-logging-and-visualization/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 07:50:18 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[ITP]]></category>
		<category><![CDATA[Sociable Objects Workshop]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[sensor network]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[xbee]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=823</guid>
		<description><![CDATA[I&#8217;m working with Sebastian and Michael as &#8220;visualization&#8221; team for the sensor network assignment for this week&#8217;s Sociable Objects Workshop. It&#8217;s very challenging for the whole class to work on one single project, but so far it went on pretty well. Tasks are split and assigned and we also find ways to work with dependencies [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working with Sebastian and Michael as &#8220;visualization&#8221; team for the sensor network assignment for this week&#8217;s Sociable Objects Workshop. It&#8217;s very challenging for the whole class to work on one single project, but so far it went on pretty well. Tasks are split and assigned and we also find ways to work with dependencies and such constraints.</p>
<p>Since we are just focusing on the visualization part, meaning that we take on only after all the data are aggregated at the coordinator xbee, our main effort will be data logging, mining and visualization. So the first thing we built is a <strong>pseudo data generator</strong> that feeds data in the same format as the data will be from the coordinator. We talked to the base station team and agreed that we will be getting raw API I/O RX packet and we will take care of the parsing and data storage. </p>
<p>I put together some simple arduino code to feed pseudo data, they could be easily replaced by a real coordinator and ideally we will not have to change the processing code on the other side which is listening to the serial channel.</p>
<div class="codecolorer-container c dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:1300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#define ADDRESS_COUNT 9</span><br />
<span style="color: #993333;">int</span> addresses<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #208080;">0x0001</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0002</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0003</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0004</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0005</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0006</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0007</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0008</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #208080;">0x0009</span><span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; randomSeed<span style="color: #009900;">&#40;</span>analogRead<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&lt;</span> ADDRESS_COUNT<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>random<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">990</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>random<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sendPseudoPackage<span style="color: #009900;">&#40;</span>addresses<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sendPseudoPackage<span style="color: #009900;">&#40;</span>addresses<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #993333;">void</span> sendPseudoPackage<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> address<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp;<span style="color: #666666; font-style: italic;">// pass either a 0x4 or and 0x5 to turn the pin on or off</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x7E</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// start byte</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x0</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// high part of length (always zero)</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x17</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// low part of length (the number of bytes that follow, not including checksum)</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x92</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 0x92 is I/O RX Packet</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//05-12: &nbsp;64-bit address</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x13</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xA2</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x40</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x33</span><span style="color: #339933;">,</span>BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #993333;">int</span> low <span style="color: #339933;">=</span> address <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #993333;">int</span> high <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>address <span style="color: #339933;">-</span> low<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>high<span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>low<span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//13-14: &nbsp;16 bit of recipient or 0xFFFE if unknown</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xFF</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0xFE</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//15: &nbsp;Receive Option</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x01</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//16: &nbsp;Num Samples</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x01</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//17-18 Digital Channel Mask</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x01</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//only Digital I/O 0</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//19: &nbsp;Analog Channel Mask</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//20-21: &nbsp;Digital Samples</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">,</span> BYTE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">//no analog samples</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">// checksum is all bytes after length bytes</span><br />
&nbsp; <span style="color: #993333;">long</span> sum <span style="color: #339933;">=</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//fake</span><br />
&nbsp; Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span> <span style="color: #208080;">0xFF</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span> sum <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFF</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">,</span> BYTE <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// calculate the proper checksum</span><br />
&nbsp; delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// safety pause to avoid overwhelming the serial port (if this function is not implemented properly)</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Then I wrote a basic processing sketch which filters the data and stores only changes to the databases. The sketch itself servers as some sort of realtime visualization on the input, and we get a feeling of how often data are changing and potentially detects sensor failures if one sensor is not active for a very long time.</p>
<p><object width="500" height="281"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9819815&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=9819815&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="281"></embed></object></p>
<p>The processing sketch is sending data to a website that handles data logging. The website also provides query api that returns sensor history in json format, and functions like filtering by certain address. The site itself is lightweight and fairly easy to add new functionality.</p>
<p>The plan is to meet tomorrow and start building a web interface upon the api for the final visualization. Hopefully we could also get to verify if the pseudo data is identical to the real format, and maybe we can get a test run with the real setup.</p>
<p><del datetime="2010-03-24T04:37:19+00:00">Stay tuned!</del></p>
<p><strong>UPDATE</strong>: A list of available API functions:</p>
<p>url: http://itp.nyu.edu/~lx243/sensornet/index.php/api/</p>
<blockquote><p>all (meaning that the url will look like http://itp.nyu.edu/~lx243/sensornet/index.php/api/all)
</p></blockquote>
<p>returning all records in json format</p>
<blockquote><p>find/:address</p></blockquote>
<p>returning all records from address specified<br />
address should be a string of 64bit address, e.g. 0013A20040330001</p>
<blockquote><p>find_today/:address</p></blockquote>
<blockquote><p>find_by_day/:address/:day
</p></blockquote>
<p>day should be in the format of yyyymmdd, e.g. 20100301</p>
<blockquote><p>status/:address
</p></blockquote>
<p>returning latest records from specified address</p>
<blockquote><p>status_at/:address/:time
</p></blockquote>
<p>returning latest records by the time specified<br />
time should be in the format of yyyymmddHHMMSS, e.g. 20100301140000</p>
<blockquote><p>changes/:address
</p></blockquote>
<p>returning all changes at specified address</p>
<blockquote><p>changes_today/:address
</p></blockquote>
<p>returning changes happened today at specified address</p>
<blockquote><p>changes_by_day/:address/:day
</p></blockquote>
<p>returning changes happened today on specified date at specified address<br />
day should be in the format of yyyymmdd, e.g. 20100301</p>
<blockquote><p>stats/:address
</p></blockquote>
<p>returning open time, close time, changes, and total active time of the sensor</p>
<blockquote><p>stats_today/:address
</p></blockquote>
<p>returning above stats from specified address</p>
<blockquote><p>stats_by_day/:address/:day
</p></blockquote>
<p>returning above stats from specified address on specified day</p>
<p><strong>UPDATE 2</strong>: Visualization</p>
<p>It took a while for Sebastian and I to make processing.js to talk to the API and get real time update. We used jQuery as a bridge to retrieve the data and feed it on the page to processing.js.  But eventually all is fine:</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2010/03/Mozilla-Firefox.png" rel="lightbox[823]"><img src="http://leejayxia.com/blog/wp-content/uploads/2010/03/Mozilla-Firefox.png" alt="" title="Where is my professor?" width="797" height="284" class="alignnone size-full wp-image-840" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/sensor-network-data-logging-and-visualization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Humon beings update</title>
		<link>http://leejayxia.com/blog/humon-beings-update/</link>
		<comments>http://leejayxia.com/blog/humon-beings-update/#comments</comments>
		<pubDate>Sat, 02 May 2009 07:55:59 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Redial:Interactive Telephony]]></category>
		<category><![CDATA[The Nature of Code]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[monster]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Spring 2009]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=653</guid>
		<description><![CDATA[Li and I presented the humons on Wednesday and Thursday in both Redial and Nature of Code class. Although we&#8217;ve been playing around for weeks and a lot of people already saw it, it&#8217;s still so joyful to see a lot people actually play with it at the same time. Here&#8217;s the video from the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lilidada.com">Li</a> and I presented the <a title="humon dev weblog" href="http://humon.us/about">humons</a> on Wednesday and Thursday in both Redial and Nature of Code class. Although we&#8217;ve been playing around for weeks and a lot of people already saw it, it&#8217;s still so joyful to see a lot people actually play with it at the same time.</p>
<p>Here&#8217;s the video from the nature of code class presentation.</p>
<p><object width="640" height="432" data="http://vimeo.com/moogaloop.swf?clip_id=4420465&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4420465&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /></object></p>
<p>A short demo of the basic motions we have so far: basic motion, jelly-ish body shape, gravity, collision, multiple ground tracks. The physics are implemented with the great <a href="http://code.google.com/p/toxiclibs/">toxi verletphysics</a> library.</p>
<p><object width="640" height="400" data="http://vimeo.com/moogaloop.swf?clip_id=4420912&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4420912&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /></object></p>
<p>Basic interactions are all accessible from the phone, which allow a lot of people to interact at the same time without introducing more human-computer interfaces.  In this demo video: basic movements (horizontal moving),  jumping, message recording.</p>
<p><object width="640" height="480" data="http://vimeo.com/moogaloop.swf?clip_id=4423441&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4423441&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /></object></p>
<p>Another key feature of the humon project is to allow people to record and broadcast voice messages to the whole community. The instant playback will probably be replaced by a queueing system in short future, so that the audience may be able to focus on certain messages.</p>
<p><object width="640" height="432" data="http://vimeo.com/moogaloop.swf?clip_id=4421322&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4421322&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /></object></p>
<p>Some more screenshots from early processing sketches and different scenes:</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-15.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-665" title="e59bbee78987-15" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-15-300x187.png" alt="e59bbee78987-15" width="300" height="187" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-13.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-663" title="e59bbee78987-13" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-13-300x187.png" alt="e59bbee78987-13" width="300" height="187" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-11.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-662" title="e59bbee78987-11" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-11-300x187.png" alt="e59bbee78987-11" width="300" height="187" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-10.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-661" title="e59bbee78987-10" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-10-300x187.png" alt="e59bbee78987-10" width="300" height="187" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-9.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-660" title="e59bbee78987-9" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/e59bbee78987-9-300x187.png" alt="e59bbee78987-9" width="300" height="187" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/wonderscene.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-671" title="wonderscene" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/wonderscene-300x187.png" alt="wonderscene" width="300" height="187" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/nightscene.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-670" title="nightscene" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/nightscene-300x187.png" alt="nightscene" width="300" height="187" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/landscene.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-669" title="landscene" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/landscene-300x187.png" alt="landscene" width="300" height="187" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/05/cityscene.png" rel="lightbox[653]"><img class="alignnone size-medium wp-image-668" title="cityscene" src="http://leejayxia.com/blog/wp-content/uploads/2009/05/cityscene-300x187.png" alt="cityscene" width="300" height="187" /></a></p>
<p>The <strong>development weblog</strong> is now live too, we&#8217;ll keep updating there more often.</p>
<p>Check it out: <a href="http://humon.us">humon doings</a></p>
<p>I stayed up late to check if we got into the spring show, but it&#8217;s still not out yet. Time to sleep!</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/humon-beings-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>US Intervention 1798 &#8211; 2009</title>
		<link>http://leejayxia.com/blog/us-intervention-1798-2009/</link>
		<comments>http://leejayxia.com/blog/us-intervention-1798-2009/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 18:35:17 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Mainstreaming Info]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Military Intervention]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Spring 2009]]></category>
		<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=643</guid>
		<description><![CDATA[&#8220;The United States military has been intervening in other countries for a long time. In 1898, it seized the Philippines, Cuba, and Puerto Rico from Spain, and in 1917-18 became embroiled in World War I in Europe. In the first half of the 20th century it repeatedly sent Marines to &#8216;protectorates&#8217; such as Nicaragua, Honduras, [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;The United States military has been intervening in other countries for a long time. In 1898, it seized the Philippines, Cuba, and Puerto Rico from Spain, and in 1917-18 became embroiled in World War I in Europe. In the first half of the 20th century it repeatedly sent Marines to &#8216;protectorates&#8217; such as Nicaragua, Honduras, Panama, Haiti, and the Dominican Republic. All these interventions directly served corporate interests, and many resulted in massive losses of civilians, rebels, and soldiers.&#8221; (via A BRIEFING ON THE HISTORY OF U.S. MILITARY INTERVENTIONS, By Zoltán Grossman, October 2001)</p>
<p>People might be familiar with recent US military interventions in Middle East, or those in Asia in 1970s, however in the past 200 years&#8217; history, overseas interventions actually happened a lot more frequent than people usually think and played an important role to this country&#8217;s development. </p>
<p>This visualization is not intended to create a narrative piece of intervention history, it&#8217;s more created as a tool to go through the mass amount of history events and discover the correlations among those events in a certain period of time, or within a certain region.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-2.png" rel="lightbox[643]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-2-1024x767.png" alt="e59bbee78987-2" title="e59bbee78987-2" width="80%" class="alignnone size-large wp-image-648" /></a></p>
<p>DOWNLOAD</p>
<p>Download app for mac:</p>
<p><a href="http://leejayxia.com/processing/us_intervention_mono_present.zip">http://leejayxia.com/processing/us_intervention_mono_present.zip</a></p>
<p>For 1024 x 768:</p>
<p><a href="http://leejayxia.com/processing/us_intervention_mono_present_1024.zip">http://leejayxia.com/processing/us_intervention_mono_present_1024.zip</a></p>
<p>I&#8217;m still working on the source data since world wars are currently excluded. Download links will be updated when I finish.</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/us-intervention-1798-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I wish I know more trigs</title>
		<link>http://leejayxia.com/blog/i-wish-i-know-more-trigs/</link>
		<comments>http://leejayxia.com/blog/i-wish-i-know-more-trigs/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 06:46:10 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Mainstreaming Info]]></category>
		<category><![CDATA[geodata]]></category>
		<category><![CDATA[globe]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[Spring 2009]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=625</guid>
		<description><![CDATA[Did too much soldering today. I&#8217;ll just post some screenshots as update for the U.S. intervention history visualization. Since last the most effort regarding this project was spent on figuring out the tech details on building interaction into the spinning globe. I wish I know more about trigs! Several tips to put down for myself: [...]]]></description>
			<content:encoded><![CDATA[<p>Did too much soldering today. I&#8217;ll just post some screenshots as update for the U.S. intervention history visualization. Since last the most effort regarding this project was spent on figuring out the tech details on building interaction into the spinning globe. I wish I know more about trigs!</p>
<p>Several tips to put down for myself:</p>
<p>- move textFont() out of the loop;<br />
- do not create font on the fly if using huge font size;<br />
- screenX and screenY are your friends (while creating mouse over interaction in 3D) (Thanks Dan!);<br />
- rotation is headache, rotation in 3D is huge headache:</p>
<p>I had some rotation and translation params of a point generated by geo data. It&#8217;s easy to get params in those forms when you&#8217;re dealing with a sphere. Such point can easily be drawn with a series of rotate() and translate(), and a box() or sphere(), however I want to calculate the actual coordinates of those points in the 3D space to place attractors / draw lines / whatever.</p>
<p>I wish I paid enough attention while I learned trigs in high school, but I ended up looking into processing core source code and did something like this:</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">PVector rotation <span style="color: #339933;">=</span> getRotation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// the rotation params that i do have</span><br />
<span style="color: #000066; font-weight: bold;">float</span> offsetZ <span style="color: #339933;">=</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// some arbitrary number</span><br />
<br />
PMatrix3D m <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PMatrix3D<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
m.<span style="color: #006633;">rotateY</span><span style="color: #009900;">&#40;</span>rotation.<span style="color: #006633;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
m.<span style="color: #006633;">rotateX</span><span style="color: #009900;">&#40;</span>rotation.<span style="color: #006633;">x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//more 3D transformation here</span><br />
<br />
m.<span style="color: #006633;">translate</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>, offsetZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// just do whatever I would do in normal draw loop</span><br />
PVector l <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PVector<span style="color: #009900;">&#40;</span>m.<span style="color: #006633;">m03</span>,m.<span style="color: #006633;">m13</span>,m.<span style="color: #006633;">m23</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>It&#8217;s basically just reusing the PMatrix3D class which is used internally in 3D transformation in processing, but I&#8217;m so happy not having to figure out the math myself.</p>
<p>More experiments:<br />
<a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-14.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-638" title="picture-14" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-14-300x198.png" alt="picture-14" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-13.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-637" title="picture-13" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-13-300x198.png" alt="picture-13" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-12.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-636" title="picture-12" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-12-300x198.png" alt="picture-12" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-10.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-635" title="picture-10" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-10-300x198.png" alt="picture-10" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-9.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-634" title="picture-9" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-9-300x198.png" alt="picture-9" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-8.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-633" title="picture-8" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-8-300x198.png" alt="picture-8" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-7.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-632" title="picture-7" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-7-300x198.png" alt="picture-7" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-6.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-631" title="picture-6" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-6-300x198.png" alt="picture-6" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-5.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-630" title="picture-5" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-5-300x198.png" alt="picture-5" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-4.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-629" title="picture-4" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-4-300x198.png" alt="picture-4" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-3.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-628" title="picture-3" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-3-300x198.png" alt="picture-3" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-2.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-627" title="picture-2" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-2-300x198.png" alt="picture-2" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-1.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-626" title="picture-1" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-1-300x198.png" alt="picture-1" width="300" height="198" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/i-wish-i-know-more-trigs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storytelling stickers update</title>
		<link>http://leejayxia.com/blog/storytelling-stickers-update/</link>
		<comments>http://leejayxia.com/blog/storytelling-stickers-update/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 22:28:27 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Toy Design]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[RFID]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[Spring 2009]]></category>
		<category><![CDATA[sticker]]></category>
		<category><![CDATA[toy]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=611</guid>
		<description><![CDATA[Wrapping up what&#8217;s happened to the storytelling stickers! THE READER The RFID reader is working! It took a while though. I did some search and ended up taking arduino codes from http://blog.formatlos.de/2008/12/08/arduino-id-12/ featuring the AF_SoftSerial library. It&#8217;s very well written and comprehensive. The scripts added a kicking off step and a disconnection detection as well. [...]]]></description>
			<content:encoded><![CDATA[<p>Wrapping up what&#8217;s happened to the <a href="http://leejayxia.com/blog/toy-design-proposal/">storytelling stickers</a>!</p>
<h3>THE READER</h3>
<p>The RFID reader is working! It took a while though. I did some search and ended up taking arduino codes from <a href="http://blog.formatlos.de/2008/12/08/arduino-id-12/">http://blog.formatlos.de/2008/12/08/arduino-id-12/</a> featuring the <a href="http://www.ladyada.net/make/eshield/AFSoftSerial.zip">AF_SoftSerial library</a>. It&#8217;s very well written and comprehensive. The scripts added a kicking off step and a disconnection detection as well. Great work! A simple processing sketch was made to display the identifier code. </p>
<p><object width="640" height="480"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3933690&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3933690&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="480"></embed></object></p>
<p>The tag needs to be really close to the reader to be recognized, which is fine in my project. But since I probably needs to get reading from both ends of a miniature trumpet/horn, that might not be good enough. I&#8217;m trying to build some antenna for the reader and see if it could extend the accessibility.  </p>
<h3>THE TAG</h3>
<p>The tags arrived too. I ordered 300 raw EM4001 RFID tags (meaning that they come with exposed coil antennae) and unfortunately a lot of them broke. A lot of soldering is ahead! But I got enough to start anyway, like a hundred.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/image019.jpg" rel="lightbox[611]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/04/image019-300x225.jpg" alt="image019" title="image019" width="300" height="225" class="alignnone size-medium wp-image-616" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/image017.jpg" rel="lightbox[611]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/04/image017-300x225.jpg" alt="image017" title="image017" width="300" height="225" class="alignnone size-medium wp-image-615" /></a>&nbsp;<a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/image0251.jpg" rel="lightbox[611]"><img src="http://leejayxia.com/blog/wp-content/uploads/2009/04/image0251-300x225.jpg" alt="image0251" title="image0251" width="300" height="225" class="alignnone size-medium wp-image-617" /></a></p>
<h3>THE SOUND</h3>
<p>I got the <a href="http://www.ladyada.net/make/waveshield/">wave sound shield from Adafruit</a> and finished assembling while procrastinating. But I haven&#8217;t tried to use them because it doesn&#8217;t record to the card and I decided to fall back to use a computer in this phrase.</p>
<p>So now it works like this. Whenever a card/tag/sticker is seen/read, according to the mode an audio clip associated to the tag ID would be recorded or played, by the computer. All sound files are stored on the computer instead of any hardware/memory card as I previously planned. The processing sketch was adapted to keep track of a known card and pick the corresponding sound file to play/record. </p>
<p>[Videos to be uploaded soon]</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ddf.minim.signals.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ddf.minim.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ddf.minim.analysis.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ddf.minim.effects.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.serial.*</span><span style="color: #339933;">;</span><br />
<br />
Serial myPort<span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">boolean</span> connected <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003399;">String</span> activeTag <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Waiting...&quot;</span><span style="color: #339933;">;</span><br />
PFont f <span style="color: #339933;">=</span> createFont<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Helvetica&quot;</span>, <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003399;">Hashtable</span> cards<span style="color: #339933;">;</span><br />
Minim minim<span style="color: #339933;">;</span><br />
AudioInput in<span style="color: #339933;">;</span><br />
AudioRecorder recorder<span style="color: #339933;">;</span><br />
AudioPlayer player<span style="color: #339933;">;</span><br />
<br />
<span style="color: #003399;">String</span> previousCard <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">boolean</span> playMode <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">boolean</span> autoPilot <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connecting...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; myPort <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Serial<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, Serial.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; myPort.<span style="color: #006633;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; cards <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Hashtable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; loadCards<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; minim <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Minim<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; in <span style="color: #339933;">=</span> minim.<span style="color: #006633;">getLineIn</span><span style="color: #009900;">&#40;</span>Minim.<span style="color: #006633;">STEREO</span>, <span style="color: #cc66cc;">2048</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">800</span>,<span style="color: #cc66cc;">600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; fill<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; noStroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; textAlign<span style="color: #009900;">&#40;</span>CENTER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; textFont<span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; text<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WAITING&quot;</span>,width <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, height <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>connected<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; myPort.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'C'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #009900;">&#40;</span>activeTag,width <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, height <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>playMode<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;PLAYING&quot;</span>,width <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, height <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;RECORDING&quot;</span>,width <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, height <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>recorder <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stroke<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>playMode<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>player <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> player.<span style="color: #006633;">left</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line<span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> player.<span style="color: #006633;">left</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span>, i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> player.<span style="color: #006633;">left</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line<span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">150</span> <span style="color: #339933;">+</span> player.<span style="color: #006633;">right</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span>, i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">150</span> <span style="color: #339933;">+</span> player.<span style="color: #006633;">right</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> in.<span style="color: #006633;">bufferSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line<span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> in.<span style="color: #006633;">left</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span>, i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">50</span> <span style="color: #339933;">+</span> in.<span style="color: #006633;">left</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line<span style="color: #009900;">&#40;</span>i, <span style="color: #cc66cc;">150</span> <span style="color: #339933;">+</span> in.<span style="color: #006633;">right</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span>, i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">150</span> <span style="color: #339933;">+</span> in.<span style="color: #006633;">right</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> closePlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>player <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> player.<span style="color: #006633;">isPlaying</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> closeRecorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>recorder <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #666666; font-style: italic;">/* &amp;&amp; recorder.isRecording()*/</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recorder.<span style="color: #006633;">endRecord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recorder.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> loadCards<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; cards.<span style="color: #006633;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>lines <span style="color: #339933;">=</span> loadStrings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;index.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lines <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> lines.<span style="color: #006633;">length</span> <span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> card <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span>lines<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cards.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>card, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> dumpCards<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">PrintWriter</span> writer <span style="color: #339933;">=</span> createWriter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data/index.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Enumeration</span> e <span style="color: #339933;">=</span> cards.<span style="color: #006633;">keys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> e.<span style="color: #006633;">hasMoreElements</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> card <span style="color: #339933;">=</span> e.<span style="color: #006633;">nextElement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; writer.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>card<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; writer.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; writer.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> serialEvent<span style="color: #009900;">&#40;</span>Serial port<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> myString <span style="color: #339933;">=</span> port.<span style="color: #006633;">readStringUntil</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>myString <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; myString <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span>myString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>myString.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connected <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connected~!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>myString.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0000000000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; activeTag <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Disconnected&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>playMode <span style="color: #339933;">&amp;&amp;</span> player <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span>previousCard <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Disconnect from playing&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closePlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span>previousCard <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Disconnect from recording&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closeRecorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; previousCard <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; activeTag <span style="color: #339933;">=</span> myString<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>cards.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>activeTag<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>activeTag,<span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dumpCards<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>autoPilot<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closePlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playMode <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//auto switch to record &nbsp; &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Autopilot: switch to record mode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #666666; font-style: italic;">//found</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>autoPilot<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; playMode <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//auto switch to play&nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closeRecorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Autopilot: switch to play mode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>playMode<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cards.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>activeTag<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span>activeTag <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Start playing new file, disconnect from previous &quot;</span> <span style="color: #339933;">+</span> previousCard<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closePlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;loading &quot;</span> <span style="color: #339933;">+</span> activeTag <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; to play&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player <span style="color: #339933;">=</span> minim.<span style="color: #006633;">loadFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data/&quot;</span> <span style="color: #339933;">+</span> activeTag <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.wav&quot;</span>, <span style="color: #cc66cc;">2048</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; player.<span style="color: #006633;">loop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span>activeTag <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Not recorded yet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #666666; font-style: italic;">//record mode</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>activeTag <span style="color: #339933;">!=</span> previousCard<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span>activeTag <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Start playing new file, disconnect from previous &quot;</span> <span style="color: #339933;">+</span> previousCard<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closePlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closeRecorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recorder <span style="color: #339933;">=</span> minim.<span style="color: #006633;">createRecorder</span><span style="color: #009900;">&#40;</span>in, <span style="color: #0000ff;">&quot;data/&quot;</span> <span style="color: #339933;">+</span> activeTag <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.wav&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recorder.<span style="color: #006633;">beginRecord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; previousCard <span style="color: #339933;">=</span> activeTag<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> stop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; in.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; closePlayer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; closeRecorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; minim.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> keyPressed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>key <span style="color: #339933;">==</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; playMode <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>playMode<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>playMode<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;play mode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;record mode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>key <span style="color: #339933;">==</span> <span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; autoPilot <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>autoPilot<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>autoPilot<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Autopilot: ON&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; println<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Autopilot: OFF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<h3>THE NAME</h3>
<p>Any thoughts on a name for the toy?</p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/storytelling-stickers-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TicTacToe Game with Asterisk</title>
		<link>http://leejayxia.com/blog/tictactoe-game-with-asterisk/</link>
		<comments>http://leejayxia.com/blog/tictactoe-game-with-asterisk/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 21:08:42 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Redial:Interactive Telephony]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[EAGI]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[TicTacToe]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=608</guid>
		<description><![CDATA[and Processing&#8230; Thanks to Dan&#8217;s example codes on the threading multiple callers and socket communication, it&#8217;s not hard to route the AGI scripts to processing. The most effort was actually spent on the player scheduling and game developing (written from scratch). Kinda tired of these white on black UIs but it&#8217;s still the most handy [...]]]></description>
			<content:encoded><![CDATA[<p>and Processing&#8230;</p>
<p>Thanks to <a href="http://www.shiffman.net/p5/asterisk/">Dan&#8217;s example codes</a> on the threading multiple callers and socket communication, it&#8217;s not hard to route the AGI scripts to processing. The most effort was actually spent on the player scheduling and game developing (written from scratch). Kinda tired of these white on black UIs but it&#8217;s still the most handy design for quick prototype.</p>
<p>In the video the game was played between a cellphone and a softphone on Gizmo.</p>
<p><object width="640" height="480"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3951020&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3951020&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="480"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/tictactoe-game-with-asterisk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More experiments with globe</title>
		<link>http://leejayxia.com/blog/more-experiments-with-globe/</link>
		<comments>http://leejayxia.com/blog/more-experiments-with-globe/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 20:51:11 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Mainstreaming Info]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Military Intervention]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[Spring 2009]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=597</guid>
		<description><![CDATA[Some sketches to play with 3D globe and its motion. I have to made this to see if it makes sense at all if I plot the timeline data long the radius of the globe. Next step is to create better visual elements and put in text captions. The graph reads from the center to [...]]]></description>
			<content:encoded><![CDATA[<p>Some sketches to play with 3D globe and its motion. I have to made this to see if it makes sense at all if I plot the timeline data long the radius of the globe. Next step is to create better visual elements and put in text captions.</p>
<p>The graph reads from the center to the outside as from oldest to latest events. The size of the cubes indicates the length of the intervention event.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-14.png" rel="lightbox[597]"><img class="alignnone size-medium wp-image-602" title="e59bbee78987-14" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-14-300x236.png" alt="e59bbee78987-14" width="300" height="236" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-13.png" rel="lightbox[597]"><img class="alignnone size-medium wp-image-601" title="e59bbee78987-13" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-13-300x236.png" alt="e59bbee78987-13" width="300" height="236" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-12.png" rel="lightbox[597]"><img class="alignnone size-medium wp-image-600" title="e59bbee78987-12" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-12-300x236.png" alt="e59bbee78987-12" width="300" height="236" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-11.png" rel="lightbox[597]"><img class="alignnone size-medium wp-image-599" title="e59bbee78987-11" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/e59bbee78987-11-300x236.png" alt="e59bbee78987-11" width="300" height="236" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/us_intervention_globe_time.zip">Download the sketch executable for Mac OS X.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/more-experiments-with-globe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update on mainstreaming info</title>
		<link>http://leejayxia.com/blog/update-on-mainstreaming-info/</link>
		<comments>http://leejayxia.com/blog/update-on-mainstreaming-info/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 13:48:21 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Mainstreaming Info]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[Military Intervention]]></category>
		<category><![CDATA[nation building]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Spring 2009]]></category>
		<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=573</guid>
		<description><![CDATA[I broadened my mainstreaming info project to look into all US military interventions in the past 200 years instead of only nation building attempts for several reasons. After putting all nation building facts together and categorizing them by countries, it&#8217;s still hard for me to reveal some significant patterns among all these attempts for me [...]]]></description>
			<content:encoded><![CDATA[<p>I broadened my mainstreaming info project to look into all US military interventions in the past 200 years instead of only nation building attempts for several reasons.</p>
<p>After putting all nation building facts together and categorizing them by countries, it&#8217;s still hard for me to reveal some significant patterns among all these attempts for me to use as an axis to organize all the verbal materials;</p>
<p>I made the sketch below trying to plot the history events onto the timeline. It turns out that first it would take much longer time for me to verify all the facts and second I don&#8217;t feel confident enough to simply &#8220;tag&#8221; the history events with my shallow understandings for now;</p>
<p>Sketch: military intervention shown on top of the timeline bar, main history events displayed along the side of the bar. (blue &#8211; independence,  red &#8211; controlled by another country,  orange &#8211; dictatorship)</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/nationbuilding_sketch.jpg" rel="lightbox[573]"><img class="alignnone size-medium wp-image-587" title="nationbuilding_sketch" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/nationbuilding_sketch-300x145.jpg" alt="nationbuilding_sketch" width="300" height="145" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/nationbuilding_sketch.jpg" rel="lightbox[573]"></a><a style="text-decoration: none;" href="http://leejayxia.com/blog/wp-content/uploads/2009/03/dominicanr.jpg" rel="lightbox[573]"><img class="alignnone size-medium wp-image-586" title="dominicanr" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/dominicanr-300x48.jpg" alt="dominicanr" width="300" height="48" /></a></p>
<p>This timeline graph is not enough to carry the huge amount of information due to the capacity of information it&#8217;s trying to carry. It&#8217;s not easy to arrive on a simple conclusion from this sea of history data. A visualization is always an illusion, however I do not wish to over simplify the history in this case. I would have to put more texts and labels on the screen. (This is like a common struggle while I&#8217;m designing a visualization. It&#8217;s becoming more like a data mining toolset other than a complete presentation of an idea.)<br />
So the user still have to read through the texts to get more info on a certain event, which is not a bad thing. They could combine the external intervention facts together with country key events to get to their own conclusions, or not. From there I started to think if it would be better to just show the big picture of all military interventions and use nation building as an addition.</p>
<p>The intervention list I&#8217;m using was found here: <a href="http://www.globalpolicy.org/empire/history/interventions.htm">http://www.globalpolicy.org/empire/history/interventions.htm</a>. History commons has another well organized <a href="http://www.historycommons.org/project.jsp?project=US_interventions_project">list of intervention history</a> too. I wrote a quick gantt chart sketch in processing to see how the data look like, and was surprised to find China and Nicaragua to be the two countries with most US intervention in history.</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-41.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-577" title="e59bbee78987-41" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-41-300x187.png" alt="e59bbee78987-41" width="300" height="187" /></a></p>
<p>Next step would be playing back the events in a 3D space to better illustrate the geo location of all these data, and I would like to create more organic visual forms for the history events. Some experiments starting with basic geometry forms:</p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-81.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-581" title="e59bbee78987-81" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-81-300x236.png" alt="e59bbee78987-81" width="300" height="236" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-71.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-580" title="e59bbee78987-71" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-71-300x236.png" alt="e59bbee78987-71" width="300" height="236" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-61.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-579" title="e59bbee78987-61" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-61-300x236.png" alt="e59bbee78987-61" width="300" height="236" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-51.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-578" title="e59bbee78987-51" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-51-300x236.png" alt="e59bbee78987-51" width="300" height="236" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-2.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-576" title="e59bbee78987-2" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-2-300x236.png" alt="e59bbee78987-2" width="300" height="236" /></a> <a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-15.png" rel="lightbox[573]"><img class="alignnone size-medium wp-image-575" title="e59bbee78987-15" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-15-300x236.png" alt="e59bbee78987-15" width="300" height="236" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/update-on-mainstreaming-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visualizing wolfram patterns with monmonmonsters</title>
		<link>http://leejayxia.com/blog/visualizing-wolfram-patterns-with-monmonmonsters/</link>
		<comments>http://leejayxia.com/blog/visualizing-wolfram-patterns-with-monmonmonsters/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 05:59:37 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[The Nature of Code]]></category>
		<category><![CDATA[Cellular automata]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[monster]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Spring 2009]]></category>
		<category><![CDATA[Week8]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=561</guid>
		<description><![CDATA[Interested in creating a simple form of &#8220;stand alone complex&#8221;, I decided to use wolfram&#8217;s one-dimension cellular automata as the underneath engine for the monsters. The color, dancing pattern, dancing amplitude are driven by different sets of CA rules. Play monmon &#8220;CA&#8221; monster here: http://leejayxia.com/processing/monmonmonster_wolfram/ or on openprocessing: http://openprocessing.org/visuals/?visualID=1326]]></description>
			<content:encoded><![CDATA[<p>Interested in creating a simple form of &#8220;stand alone complex&#8221;, I decided to use wolfram&#8217;s one-dimension cellular automata as the underneath engine for the monsters. The color, dancing pattern, dancing amplitude are driven by different sets of CA rules.</p>
<p>Play monmon &#8220;CA&#8221; monster here: <a href="http://leejayxia.com/processing/monmonmonster_wolfram/">http://leejayxia.com/processing/monmonmonster_wolfram/</a></p>
<p>or on openprocessing: <a href="http://openprocessing.org/visuals/?visualID=1326">http://openprocessing.org/visuals/?visualID=1326</a> </p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-14.png" rel="lightbox[561]"><img class="alignnone size-full wp-image-569" title="e59bbee78987-14" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-14.png" alt="e59bbee78987-14" width="980" height="232" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-12.png" rel="lightbox[561]"><img class="alignnone size-full wp-image-567" title="e59bbee78987-12" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-12.png" alt="e59bbee78987-12" width="980" height="232" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-11.png" rel="lightbox[561]"><img class="alignnone size-full wp-image-566" title="e59bbee78987-11" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-11.png" alt="e59bbee78987-11" width="980" height="232" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-7.png" rel="lightbox[561]"><img class="alignnone size-full wp-image-564" title="e59bbee78987-7" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-7.png" alt="e59bbee78987-7" width="980" height="232" /></a></p>
<p><a href="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-5.png" rel="lightbox[561]"><img class="alignnone size-full wp-image-562" title="e59bbee78987-5" src="http://leejayxia.com/blog/wp-content/uploads/2009/03/e59bbee78987-5.png" alt="e59bbee78987-5" width="980" height="232" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/visualizing-wolfram-patterns-with-monmonmonsters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

