mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
86 lines
3.4 KiB
Plaintext
86 lines
3.4 KiB
Plaintext
/*
|
|
* Copyright (C) 2012 Southern Storm Software, Pty Ltd.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included
|
|
* in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
\file lcd-helloworld.dox
|
|
\page lcd_hello_world Hello World for Freetronics LCD
|
|
|
|
The FreetronicsLCD class provides an enhanced version of the standard
|
|
Arduino <a href="http://arduino.cc/en/Reference/LiquidCrystal">LiquidCrystal</a>
|
|
library that supports the additional features of the
|
|
<a href="http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide">Freetronics LCD</a> shield;
|
|
namely the back light and the Up, Down, Left, Right, and Select buttons.
|
|
This tutorial explains how to use the FreetronicsLCD class to perform
|
|
basic text output and to use the enhanced shield features.
|
|
|
|
\image html HelloWorld.png
|
|
|
|
We start by including the library and initializing it:
|
|
|
|
\dontinclude FreetronicsLCD/examples/HelloWorld/HelloWorld.pde
|
|
\skip FreetronicsLCD.h
|
|
\until lcd
|
|
|
|
Unlike the LiquidCrystal library we don't normally need to specify the pin
|
|
assignments for this shield. The one exception is when the shield is used
|
|
with the USBDroid and the D9 pin is reassigned as described on
|
|
<a href="http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid">this page</a>. In that case, the initialization sequence
|
|
would look something like this instead:
|
|
|
|
\code
|
|
FreetronicsLCD lcd(A1);
|
|
\endcode
|
|
|
|
The next step is to enable the screen saver and print some text
|
|
in the \c setup function:
|
|
|
|
\dontinclude FreetronicsLCD/examples/HelloWorld/HelloWorld.pde
|
|
\skip setup()
|
|
\until }
|
|
|
|
The screen saver is a built-in feature of the FreetronicsLCD class that
|
|
turns off the display and the back light after a specific timeout
|
|
(the default is 10 seconds). Pressing any of the keys on the shield
|
|
or calling FreetronicsLCD::display() will wake up the screen again.
|
|
|
|
In the program's \c loop function we print the number of seconds
|
|
since startup to the second line of the LCD display:
|
|
|
|
\dontinclude FreetronicsLCD/examples/HelloWorld/HelloWorld.pde
|
|
\skip loop()
|
|
\until millis()
|
|
|
|
We then print the name of the button that is currently pressed:
|
|
|
|
\dontinclude FreetronicsLCD/examples/HelloWorld/HelloWorld.pde
|
|
\skip setCursor(8, 1)
|
|
\until }
|
|
|
|
The FreetronicsLCD::getButton() function returns the key that has
|
|
been pressed or released, or LCD_BUTTON_NONE if no key has been
|
|
pressed or released this time through the loop.
|
|
|
|
The full source code for the example follows:
|
|
|
|
\include FreetronicsLCD/examples/HelloWorld/HelloWorld.pde
|
|
*/
|