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

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: F_focus_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">F_focus_menu.ino</div> </div>
</div><!--header-->
<div class="contents">
<p>This example demonstrates how to customize the focus indicator.</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * LiquidMenu library - focus_menu.ino</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * This example demonstrates how to customize the focus indicator.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * The default focus indicator is an arrow symbol shown on the right of the</span></div><div class="line"><span class="comment"> * focused line. The focus indicator position can be changed per line to be</span></div><div class="line"><span class="comment"> * shown on the right, on the left or in a specified position. The focus</span></div><div class="line"><span class="comment"> * symbol can also be changed, per position.</span></div><div class="line"><span class="comment"> * In this example a custom focus symbol is defined (uint8_t rFocus[8]). Then</span></div><div class="line"><span class="comment"> * it is configured to be the right focus indicator symbol using the</span></div><div class="line"><span class="comment"> * bool LiquidMenu::set_focusSymbol(Position position, uint8_t symbol[8]) method.</span></div><div class="line"><span class="comment"> * The focus position for the different lines is configured using the</span></div><div class="line"><span class="comment"> * bool set_focusPosition(Position position, uint8_t column = 0, uint8_t row = 0)</span></div><div class="line"><span class="comment"> * method. If the &quot;position&quot; is &quot;Position::CUSTOM&quot;, the column and row parameters</span></div><div class="line"><span class="comment"> * must be specified. The focus position can be specified for a single line, for</span></div><div class="line"><span class="comment"> * the whole screen, for the whole menu or for the whole menu system using the</span></div><div class="line"><span class="comment"> * respective objects.</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/focus_menu/F_focus_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"> * - Button (left) to Arduino pin A0 and ground</span></div><div class="line"><span class="comment"> * - Button (right) to Arduino pin 7 and ground</span></div><div class="line"><span class="comment"> * - Button (enter) to Arduino pin 10 and 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 indicator symbol</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 &quot;Button.h&quot;</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">// Button objects instantiation</span></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">bool</span> pullup = <span class="keyword">true</span>;</div><div class="line">Button left(A0, pullup);</div><div class="line">Button right(7, pullup);</div><div class="line">Button enter(10, pullup);</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(1, 1, <span class="stringliteral">&quot;Focus 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> leftFocus_line(1, 0, <span class="stringliteral">&quot;Left focus&quot;</span>);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> rightFocus_line(1, 1, <span class="stringliteral">&quot;Right focus&quot;</span>);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> leftright_screen(leftFocus_line, rightFocus_line);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> customFocus_line(1, 0, <span class="stringliteral">&quot;Custom focus&quot;</span>);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> customFocus_screen(customFocus_line);</div><div class="line"></div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> leftF1_line(6, 0, <span class="stringliteral">&quot;Left&quot;</span>);</div><div class="line"><a class="code" href="class_liquid_line.html">LiquidLine</a> leftF2_line(6, 1, <span class="stringliteral">&quot;focus&quot;</span>);</div><div class="line"><a class="code" href="class_liquid_screen.html">LiquidScreen</a> leftF12_screen(leftF1_line, leftF2_line);</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"><span class="comment">// Checks all the buttons.</span></div><div class="line"><span class="keywordtype">void</span> buttonsCheck() {</div><div class="line"> <span class="keywordflow">if</span> (right.check() == LOW) {</div><div class="line"> menu.next_screen();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">if</span> (left.check() == LOW) {</div><div class="line"> menu.previous_screen();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">if</span> (enter.check() == LOW) {</div><div class="line"> <span class="comment">// Switches focus to the next line.</span></div><div class="line"> menu.switch_focus();</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// Indicator symbol definition, it will change the default symbol for the right focus.</span></div><div class="line"><span class="comment">// http://omerk.github.io/lcdchargen/</span></div><div class="line">uint8_t rFocus[8] = {</div><div class="line"> 0b00000,</div><div class="line"> 0b00000,</div><div class="line"> 0b00100,</div><div class="line"> 0b01110,</div><div class="line"> 0b00100,</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"><span class="comment">// Blank function, it is attached to the lines so that they become focusable.</span></div><div class="line"><span class="keywordtype">void</span> func() {</div><div class="line"> <span class="keywordflow">return</span>;</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">// Changes the right focus symbol.</span></div><div class="line"> menu.set_focusSymbol(Position::RIGHT, rFocus);</div><div class="line"></div><div class="line"> <span class="comment">// Sets the focus position for this line to be on the left.</span></div><div class="line"> leftFocus_line.set_focusPosition(Position::LEFT);</div><div class="line"> rightFocus_line.set_focusPosition(Position::RIGHT);</div><div class="line"> <span class="comment">// &#39;CUSTOM&#39; focus position needs column and row parameters.</span></div><div class="line"> customFocus_line.set_focusPosition(Position::CUSTOM, 15, 0);</div><div class="line"> <span class="comment">// The focus position can be changed for the whole screen or</span></div><div class="line"> <span class="comment">// menu at once. &#39;CUSTOM&#39; position cannot be set because it</span></div><div class="line"> <span class="comment">// needs individual coordinates.</span></div><div class="line"> leftF12_screen.set_focusPosition(Position::LEFT);</div><div class="line"></div><div class="line"> <span class="comment">// Attaching a function to a line makes the line focusable.</span></div><div class="line"> leftFocus_line.attach_function(1, func);</div><div class="line"> rightFocus_line.attach_function(1, func);</div><div class="line"> customFocus_line.attach_function(1, func);</div><div class="line"> leftF1_line.attach_function(1, func);</div><div class="line"> leftF2_line.attach_function(1, func);</div><div class="line"></div><div class="line"> menu.add_screen(welcome_screen);</div><div class="line"> menu.add_screen(leftright_screen);</div><div class="line"> menu.add_screen(customFocus_screen);</div><div class="line"> menu.add_screen(leftright_screen);</div><div class="line"> menu.add_screen(leftF12_screen);</div><div class="line"></div><div class="line"> menu.update();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop() {</div><div class="line"> buttonsCheck();</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>