You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
15 KiB
80 lines
15 KiB
<!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.14"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>LiquidMenu: A_hello_menu.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="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 style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="logo_small.png"/></td>
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">LiquidMenu
|
|
 <span id="projectnumber">1.4.1</span>
|
|
</div>
|
|
<div id="projectbrief">Menu creation Arduino library for LCDs, wraps LiquidCrystal.</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(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">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">A_hello_menu.ino</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<p>This is the get started example demonstrating how to create a menu of two screens with dynamically changing information.</p>
|
|
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * LiquidMenu library - hello_menu.ino</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * This is the get started example demonstrating how to create</span></div><div class="line"><span class="comment"> * a menu of two screens with dynamically changing information.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * The first screen shows some static text. The second screen</span></div><div class="line"><span class="comment"> * shows the reading of analog pin A1. To display a changing</span></div><div class="line"><span class="comment"> * variable on the LCD, simply put the variable in the LiquidLine</span></div><div class="line"><span class="comment"> * constructor. In this case the LiquidLine object is "analogReading_line"</span></div><div class="line"><span class="comment"> * and the variable is "analogReading". This line is on the second</span></div><div class="line"><span class="comment"> * screen. The value of the analog pin is read every second and if</span></div><div class="line"><span class="comment"> * it has changed the display is updated with the new value. The</span></div><div class="line"><span class="comment"> * menu cycles through its two screens every five seconds.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * The circuit:</span></div><div class="line"><span class="comment"> * https://github.com/VasilKalchev/LiquidMenu/blob/master/examples/A_hello_menu/hello_menu.png</span></div><div class="line"><span class="comment"> * - LCD RS pin to Arduino pin 12</span></div><div class="line"><span class="comment"> * - LCD E pin to Arduino pin 11</span></div><div class="line"><span class="comment"> * - LCD D4 pin to Arduino pin 5</span></div><div class="line"><span class="comment"> * - LCD D5 pin to Arduino pin 4</span></div><div class="line"><span class="comment"> * - LCD D6 pin to Arduino pin 3</span></div><div class="line"><span class="comment"> * - LCD D7 pin to Arduino pin 2</span></div><div class="line"><span class="comment"> * - LCD R/W pin to ground</span></div><div class="line"><span class="comment"> * - LCD VSS pin to ground</span></div><div class="line"><span class="comment"> * - LCD VDD pin to 5V</span></div><div class="line"><span class="comment"> * - 10k ohm potentiometer: ends to 5V and ground, wiper to LCD V0</span></div><div class="line"><span class="comment"> * - 150 ohm resistor from 5V to LCD Anode</span></div><div class="line"><span class="comment"> * - LCD Cathode to ground</span></div><div class="line"><span class="comment"> * - ----</span></div><div class="line"><span class="comment"> * - some analog input to Arduino pin A1 (unconnected also works)</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * Created July 24, 2016</span></div><div class="line"><span class="comment"> * by Vasil Kalchev</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * https://github.com/VasilKalchev/LiquidMenu</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"><span class="comment">// The LCD library</span></div><div class="line"><span class="preprocessor">#include <LiquidCrystal.h></span></div><div class="line"><span class="comment">// The menu wrapper library</span></div><div class="line"><span class="preprocessor">#include <<a class="code" href="_liquid_menu_8h.html">LiquidMenu.h</a>></span></div><div class="line"></div><div class="line"><span class="comment">// Pin mapping for the display:</span></div><div class="line"><span class="keyword">const</span> byte LCD_RS = 12;</div><div class="line"><span class="keyword">const</span> byte LCD_E = 11;</div><div class="line"><span class="keyword">const</span> byte LCD_D4 = 5;</div><div class="line"><span class="keyword">const</span> byte LCD_D5 = 4;</div><div class="line"><span class="keyword">const</span> byte LCD_D6 = 3;</div><div class="line"><span class="keyword">const</span> byte LCD_D7 = 2;</div><div class="line"><span class="comment">//LCD R/W pin to ground</span></div><div class="line"><span class="comment">//10K potentiometer wiper to VO</span></div><div class="line">LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * Variable 'analogReading' is later configured to</span></div><div class="line"><span class="comment"> * be printed on the display. 'lastAnalogReading'</span></div><div class="line"><span class="comment"> * is used to check if the variable has changed.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">const</span> byte analogPin = A1;</div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> analogReading = 0;</div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> lastAnalogReading = 0;</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * Variables used for periodic execution of code. The first one is the period</span></div><div class="line"><span class="comment"> * in milliseconds and the second one is the last time the code executed.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> period_check = 1000;</div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> lastMs_check = 0;</div><div class="line"></div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> period_nextScreen = 5000;</div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> lastMs_nextScreen = 0;</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * LiquidLine objects represent a single line of text and/or variables</span></div><div class="line"><span class="comment"> * on the display. The first two parameters are the column and row from</span></div><div class="line"><span class="comment"> * which the line starts, the rest of the parameters are the text and/or</span></div><div class="line"><span class="comment"> * variables that will be printed on the display. They can be up to four.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="comment">// Here the line is set to column 1, row 0 and will print the passed</span></div><div class="line"><span class="comment">// string and the passed variable.</span></div><div class="line"><a name="_a0"></a><a class="code" href="class_liquid_line.html">LiquidLine</a> welcome_line1(1, 0, <span class="stringliteral">"LiquidMenu "</span>, <a name="a1"></a><a class="code" href="_liquid_menu_8h.html#a7189c07575adbb1070c89dcd0ab5e272">LIQUIDMENU_VERSION</a>);</div><div class="line"><span class="comment">// Here the column is 3, the row is 1 and the string is "Hello Menu".</span></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> welcome_line2(3, 1, <span class="stringliteral">"Hello Menu"</span>);</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * LiquidScreen objects represent a single screen. A screen is made of</span></div><div class="line"><span class="comment"> * one or more LiquidLine objects. Up to four LiquidLine objects can</span></div><div class="line"><span class="comment"> * be inserted from here, but more can be added later in setup() using</span></div><div class="line"><span class="comment"> * welcome_screen.add_line(someLine_object);.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="comment">// Here the LiquidLine objects are the two objects from above.</span></div><div class="line"><a name="_a2"></a><a class="code" href="class_liquid_screen.html">LiquidScreen</a> welcome_screen(welcome_line1, welcome_line2);</div><div class="line"></div><div class="line"><span class="comment">// Here there is not only a text string but also a changing integer variable.</span></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> analogReading_line(0, 0, <span class="stringliteral">"Analog: "</span>, analogReading);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> secondary_screen(analogReading_line);</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * The LiquidMenu object combines the LiquidScreen objects to form the</span></div><div class="line"><span class="comment"> * menu. Here it is only instantiated and the screens are added later</span></div><div class="line"><span class="comment"> * using menu.add_screen(someScreen_object);. This object is used to</span></div><div class="line"><span class="comment"> * control the menu, for example: menu.next_screen(), menu.switch_focus()...</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><a name="_a3"></a><a class="code" href="class_liquid_menu.html">LiquidMenu</a> menu(lcd);</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setup() {</div><div class="line"> Serial.begin(250000);</div><div class="line"></div><div class="line"> pinMode(analogPin, INPUT);</div><div class="line"></div><div class="line"> lcd.begin(16, 2);</div><div class="line"></div><div class="line"> <span class="comment">// This is the method used to add a screen object to the menu.</span></div><div class="line"> menu.add_screen(welcome_screen);</div><div class="line"> menu.add_screen(secondary_screen);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop() {</div><div class="line"> <span class="comment">// Periodic reading of the analog pin.</span></div><div class="line"> <span class="keywordflow">if</span> (millis() - lastMs_check > period_check) {</div><div class="line"> lastMs_check = millis();</div><div class="line"> analogReading = analogRead(analogPin);</div><div class="line"> <span class="comment">/*</span></div><div class="line"><span class="comment"> * Check if the analog value have changed</span></div><div class="line"><span class="comment"> * and update the display if it has.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"> <span class="keywordflow">if</span> (analogReading != lastAnalogReading) {</div><div class="line"> lastAnalogReading = analogReading;</div><div class="line"> menu.update();</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Periodic switching to the next screen.</span></div><div class="line"> <span class="keywordflow">if</span> (millis() - lastMs_nextScreen > period_nextScreen) {</div><div class="line"> lastMs_nextScreen = millis();</div><div class="line"> menu.next_screen();</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --> </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.14
|
|
</small></address>
|
|
</body>
|
|
</html>
|
|
|