<?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>I am ShadowLord&#187; TouchShield Slide</title>
	<atom:link href="http://iamshadowlord.com/category/projects/touchshield-slide/feed" rel="self" type="application/rss+xml" />
	<link>http://iamshadowlord.com</link>
	<description>Interesting to me</description>
	<lastBuildDate>Mon, 26 Mar 2012 03:41:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>TouchShield Slide Two-way Communications</title>
		<link>http://iamshadowlord.com/2010/03/touchshield-slide-two-way-communications.html</link>
		<comments>http://iamshadowlord.com/2010/03/touchshield-slide-two-way-communications.html#comments</comments>
		<pubDate>Sun, 21 Mar 2010 09:26:57 +0000</pubDate>
		<dc:creator>Hans</dc:creator>
				<category><![CDATA[TouchShield Slide]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[liquidware]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[serial]]></category>

		<guid isPermaLink="false">http://iamshadowlord.com/?p=118</guid>
		<description><![CDATA[Over last summer, I got the GamePack from Liquidware which includes a touch screen display, joystick, microcontroller, and battery pack. With this kit you can make a GameBoy from scratch. With some blood, sweat, and tears, I was able to re-create some games like Asteroids and Tetris. The touch screen is called the TouchShield Slide [...]]]></description>
			<content:encoded><![CDATA[<p>Over last summer, I got the <a title="Game Kit from Liquid Ware" href="http://www.liquidware.com/shop/show/GMP/GamePack" target="_blank">GamePack</a> from Liquidware which includes a touch screen display, joystick, microcontroller, and battery pack. With this kit you can make a GameBoy from scratch. With some blood, sweat, and tears, I was able to re-create some games like <a title="Asteriods game for TouchShield Slide and InputShield from LiquidWare" href="http://www.liquidware.com/apps/show/73" target="_blank">Asteroids</a> and Tetris.</p>
<p>The touch screen is called the TouchShield Slide which is a 320×240 OLED and resistive touch screen. The screen also has a microcontroller that is Arduino compatible and expands your program space. Since the screen is really a microcontroller in disguise, it can be used for many types of projects. Overall I am very happy with the screen, but I realized I didn&#8217;t know how to use it very well. I set out to learn and develop a protocol / reusable library that allows the screen to talk to a microcontroller and vice-verse. So I wanted to take a moment and explain what I learned &#8211; maybe you can get going faster than I did.</p>
<p><em><strong>The Goal</strong></em></p>
<p>My goal is to be able to display data on the screen that has been received from another device. The data requested would be initiated by a touch on the screen. The protocol has to be consistent and reliable, while being flexible enough to be the basis for future projects.</p>
<div id="attachment_119" class="wp-caption aligncenter" style="width: 556px"><a title="TouchShield Slide Touch Screen, OLED display at Liquidware" href="http://www.liquidware.com/shop/show/TSL/TouchShield+Slide" target="_blank"><img class="size-full wp-image-119" title="Touch -&gt; TouchShield Slide -&gt; Arduino -&gt; TouchShield Slide" src="http://iamshadowlord.com/wp-content/uploads/2010/03/System-Overview.jpg" alt="Touch -&gt; TouchShield Slide -&gt; Arduino -&gt; TouchShield Slide" width="546" height="386" /></a><p class="wp-caption-text">Touch -&gt; TouchShield Slide -&gt; Arduino -&gt; TouchShield Slide</p></div>
<p><strong><em>Programming Tips and Tricks</em></strong></p>
<p>I found quite a few libraries and resources on <a title="TouchShield wiki" href="http://www.liquidware.com/wikipages/name/TouchShield" target="_blank">liquidware.com</a>.  I also discovered quite a few important things through my trial and error. My biggest frustration was with programming and figuring out the IDE. Here are some tips.</p>
<ul>
<li>To program the screen use the <a title="Antipasto Arduino IDE" href="http://www.liquidware.com/wikipages/1" target="_blank">Antipasto Arduino / Aardvark IDE</a></li>
<li>Program the screen and Arduino separately - make sure the IDE has the proper device selected</li>
<li>To put the screen in program mode, press the switch beside the power connector &#8211; it&#8217;s in program mode when the LED on the backside is red</li>
</ul>
<p><strong><em>TouchShield Slide Serial</em></strong></p>
<p>Serial data sent and received by the TouchShield Slide uses the hardware serial lines.</p>
<p>To setup the serial connection, place this line in your setup code block:</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:580px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">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></div></div>
<p>Now you can read and write to and from the serial buffer. To read in a whole string, use a byte array to store bytes from the serial buffer when serial data is available. To write to the serial buffer, simply use serial print.</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:580px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333;">char</span> charIn <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
byte i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">char</span> stringIn<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">32</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
charIn <span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
stringIn<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> charIn<span style="color: #339933;">;</span><br />
i <span style="color: #339933;">+=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;A&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><strong><em>Arduino Serial</em></strong></p>
<p>On the Arduino side, you have to use some form of Software Serial that sends and receives data on Pins 2/3. I have found that the Adafruit SoftSerial Library, &#8220;AFSoftSerial.h&#8221;, works the best. It seems to be reliable and produce consistent results when talking to the TouchShield Slide. Reading and writing from a software  serial buffer is about the same as a hardware one with this library.</p>
<p>To use software serial, follow these steps:</p>
<ul>
<li>Include the &#8220;AFSoftSerial.h&#8221; library in your Arduino code header space</li>
<li>Define the RX and TX pins</li>
<li>Instantiate the software serial</li>
<li>Initiate the software serial line</li>
</ul>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:580px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include &lt;AFSoftSerial.h&gt;</span><br />
<br />
<span style="color: #339933;">#define RX_PIN &nbsp;3</span><br />
<span style="color: #339933;">#define TX_PIN &nbsp;2</span><br />
<br />
AFSoftSerial touchSerial <span style="color: #339933;">=</span> &nbsp;AFSoftSerial<span style="color: #009900;">&#40;</span>RX_PIN<span style="color: #339933;">,</span> TX_PIN<span style="color: #009900;">&#41;</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> <span style="color: #009900;">&#123;</span><br />
touchSerial.<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 />
<span style="color: #009900;">&#125;</span></div></div>
<p><em><strong>Demo Project</strong></em></p>
<p>I took a moment to put together all of the things that I learned into a quick demo project. This project displays a random number on the screen. The random number is being generated by an Arduino, sent via serial, and requested by a touch of the TouchShield Slide.</p>
<p>Visit Liquidware&#8217;s <a title="Liquidware App Store" href="http://www.liquidware.com/apps/show/80" target="_blank">App Store</a> to download the source code and library for this demo project.</p>
<div id="attachment_122" class="wp-caption aligncenter" style="width: 506px"><a title="Download the project source code from the app store liquidware.com" href="http://www.liquidware.com/apps/show/80" target="_blank"><img class="size-full wp-image-122 " title="Random Number from Arduino Displayed after Detecting a Touch" src="http://iamshadowlord.com/wp-content/uploads/2010/03/Touch.jpg" alt="Random Number from Arduino Displayed after Detecting a Touch" width="496" height="297" /></a><p class="wp-caption-text">Random Number from Arduino Displayed after Detecting a Touch</p></div>
]]></content:encoded>
			<wfw:commentRss>http://iamshadowlord.com/2010/03/touchshield-slide-two-way-communications.html/feed</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>

