mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Update docs
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.6"/>
|
||||
<title>ArduinoLibs: Cylon Eyes Example</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
@@ -29,7 +30,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.1.2 -->
|
||||
<!-- Generated by Doxygen 1.8.6 -->
|
||||
<script type="text/javascript">
|
||||
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
</script>
|
||||
@@ -78,16 +79,16 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
<div class="title">Cylon Eyes Example </div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><p>This example shows how to use the <a class="el" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a> class to simulate the Cylon eye effect from Battlestar Galactica. Digital outputs are used to drive six LED's in a back and forth motion, using the following schematic:</p>
|
||||
<div class="textblock"><p>This example shows how to use the <a class="el" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence. ">ChaseLEDs</a> class to simulate the Cylon eye effect from Battlestar Galactica. Digital outputs are used to drive six LED's in a back and forth motion, using the following schematic:</p>
|
||||
<div class="image">
|
||||
<img src="Cylon.png" alt="Cylon.png"/>
|
||||
</div>
|
||||
<p>We start by including the <a class="el" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a> class:</p>
|
||||
<p>We start by including the <a class="el" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence. ">ChaseLEDs</a> class:</p>
|
||||
<div class="fragment"><div class="line"><span class="preprocessor">#include <ChaseLEDs.h></span></div>
|
||||
</div><!-- fragment --></p>
|
||||
<p>The next step is to define the pins that the chase will run over:</p>
|
||||
<div class="fragment"><div class="line">byte pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5};</div>
|
||||
<div class="line"><a class="code" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a> cylonEyes(pins, <span class="keyword">sizeof</span>(pins), 100);</div>
|
||||
<div class="line"><a class="code" href="classChaseLEDs.html">ChaseLEDs</a> cylonEyes(pins, <span class="keyword">sizeof</span>(pins), 100);</div>
|
||||
</div><!-- fragment --></p>
|
||||
<p>The chase runs from the first pin to the sixth pin and back again, with each LED lit for 100 milliseconds before moving onto the next one. To complete the example, we need to call <a class="el" href="classChaseLEDs.html#a8745fa6b9f33b6c6274a563dd4dea786">ChaseLEDs::loop()</a> each time around our main loop to cause the chase to run:</p>
|
||||
<div class="fragment"><div class="line"><span class="keywordtype">void</span> loop() {</div>
|
||||
@@ -95,22 +96,22 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --></p>
|
||||
<p>While this example uses only six pins, it can be easily extended to any number of pins by modifying the <code>pins</code> array and altering the schematic accordingly.</p>
|
||||
<p>So far we are chasing only a single LED. We could change this to chase two adjacent LED's instead by defining a new <code>CylonChase</code> class that inherits from <a class="el" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a>:</p>
|
||||
<div class="fragment"><div class="line"><span class="keyword">class </span>CylonChase : <span class="keyword">public</span> <a class="code" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a></div>
|
||||
<p>So far we are chasing only a single LED. We could change this to chase two adjacent LED's instead by defining a new <code>CylonChase</code> class that inherits from <a class="el" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence. ">ChaseLEDs</a>:</p>
|
||||
<div class="fragment"><div class="line"><span class="keyword">class </span>CylonChase : <span class="keyword">public</span> <a class="code" href="classChaseLEDs.html">ChaseLEDs</a></div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"><span class="keyword">public</span>:</div>
|
||||
<div class="line"> CylonChase(<span class="keyword">const</span> byte *pins, <span class="keywordtype">int</span> num, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> advanceTime)</div>
|
||||
<div class="line"> : <a class="code" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a>(pins, num, advanceTime) {}</div>
|
||||
<div class="line"> : <a class="code" href="classChaseLEDs.html">ChaseLEDs</a>(pins, num, advanceTime) {}</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"><span class="keyword">protected</span>:</div>
|
||||
<div class="line"> <span class="keywordtype">void</span> <a class="code" href="classChaseLEDs.html#aa0f4e0bd07dd65ee5574e894a612486b" title="Advances to the next LED in sequence, turning off prevPin, and turning on nextPin.">advance</a>(byte prevPin, byte nextPin) {</div>
|
||||
<div class="line"> digitalWrite(<a class="code" href="classChaseLEDs.html#a27c460fcb341c2dc2fcf9341616eb525" title="Returns the pin that is n steps back in the sequence.">previousPin</a>(2), LOW);</div>
|
||||
<div class="line"> <span class="keywordtype">void</span> <a class="code" href="classChaseLEDs.html#aa0f4e0bd07dd65ee5574e894a612486b">advance</a>(byte prevPin, byte nextPin) {</div>
|
||||
<div class="line"> digitalWrite(<a class="code" href="classChaseLEDs.html#a27c460fcb341c2dc2fcf9341616eb525">previousPin</a>(2), LOW);</div>
|
||||
<div class="line"> digitalWrite(prevPin, HIGH);</div>
|
||||
<div class="line"> digitalWrite(nextPin, HIGH);</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line">};</div>
|
||||
</div><!-- fragment --></p>
|
||||
<p>The important part is the implementation of the <code>advance()</code> method, which overrides <a class="el" href="classChaseLEDs.html#aa0f4e0bd07dd65ee5574e894a612486b" title="Advances to the next LED in sequence, turning off prevPin, and turning on nextPin.">ChaseLEDs::advance()</a> to provide our own scheme for lighting the LED's each time the chase advances. We use <a class="el" href="classChaseLEDs.html#a27c460fcb341c2dc2fcf9341616eb525" title="Returns the pin that is n steps back in the sequence.">ChaseLEDs::previousPin()</a> to get the pin that is 2 steps back in the sequence, set it to LOW, and then set the previous pin (1 step back) and the next pin to HIGH. All that remains is to change our chase initialization to use the new class:</p>
|
||||
<p>The important part is the implementation of the <code>advance()</code> method, which overrides <a class="el" href="classChaseLEDs.html#aa0f4e0bd07dd65ee5574e894a612486b" title="Advances to the next LED in sequence, turning off prevPin, and turning on nextPin. ">ChaseLEDs::advance()</a> to provide our own scheme for lighting the LED's each time the chase advances. We use <a class="el" href="classChaseLEDs.html#a27c460fcb341c2dc2fcf9341616eb525" title="Returns the pin that is n steps back in the sequence. ">ChaseLEDs::previousPin()</a> to get the pin that is 2 steps back in the sequence, set it to LOW, and then set the previous pin (1 step back) and the next pin to HIGH. All that remains is to change our chase initialization to use the new class:</p>
|
||||
<div class="fragment"><div class="line">byte pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5};</div>
|
||||
<div class="line">CylonChase cylonEyes(pins, <span class="keyword">sizeof</span>(pins), 100);</div>
|
||||
</div><!-- fragment --></p>
|
||||
@@ -143,18 +144,18 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
<div class="line"></div>
|
||||
<div class="line"><span class="preprocessor">#include <ChaseLEDs.h></span></div>
|
||||
<div class="line"></div>
|
||||
<div class="line"><span class="keyword">class </span>CylonChase : <span class="keyword">public</span> <a class="code" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a></div>
|
||||
<div class="line"><span class="keyword">class </span>CylonChase : <span class="keyword">public</span> <a class="code" href="classChaseLEDs.html">ChaseLEDs</a></div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"><span class="keyword">public</span>:</div>
|
||||
<div class="line"> CylonChase(<span class="keyword">const</span> byte *pins, <span class="keywordtype">int</span> num, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> advanceTime)</div>
|
||||
<div class="line"> : <a class="code" href="classChaseLEDs.html" title="Chase LED's on output pins in a defined sequence.">ChaseLEDs</a>(pins, num, advanceTime) {}</div>
|
||||
<div class="line"> : <a class="code" href="classChaseLEDs.html">ChaseLEDs</a>(pins, num, advanceTime) {}</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"><span class="keyword">protected</span>:</div>
|
||||
<div class="line"> <span class="keywordtype">void</span> <a class="code" href="classChaseLEDs.html#aa0f4e0bd07dd65ee5574e894a612486b" title="Advances to the next LED in sequence, turning off prevPin, and turning on nextPin.">advance</a>(byte prevPin, byte nextPin) {</div>
|
||||
<div class="line"> digitalWrite(<a class="code" href="classChaseLEDs.html#a27c460fcb341c2dc2fcf9341616eb525" title="Returns the pin that is n steps back in the sequence.">previousPin</a>(2), LOW);</div>
|
||||
<div class="line"> <span class="keywordtype">void</span> <a class="code" href="classChaseLEDs.html#aa0f4e0bd07dd65ee5574e894a612486b">advance</a>(byte prevPin, byte nextPin) {</div>
|
||||
<div class="line"> digitalWrite(<a class="code" href="classChaseLEDs.html#a27c460fcb341c2dc2fcf9341616eb525">previousPin</a>(2), LOW);</div>
|
||||
<div class="line"> analogWrite(prevPin, 32);</div>
|
||||
<div class="line"> digitalWrite(nextPin, HIGH);</div>
|
||||
<div class="line"> <a class="code" href="classChaseLEDs.html#af560270f72302c19fb7f95002089c9d7" title="Sets the number of milliseconds to advance between LED's to advanceTime.">setAdvanceTime</a>(map(analogRead(A0), 0, 1023, 25, 250));</div>
|
||||
<div class="line"> <a class="code" href="classChaseLEDs.html#af560270f72302c19fb7f95002089c9d7">setAdvanceTime</a>(map(analogRead(A0), 0, 1023, 25, 250));</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line">};</div>
|
||||
<div class="line"></div>
|
||||
@@ -170,9 +171,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
</div><!-- fragment --> </div></div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated on Sun Sep 29 2013 09:30:46 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
|
||||
Generated on Thu Mar 12 2015 19:02:05 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||||
</a> 1.8.1.2
|
||||
</a> 1.8.6
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user