Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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.11"/>
<title>arduino-pin-toggler: arduino-pin-toggler</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">arduino-pin-toggler
</div>
<div id="projectbrief">Toggle pins on an arduino at variable rates using interrupts</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li class="current"><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">arduino-pin-toggler </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="Introduction"></a>
Introduction</h1>
<p>This Arduino library manages the toggling of arbitary pins at controllable rates. For example, it can be used to flash an LED at different speeds according to the state of your device.</p>
<p>It works using interrupts and is designed to be lightweight when running, so will not interfere with existing code.</p>
<p>This library requires exclusive usage of TIMER1 so is incompatible with libraries that also use this timer.</p>
<h1><a class="anchor" id="Usage"></a>
Usage</h1>
<p>Include the class by adding <code>#include <<a class="el" href="pin_toggler_8h.html" title="Contains all the code for the arduino-pin-toggler library. ">pinToggler.h</a>></code> to your sketch.</p>
<p>Init the class by passing it an array of pins that will be toggled. E.g. </p><pre class="fragment">int pins[3] = {13, A4, A5};
pinToggler<3>::init(pins);
</pre><p>The template parameter (<code><3></code> above) defines the total number of pins being controlled.</p>
<p>These pins will start <code>LOW</code>, not toggling.</p>
<p>To start the toggling, set their speed to <code>OFF</code>, <code>SLOW</code>, <code>MEDIUM</code>, <code>FAST</code> or <code>MAX</code>. E.g. </p><pre class="fragment">pinToggler<3>::setFlashRate(0, SLOW);
</pre><p>N.B. The template parameter (here <code><3></code>) must match the one used in <a class="el" href="classpin_toggler.html#aa58211817601d0e2dd413eb63e41f773" title="Initiate the pins and TIMER1. ">pinToggler::init()</a> or this will throw an error. Also the LED parameter in <a class="el" href="classpin_toggler.html#a42ae0ac4f841dae592195f26bffb109e" title="Change the flash rate of an LED managed by this routine. ">pinToggler::setFlashRate</a> refers to the pins passed to <a class="el" href="classpin_toggler.html#aa58211817601d0e2dd413eb63e41f773" title="Initiate the pins and TIMER1. ">pinToggler::init()</a>, zero-indexed in the order that they appeared in in the array.</p>
<p>The speeds refer to fractions of the max speed, defined by <a class="el" href="pin_toggler_8h.html#a1097b75ec2a0f9ad2e6d4f6c4500d224" title="How often the ISR will trigger. ">FLASH_FREQ_HZ</a>.</p>
<dl class="section warning"><dt>Warning</dt><dd>Note that all the function calls here are static members of the class. Although a class object is created, this happens internally. For memory management purposes, be aware that this class allocates <code>3 * numPins</code> bytes on the heap. Thus, to avoid memory framentation, <a class="el" href="classpin_toggler.html#aa58211817601d0e2dd413eb63e41f773" title="Initiate the pins and TIMER1. ">pinToggler::init()</a> should be called as early in your code as possible.</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Charles Baynham 2016 </dd></dl>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
a8fd7f682This file is pinned to the selected release. Download the original to open it in your design tool.