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.
MicroMDAEPiano/third-party/LiquidMenu/doc/Doxygen/html/_e_progmem_menu_8ino-exampl...

80 lines
19 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: E_progmem_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
&#160;<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&amp;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&amp;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">E_progmem_menu.ino</div> </div>
</div><!--header-->
<div class="contents">
<p>This example demonstrates how to display a string stored in flash memory.</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * LiquidMenu library - progmem_menu.ino</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * This example demonstrates how to display a string stored in flash memory.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * Usually all the variables are stored in RAM (which is 2KB on ATmega328).</span></div><div class="line"><span class="comment"> * To conserve RAM, big variables like char arrays can be stored along with</span></div><div class="line"><span class="comment"> * the program in flash memory (which is 32KB on ATmega328). There is a tutorial</span></div><div class="line"><span class="comment"> * on how to do that on the Arduino web site: https://www.arduino.cc/en/Reference/PROGMEM,</span></div><div class="line"><span class="comment"> * there is also a very good tutorial here: http://www.gammon.com.au/progmem.</span></div><div class="line"><span class="comment"> * Basically the variable is prepended with the &quot;const&quot; variable modifier and</span></div><div class="line"><span class="comment"> * appended with the &quot;PROGMEM&quot; keyword. After that the variable is added to the</span></div><div class="line"><span class="comment"> * LiquidLine object as usual. The difference is that later in the setup(), the method</span></div><div class="line"><span class="comment"> * bool LiquidLine::set_asProgmem(byte number) must be called on the LiquidLine object</span></div><div class="line"><span class="comment"> * holding the variable. The &quot;number&quot; parameter is the consecutive number of the variable</span></div><div class="line"><span class="comment"> * for this LiquidLine object. If there are two variables, the first is an integer</span></div><div class="line"><span class="comment"> * and the second is a string stored in flash, &quot;number&quot; will be 2.</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/progmem_menu/E_progmem_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"> * 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="preprocessor">#include &lt;LiquidCrystal.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="_liquid_menu_8h.html">LiquidMenu.h</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;avr/pgmspace.h&gt;</span> <span class="comment">// The PROGMEM library</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 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"></div><div class="line"><span class="comment">// These are the char arrays stored in flash</span></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text1[] PROGMEM = <span class="stringliteral">&quot;Lorem ipsum dolo&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text2[] PROGMEM = <span class="stringliteral">&quot;r sit amet, cons&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text3[] PROGMEM = <span class="stringliteral">&quot;ectetur adipisci&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text4[] PROGMEM = <span class="stringliteral">&quot;ibendum, sem ac &quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text5[] PROGMEM = <span class="stringliteral">&quot;venenatis rhoncu&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text6[] PROGMEM = <span class="stringliteral">&quot;s, nisi justo eu&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text7[] PROGMEM = <span class="stringliteral">&quot;ismod lectus, eu&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text8[] PROGMEM = <span class="stringliteral">&quot; eleifend ante n&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text9[] PROGMEM = <span class="stringliteral">&quot;isl vitae eros. &quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text10[] PROGMEM = <span class="stringliteral">&quot;Pellentesque hab&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text11[] PROGMEM = <span class="stringliteral">&quot;itant morbi tris&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text12[] PROGMEM = <span class="stringliteral">&quot;tique senectus e&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text13[] PROGMEM = <span class="stringliteral">&quot;t netus et males&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text14[] PROGMEM = <span class="stringliteral">&quot;uada fames ac tu&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text15[] PROGMEM = <span class="stringliteral">&quot;rpis egestas. Or&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text16[] PROGMEM = <span class="stringliteral">&quot;ci varius natoqu&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text17[] PROGMEM = <span class="stringliteral">&quot;e penatibus et m&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text18[] PROGMEM = <span class="stringliteral">&quot;agnis dis partur&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text19[] PROGMEM = <span class="stringliteral">&quot;ient montes, nas&quot;</span>;</div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> text20[] PROGMEM = <span class="stringliteral">&quot;cetur ridiculus &quot;</span>;</div><div class="line"></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">&quot;LiquidMenu &quot;</span>, <a name="a1"></a><a class="code" href="_liquid_menu_8h.html#a7189c07575adbb1070c89dcd0ab5e272">LIQUIDMENU_VERSION</a>);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> welcome_line2(0, 1, <span class="stringliteral">&quot;PROGMEM example&quot;</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"><a class="code" href="class_liquid_line.html">LiquidLine</a> line11(0, 0, text1);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line12(0, 1, text2);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen1(line11, line12);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line21(0, 0, text3);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line22(0, 1, text4);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen2(line21, line22);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line31(0, 0, text5);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line32(0, 1, text6);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen3(line31, line32);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line41(0, 0, text7);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line42(0, 1, text8);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen4(line41, line42);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line51(0, 0, text9);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line52(0, 1, text10);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen5(line51, line52);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line61(0, 0, text11);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line62(0, 1, text12);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen6(line61, line62);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line71(0, 0, text13);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line72(0, 1, text14);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen7(line71, line72);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line81(0, 0, text15);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line82(0, 1, text16);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen8(line81, line82);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line91(0, 0, text17);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line92(0, 1, text18);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen9(line91, line92);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line101(0, 0, text19);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line102(0, 1, text20);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen10(line101, line102);</div><div class="line"></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"> lcd.begin(16, 2);</div><div class="line"></div><div class="line"> <span class="comment">// Set the variables as PROGMEM. The parameter is the consecutive</span></div><div class="line"> <span class="comment">// number of the PROGMEM variable for that LiquidLine object.</span></div><div class="line"> line11.set_asProgmem(1);</div><div class="line"> line12.set_asProgmem(1);</div><div class="line"> line21.set_asProgmem(1);</div><div class="line"> line22.set_asProgmem(1);</div><div class="line"> line31.set_asProgmem(1);</div><div class="line"> line32.set_asProgmem(1);</div><div class="line"> line41.set_asProgmem(1);</div><div class="line"> line42.set_asProgmem(1);</div><div class="line"> line51.set_asProgmem(1);</div><div class="line"> line52.set_asProgmem(1);</div><div class="line"> line61.set_asProgmem(1);</div><div class="line"> line62.set_asProgmem(1);</div><div class="line"> line71.set_asProgmem(1);</div><div class="line"> line72.set_asProgmem(1);</div><div class="line"> line81.set_asProgmem(1);</div><div class="line"> line82.set_asProgmem(1);</div><div class="line"> line91.set_asProgmem(1);</div><div class="line"> line92.set_asProgmem(1);</div><div class="line"> line101.set_asProgmem(1);</div><div class="line"> line102.set_asProgmem(1);</div><div class="line"></div><div class="line"> menu.add_screen(welcome_screen);</div><div class="line"> menu.add_screen(screen1);</div><div class="line"> menu.add_screen(screen2);</div><div class="line"> menu.add_screen(screen3);</div><div class="line"> menu.add_screen(screen4);</div><div class="line"> menu.add_screen(screen5);</div><div class="line"> menu.add_screen(screen6);</div><div class="line"> menu.add_screen(screen7);</div><div class="line"> menu.add_screen(screen8);</div><div class="line"> menu.add_screen(screen9);</div><div class="line"> menu.add_screen(screen10);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop() {</div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> lastMs_nextScreen = 0;</div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> period_nextScreen = 1000;</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 &gt; 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 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>