Files
Forairaaaaa fb78eb0e89 rename
2023-02-13 15:47:41 +08:00

153 lines
9.4 KiB
HTML

<!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">
<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.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Core2 for AWS IoT Kit BSP: Button (virtual)</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" />
<link href="custom.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="projectlogo"><img alt="Logo" src="AWS_logo_RGB.png"/></td>
<td id="projectalign">
<div id="projectname">Core2 for AWS IoT Kit BSP<span id="projectnumber">&#160;1.5.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'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>
<!-- 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><!-- top -->
<div><div class="header">
<div class="headertitle"><div class="title">Button (virtual) </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p >The button library provides convenience functions to interact with the virtual buttons drawn over specified areas of the front of the device. There are three virtual buttons aligned to the circles etched on the front of the Core2 for AWS IoT Kit reference hardware.</p>
<p ><a class="anchor" id="btn"></a></p>
<p >To enable this feature using KConfig, use the command <code>pio run --environment core2foraws --target menuconfig</code> from within the root of the project directory in your <a href="/en/blinky-hello-world/prerequisites.html#open-the-platformio-cli-terminal-window">PlatformIO terminal window</a> and go to the menu <code>Component Config --&gt; Core2 for AWS features</code> to set the features you want to enable.</p>
<h1><a class="anchor" id="button_example"></a>
Example</h1>
<p >The following example initializes the Core2 for AWS, which initializes the PMU for the battery and other user enabled hardware features — such as the FT6336U and virtual touch buttons. It then creates a FreeRTOS task of priority 1 that prints "MIDDLE PRESSED!" using the ESP logger if the middle button touch is pressed.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;freertos/FreeRTOS.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;freertos/task.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &quot;esp_log.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="core2for_a_w_s_8h.html">core2forAWS.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code hl_define" href="i2c__device_8c.html#afc3d101f633a076cc1ca84b85b6224b2">TAG</a> = <span class="stringliteral">&quot;EXAMPLE&quot;</span>;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> button_task(<span class="keywordtype">void</span>* pvParameters){</div>
<div class="line"> <span class="keywordflow">for</span>(;;){</div>
<div class="line"> <span class="keywordflow">if</span> (<a class="code hl_function" href="button_8c.html#acf2b76f9c6fe8e6f8ac65ff1eff8ccdd">Button_WasPressed</a>(<a class="code hl_variable" href="core2for_a_w_s_8c.html#a49b277909900db7e85d6be2841301fe7">button_middle</a>)) {</div>
<div class="line"> ESP_LOGI(<a class="code hl_define" href="i2c__device_8c.html#afc3d101f633a076cc1ca84b85b6224b2">TAG</a>, <span class="stringliteral">&quot;MIDDLE PRESSED!&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> vTaskDelay(pdMS_TO_TICKS(80));</div>
<div class="line"> }</div>
<div class="line"> vTaskDelete(NULL); <span class="comment">// Should never get to here...</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> app_main(<span class="keywordtype">void</span>){</div>
<div class="line"> <a class="code hl_function" href="core2for_a_w_s_8c.html#a3d850a3f56bbe0685b60726d8b53bece">Core2ForAWS_Init</a>();</div>
<div class="line"> </div>
<div class="line"> xTaskCreatePinnedToCore(button_task, <span class="stringliteral">&quot;buttonTask&quot;</span>, configMINIMAL_STACK_SIZE * 3, NULL, 1, NULL, 1); </div>
<div class="line">}</div>
<div class="ttc" id="abutton_8c_html_acf2b76f9c6fe8e6f8ac65ff1eff8ccdd"><div class="ttname"><a href="button_8c.html#acf2b76f9c6fe8e6f8ac65ff1eff8ccdd">Button_WasPressed</a></div><div class="ttdeci">uint8_t Button_WasPressed(Button_t *button)</div><div class="ttdoc">See if the specified button was pressed.</div><div class="ttdef"><b>Definition:</b> button.c:43</div></div>
<div class="ttc" id="acore2for_a_w_s_8c_html_a3d850a3f56bbe0685b60726d8b53bece"><div class="ttname"><a href="core2for_a_w_s_8c.html#a3d850a3f56bbe0685b60726d8b53bece">Core2ForAWS_Init</a></div><div class="ttdeci">void Core2ForAWS_Init(void)</div><div class="ttdoc">Initializes the power chip with default values, enables battery charging, and initializes all enabled...</div><div class="ttdef"><b>Definition:</b> core2forAWS.c:32</div></div>
<div class="ttc" id="acore2for_a_w_s_8c_html_a49b277909900db7e85d6be2841301fe7"><div class="ttname"><a href="core2for_a_w_s_8c.html#a49b277909900db7e85d6be2841301fe7">button_middle</a></div><div class="ttdeci">Button_t * button_middle</div><div class="ttdoc">Middle virtual touch button.</div><div class="ttdef"><b>Definition:</b> core2forAWS.c:86</div></div>
<div class="ttc" id="acore2for_a_w_s_8h_html"><div class="ttname"><a href="core2for_a_w_s_8h.html">core2forAWS.h</a></div><div class="ttdoc">Functions to initialize and access Core2 for AWS IoT Kit hardware features.</div></div>
<div class="ttc" id="ai2c__device_8c_html_afc3d101f633a076cc1ca84b85b6224b2"><div class="ttname"><a href="i2c__device_8c.html#afc3d101f633a076cc1ca84b85b6224b2">TAG</a></div><div class="ttdeci">#define TAG</div><div class="ttdef"><b>Definition:</b> i2c_device.c:10</div></div>
</div><!-- fragment --><h1><a class="anchor" id="button_enumerated_type_definitions"></a>
Enumerated Type Definitions</h1>
<ul>
<li><a class="el" href="button_pressevent_enum.html">PressEvent</a> <br />
</li>
</ul>
<h1><a class="anchor" id="button_structs"></a>
Structs</h1>
<ul>
<li><a class="el" href="button_button_t_struct.html">Button_t</a> <br />
</li>
</ul>
<h1><a class="anchor" id="button_variables"></a>
Variables</h1>
<ul>
<li><a class="el" href="button_left_variable.html">button_left</a> <br />
</li>
<li><a class="el" href="button_middle_variable.html">button_middle</a> <br />
</li>
<li><a class="el" href="button_right_variable.html">button_right</a> <br />
</li>
</ul>
<h1><a class="anchor" id="button_functions"></a>
Functions</h1>
<ul>
<li><a class="el" href="button_init_function.html">Button_Init</a> <br />
</li>
<li><a class="el" href="button_attach_function.html">Button_Attach</a> <br />
</li>
<li><a class="el" href="button_waspressed_function.html">Button_WasPressed</a> <br />
</li>
<li><a class="el" href="button_wasreleased_function.html">Button_WasReleased</a> <br />
</li>
<li><a class="el" href="button_ispress_function.html">Button_IsPress</a> <br />
</li>
<li><a class="el" href="button_isrelease_function.html">Button_IsRelease</a> <br />
</li>
<li><a class="el" href="button_waslongpress_function.html">Button_WasLongPress</a> <br />
</li>
</ul>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- 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.3
</small></address>
</body>
</html>