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/_g_glyph_menu_8ino-example....

80 lines
16 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: G_glyph_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">G_glyph_menu.ino</div> </div>
</div><!--header-->
<div class="contents">
<p>This example demonstrates how to create a custom character (glyph) and put it inside a <a class="el" href="class_liquid_line.html" title="Represents the individual lines printed on the display. ">LiquidLine</a> object.</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * LiquidMenu library - glyph_menu.ino</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * This example demonstrates how to create a custom character</span></div><div class="line"><span class="comment"> * (glyph) and put it inside a LiquidLine object.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * The LiquidCrystal library allows creating custom characters</span></div><div class="line"><span class="comment"> * with the method bool LiquidCrystal::createChar(byte num, byte data[]).</span></div><div class="line"><span class="comment"> * The &quot;num&quot; parameter is an index (0 to 7), identifying the glyph and</span></div><div class="line"><span class="comment"> * the &quot;data&quot; parameter is an array holding the actual glyph. To insert</span></div><div class="line"><span class="comment"> * it in a LiquidLine object put the &quot;num&quot; parameter (used when creating the</span></div><div class="line"><span class="comment"> * glyph earlier) in the LiquidLine object as a normal variable or an int</span></div><div class="line"><span class="comment"> * literal (e.g. LiquidLine line1(0, 0, glyphNum)) and then call the method</span></div><div class="line"><span class="comment"> * bool LiquidLine::set_asGlyph(byte number) where &quot;number&quot; is the consecutive</span></div><div class="line"><span class="comment"> * number of the variable for that line (e.g. line1.set_asGlyph(1)). Now when</span></div><div class="line"><span class="comment"> * displaying the line on the screen the object will know that this number</span></div><div class="line"><span class="comment"> * should not be displayed directly but is referencing a created character.</span></div><div class="line"><span class="comment"> * The glyph can be animated by changing the value of the variable pointing</span></div><div class="line"><span class="comment"> * to the created character to point to other created character. In the case</span></div><div class="line"><span class="comment"> * of animating a glyph, the method void LiquidMenu::softUpdate() can be used</span></div><div class="line"><span class="comment"> * to update the display to the new glyph without clearing the display. This</span></div><div class="line"><span class="comment"> * method can be used in any case when you are sure that the new information</span></div><div class="line"><span class="comment"> * shown on the display will overwrite the old.</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/glyph_menu/G_glyph_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"> * http://omerk.github.io/lcdchargen/ - for creating custom character definition</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"></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"><span class="comment">// The glyph are separated in a namespace. To use them use</span></div><div class="line"><span class="comment">// namespace_name::variable_name.</span></div><div class="line"><span class="keyword">namespace </span>glyphs {</div><div class="line">uint8_t thermometer[8] = {</div><div class="line"> 0b00100,</div><div class="line"> 0b01010,</div><div class="line"> 0b01010,</div><div class="line"> 0b01010,</div><div class="line"> 0b10001,</div><div class="line"> 0b11111,</div><div class="line"> 0b01110,</div><div class="line"> 0b00000</div><div class="line">};</div><div class="line"></div><div class="line">uint8_t celsiusSymbol[8] = {</div><div class="line"> 0b00011,</div><div class="line"> 0b00011,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000</div><div class="line">};</div><div class="line"></div><div class="line">uint8_t fan1[8] = {</div><div class="line"> 0b00000,</div><div class="line"> 0b11001,</div><div class="line"> 0b01011,</div><div class="line"> 0b00100,</div><div class="line"> 0b11010,</div><div class="line"> 0b10011,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000</div><div class="line">};</div><div class="line"></div><div class="line">uint8_t fan2[8] = {</div><div class="line"> 0b00000,</div><div class="line"> 0b10011,</div><div class="line"> 0b11010,</div><div class="line"> 0b00100,</div><div class="line"> 0b01011,</div><div class="line"> 0b11001,</div><div class="line"> 0b00000,</div><div class="line"> 0b00000</div><div class="line">};</div><div class="line">} <span class="comment">//namespace glyphs</span></div><div class="line"></div><div class="line"><span class="comment">// These are the indexes we will use to create the characters</span></div><div class="line"><span class="comment">// and set them as variables of a LiquidLine object.</span></div><div class="line">byte fan_glyphIndex = 0;</div><div class="line">byte thermometer_glyphIndex = 2;</div><div class="line">byte celsiusSymbol_glyphIndex = 3;</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> line1(1, 1, fan_glyphIndex);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line2(7, 1, thermometer_glyphIndex);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> line3(13, 1, celsiusSymbol_glyphIndex, <span class="stringliteral">&quot;C&quot;</span>);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> screen1(line1, line2, line3);</div><div class="line"></div><div class="line"><a name="_a3"></a><a class="code" href="class_liquid_menu.html">LiquidMenu</a> menu(lcd, welcome_screen, screen1);</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"> <span class="comment">// Here we create the characters using the LiquidCrystal library.</span></div><div class="line"> <span class="comment">// The fan glyph will be animated. This is the first glyph.</span></div><div class="line"> lcd.createChar(fan_glyphIndex, glyphs::fan1);</div><div class="line"> <span class="comment">// This is the second glyph, indexed after the first.</span></div><div class="line"> lcd.createChar(fan_glyphIndex + 1, glyphs::fan2);</div><div class="line"> lcd.createChar(thermometer_glyphIndex, glyphs::thermometer);</div><div class="line"> lcd.createChar(celsiusSymbol_glyphIndex, glyphs::celsiusSymbol);</div><div class="line"></div><div class="line"> <span class="comment">// This functions tells the LiquidLine objects that their first</span></div><div class="line"> <span class="comment">// variable is not an integer value but an index to a glyph.</span></div><div class="line"> line1.set_asGlyph(1);</div><div class="line"> line2.set_asGlyph(1);</div><div class="line"> line3.set_asGlyph(1);</div><div class="line"></div><div class="line"> lcd.begin(16, 2);</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">// This block cycles the value of the variable pointing to</span></div><div class="line"> <span class="comment">// one of the fan glyphs to point to the other.</span></div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> lastMs_fanAnimation = 0;</div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> period_fanAnimation = 500;</div><div class="line"> <span class="keywordflow">if</span> (millis() - lastMs_fanAnimation &gt; period_fanAnimation) {</div><div class="line"> lastMs_fanAnimation = millis();</div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">bool</span> currentAnimation_fan = 0;</div><div class="line"> <span class="keywordflow">if</span> (currentAnimation_fan == 0) {</div><div class="line"> currentAnimation_fan = 1;</div><div class="line"> fan_glyphIndex = 1;</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> currentAnimation_fan = 0;</div><div class="line"> fan_glyphIndex = 0;</div><div class="line"> }</div><div class="line"> <span class="comment">// The display must be updated to show the new glyph.</span></div><div class="line"> menu.softUpdate();</div><div class="line"> }</div><div class="line"></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 = 4000;</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>