<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Sensor Watch: LED Control</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>
<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 id="projectrow">
  <td id="projectalign">
   <div id="projectname">Sensor Watch<span id="projectnumber">&#160;0.0.2</span>
   </div>
   <div id="projectbrief">A board replacement for the classic Casio F-91W wristwatch, powered by a Microchip SAM L22 microcontroller.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></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">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">LED Control</div></div>
</div><!--header-->
<div class="contents">

<p>This section covers functions related to the bi-color red/green LED mounted behind the LCD.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga86ce31dc95137ed41983fb7c6af5502a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__led.html#ga86ce31dc95137ed41983fb7c6af5502a">watch_enable_leds</a> (void)</td></tr>
<tr class="memdesc:ga86ce31dc95137ed41983fb7c6af5502a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enables the bi-color LED.  <a href="group__led.html#ga86ce31dc95137ed41983fb7c6af5502a">More...</a><br /></td></tr>
<tr class="separator:ga86ce31dc95137ed41983fb7c6af5502a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga883bf171196fb5a7a57ef727dca6e04a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__led.html#ga883bf171196fb5a7a57ef727dca6e04a">watch_disable_leds</a> (void)</td></tr>
<tr class="memdesc:ga883bf171196fb5a7a57ef727dca6e04a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Disables the LEDs.  <a href="group__led.html#ga883bf171196fb5a7a57ef727dca6e04a">More...</a><br /></td></tr>
<tr class="separator:ga883bf171196fb5a7a57ef727dca6e04a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga042bcc9220ab05d1de8389cf0067511b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__led.html#ga042bcc9220ab05d1de8389cf0067511b">watch_set_led_color</a> (uint8_t red, uint8_t green)</td></tr>
<tr class="memdesc:ga042bcc9220ab05d1de8389cf0067511b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the LED to a custom color by modulating each output's duty cycle.  <a href="group__led.html#ga042bcc9220ab05d1de8389cf0067511b">More...</a><br /></td></tr>
<tr class="separator:ga042bcc9220ab05d1de8389cf0067511b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga36d89031d8e8813dfab5f6cff9c6ee40"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__led.html#ga36d89031d8e8813dfab5f6cff9c6ee40">watch_set_led_red</a> (void)</td></tr>
<tr class="memdesc:ga36d89031d8e8813dfab5f6cff9c6ee40"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the red LED to full brightness, and turns the green LED off.  <a href="group__led.html#ga36d89031d8e8813dfab5f6cff9c6ee40">More...</a><br /></td></tr>
<tr class="separator:ga36d89031d8e8813dfab5f6cff9c6ee40"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab01a29900ddc5315c0e752e63d748f41"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__led.html#gab01a29900ddc5315c0e752e63d748f41">watch_set_led_green</a> (void)</td></tr>
<tr class="memdesc:gab01a29900ddc5315c0e752e63d748f41"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the green LED to full brightness, and turns the red LED off.  <a href="group__led.html#gab01a29900ddc5315c0e752e63d748f41">More...</a><br /></td></tr>
<tr class="separator:gab01a29900ddc5315c0e752e63d748f41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga51ba53c3281ad8724d98af27eacc3de0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__led.html#ga51ba53c3281ad8724d98af27eacc3de0">watch_set_led_yellow</a> (void)</td></tr>
<tr class="memdesc:ga51ba53c3281ad8724d98af27eacc3de0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets both red and green LEDs to full brightness.  <a href="group__led.html#ga51ba53c3281ad8724d98af27eacc3de0">More...</a><br /></td></tr>
<tr class="separator:ga51ba53c3281ad8724d98af27eacc3de0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8619f040ff7364285398412a4c420cae"><td class="memItemLeft" align="right" valign="top"><a id="ga8619f040ff7364285398412a4c420cae" name="ga8619f040ff7364285398412a4c420cae"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>watch_set_led_off</b> (void)</td></tr>
<tr class="memdesc:ga8619f040ff7364285398412a4c420cae"><td class="mdescLeft">&#160;</td><td class="mdescRight">Turns both the red and the green LEDs off. <br /></td></tr>
<tr class="separator:ga8619f040ff7364285398412a4c420cae"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >This section covers functions related to the bi-color red/green LED mounted behind the LCD. </p>
<p >The SAM L22 is an exceedingly power efficient chip, whereas the LED's are relatively power- hungry. The green LED, at full power, consumes more power than the whole chip in active mode, and the red LED consumes about twelve times as much power! The LED's should thus be used only sparingly in order to preserve battery life. </p><dl class="section note"><dt>Note</dt><dd>Some watches use a red/blue LED instead of a red/green LED. You will be able to determine this easily when you double tap the reset button: if the pulsing bootloader LED is red, you have a red/green edition; if it is blue, you have a red/blue edition. For red/blue watches, build your project with the command <code>make LED=BLUE</code>, and the watch library will automatically swap the pins so that watch_set_led_red sets the red LED, and watch_set_led_green sets the blue one. </dd></dl>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga883bf171196fb5a7a57ef727dca6e04a" name="ga883bf171196fb5a7a57ef727dca6e04a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga883bf171196fb5a7a57ef727dca6e04a">&#9670;&#160;</a></span>watch_disable_leds()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void watch_disable_leds </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Disables the LEDs. </p>
<dl class="section note"><dt>Note</dt><dd>This method will also disable the buzzer, since the buzzer and LED both make use of the same peripheral to drive their PWM behavior. </dd></dl>

</div>
</div>
<a id="ga86ce31dc95137ed41983fb7c6af5502a" name="ga86ce31dc95137ed41983fb7c6af5502a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga86ce31dc95137ed41983fb7c6af5502a">&#9670;&#160;</a></span>watch_enable_leds()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void watch_enable_leds </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enables the bi-color LED. </p>
<dl class="section note"><dt>Note</dt><dd>The TCC peripheral that drives the LEDs does not run in STANDBY mode — but the outputs do! This means that if you set either red, green or both LEDs to full power, they will shine even when your app is asleep. If, however, you set a custom color using watch_set_led_color, the color will not display correctly in STANDBY mode. You will need to keep your app running while the LED is on. </dd></dl>

</div>
</div>
<a id="ga042bcc9220ab05d1de8389cf0067511b" name="ga042bcc9220ab05d1de8389cf0067511b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga042bcc9220ab05d1de8389cf0067511b">&#9670;&#160;</a></span>watch_set_led_color()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void watch_set_led_color </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>red</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>green</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets the LED to a custom color by modulating each output's duty cycle. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">red</td><td>The red value from 0-255. </td></tr>
    <tr><td class="paramname">green</td><td>The green value from 0-255. If your watch has a red/blue LED, this will be the blue value. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>If you are displaying a custom color, you will need to prevent your app from going to sleep while the LED is on; otherwise, the color will not display correctly. You can do this by returning false in your app_loop method. </dd></dl>

</div>
</div>
<a id="gab01a29900ddc5315c0e752e63d748f41" name="gab01a29900ddc5315c0e752e63d748f41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab01a29900ddc5315c0e752e63d748f41">&#9670;&#160;</a></span>watch_set_led_green()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void watch_set_led_green </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets the green LED to full brightness, and turns the red LED off. </p>
<p >Of the two LED's in the RG bi-color LED, the green LED is the more power-efficient one (~0.44 mA). </p><dl class="section note"><dt>Note</dt><dd>If your watch has a red/blue LED, this method will set the LED to blue. </dd></dl>

</div>
</div>
<a id="ga36d89031d8e8813dfab5f6cff9c6ee40" name="ga36d89031d8e8813dfab5f6cff9c6ee40"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga36d89031d8e8813dfab5f6cff9c6ee40">&#9670;&#160;</a></span>watch_set_led_red()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void watch_set_led_red </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets the red LED to full brightness, and turns the green LED off. </p>
<p >Of the two LED's in the RG bi-color LED, the red LED is the less power-efficient one (~4.5 mA). </p>

</div>
</div>
<a id="ga51ba53c3281ad8724d98af27eacc3de0" name="ga51ba53c3281ad8724d98af27eacc3de0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51ba53c3281ad8724d98af27eacc3de0">&#9670;&#160;</a></span>watch_set_led_yellow()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void watch_set_led_yellow </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets both red and green LEDs to full brightness. </p>
<p >The total current draw between the two LED's in this mode will be ~5 mA, which is more than the watch draws in any other mode. Take care not to drain the battery. </p><dl class="section note"><dt>Note</dt><dd>If your watch has a red/blue LED, this method will set the LED to pink. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>