mirror of
https://github.com/itead/ITEADLIB_Arduino_Nextion.git
synced 2026-03-03 08:44:00 +01:00
162 lines
9.0 KiB
HTML
162 lines
9.0 KiB
HTML
<!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.7"/>
|
|
<title>Documentation: CompButton.ino</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="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(initResizable);
|
|
$(window).load(resizeHeight);
|
|
</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="projectlogo"><img alt="Logo" src="Logo.png"/></td>
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">Documentation
|
|
</div>
|
|
<div id="projectbrief">For Arduino users</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.7 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li><a href="examples.html"><span>Examples</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){initNavTree('_comp_button_8ino-example.html','');});
|
|
</script>
|
|
<div id="doc-content">
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">CompButton.ino</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<dl class="section user"><dt>How to Use</dt><dd>This example shows that when the button component on the Nextion screen is released, the text of this button will plus one every time.</dd></dl>
|
|
<dl class="section author"><dt>Author</dt><dd>Wu Pengfei (email:<a href="#" onclick="location.href='mai'+'lto:'+'pen'+'gf'+'ei.'+'wu'+'@it'+'ea'+'d.c'+'c'; return false;">pengf<span style="display: none;">.nosp@m.</span>ei.w<span style="display: none;">.nosp@m.</span>u@ite<span style="display: none;">.nosp@m.</span>ad.c<span style="display: none;">.nosp@m.</span>c</a>) </dd></dl>
|
|
<dl class="section date"><dt>Date</dt><dd>2015/7/10 </dd></dl>
|
|
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. <br />
|
|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</dd></dl>
|
|
<div class="fragment"><div class="line"></div>
|
|
<div class="line"><span class="preprocessor">#include "<a class="code" href="_nextion_8h.html">Nextion.h</a>"</span></div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">/*</span></div>
|
|
<div class="line"><span class="comment"> * Declare a button object [page id:0,component id:1, component name: "b0"]. </span></div>
|
|
<div class="line"><span class="comment"> */</span></div>
|
|
<div class="line"><a name="_a0"></a><a class="code" href="class_nex_button.html">NexButton</a> b0 = <a class="code" href="class_nex_button.html">NexButton</a>(0, 1, <span class="stringliteral">"b0"</span>);</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="keywordtype">char</span> buffer[100] = {0};</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">/*</span></div>
|
|
<div class="line"><span class="comment"> * Register a button object to the touch event list. </span></div>
|
|
<div class="line"><span class="comment"> */</span></div>
|
|
<div class="line"><a name="_a1"></a><a class="code" href="class_nex_touch.html">NexTouch</a> *nex_listen_list[] = </div>
|
|
<div class="line">{</div>
|
|
<div class="line"> &b0,</div>
|
|
<div class="line"> NULL</div>
|
|
<div class="line">};</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">/*</span></div>
|
|
<div class="line"><span class="comment"> * Button component pop callback function. </span></div>
|
|
<div class="line"><span class="comment"> * In this example,the button's text value will plus one every time when it is released. </span></div>
|
|
<div class="line"><span class="comment"> */</span></div>
|
|
<div class="line"><span class="keywordtype">void</span> b0PopCallback(<span class="keywordtype">void</span> *ptr)</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> uint16_t len;</div>
|
|
<div class="line"> uint16_t number;</div>
|
|
<div class="line"> <a class="code" href="class_nex_button.html">NexButton</a> *btn = (<a class="code" href="class_nex_button.html">NexButton</a> *)ptr;</div>
|
|
<div class="line"> dbSerialPrintln(<span class="stringliteral">"b0PopCallback"</span>);</div>
|
|
<div class="line"> dbSerialPrint(<span class="stringliteral">"ptr="</span>);</div>
|
|
<div class="line"> dbSerialPrintln((uint32_t)ptr); </div>
|
|
<div class="line"> memset(buffer, 0, <span class="keyword">sizeof</span>(buffer));</div>
|
|
<div class="line"></div>
|
|
<div class="line"> <span class="comment">/* Get the text value of button component [the value is string type]. */</span></div>
|
|
<div class="line"> btn-><a name="a2"></a><a class="code" href="class_nex_button.html#a5ba1f74aa94b41b98172e42583ee13d6">getText</a>(buffer, <span class="keyword">sizeof</span>(buffer));</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> number = atoi(buffer);</div>
|
|
<div class="line"> number += 1;</div>
|
|
<div class="line"></div>
|
|
<div class="line"> memset(buffer, 0, <span class="keyword">sizeof</span>(buffer));</div>
|
|
<div class="line"> itoa(number, buffer, 10);</div>
|
|
<div class="line"></div>
|
|
<div class="line"> <span class="comment">/* Set the text value of button component [the value is string type]. */</span></div>
|
|
<div class="line"> btn-><a name="a3"></a><a class="code" href="class_nex_button.html#a649dafc5afb1dc7f1fc1bde1e6270290">setText</a>(buffer);</div>
|
|
<div class="line">}</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="keywordtype">void</span> setup(<span class="keywordtype">void</span>)</div>
|
|
<div class="line">{ </div>
|
|
<div class="line"> <span class="comment">/* Set the baudrate which is for debug and communicate with Nextion screen. */</span></div>
|
|
<div class="line"> <a name="a4"></a><a class="code" href="group___core_a_p_i.html#gab09ddba6b72334d30ae091a7b038d790">nexInit</a>();</div>
|
|
<div class="line"></div>
|
|
<div class="line"> <span class="comment">/* Register the pop event callback function of the current button component. */</span></div>
|
|
<div class="line"> b0.<a name="a5"></a><a class="code" href="class_nex_touch.html#a4da1c4fcdfadb7eabfb9ccaba9ecad11">attachPop</a>(b0PopCallback, &b0);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> dbSerialPrintln(<span class="stringliteral">"setup done"</span>); </div>
|
|
<div class="line">}</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="keywordtype">void</span> loop(<span class="keywordtype">void</span>)</div>
|
|
<div class="line">{ </div>
|
|
<div class="line"> <span class="comment">/*</span></div>
|
|
<div class="line"><span class="comment"> * When a pop or push event occured every time,</span></div>
|
|
<div class="line"><span class="comment"> * the corresponding component[right page id and component id] in touch event list will be asked.</span></div>
|
|
<div class="line"><span class="comment"> */</span></div>
|
|
<div class="line"> <a name="a6"></a><a class="code" href="group___core_a_p_i.html#ga91c549e696b0ca035cf18901e6a50d5a">nexLoop</a>(nex_listen_list);</div>
|
|
<div class="line">}</div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
<div class="line"></div>
|
|
</div><!-- fragment --> </div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated on Wed Nov 11 2015 15:49:29 for Documentation by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.7 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|