AlphaLCD helper for Arduino  1.0.4
LCD helper example for Arduino with AlphaLCD and Streaming library
 All Classes Files Functions Variables Macros
Display_Example.ino File Reference
#include <AlphaLCD.h>
#include <Streaming.h>
#include "LCD.h"
#include "Strings.h"
#include "Version.h"

Go to the source code of this file.

Functions

AlphaLCD lcd (2, 3, 4)
 AlphaLCD class instance for display hardware control. More...
 
void setup ()
 
void loop (void)
 
void welcome ()
 Welcome message shown at device power-on. More...
 
void message (String m)
 Display a string on the LCD at the cursor position. More...
 
void dec (int n)
 Display an integer value in decimal format at the cursor position. More...
 
void hex (int n)
 Display an integer value in hex format at the cursor position. More...
 
void error (String m, int x, int y)
 Display an error message at the specified cursor coordinates. More...
 
void error (String m)
 Display an error message at the cursor position. More...
 
void message (String m, int x, int y)
 Display a string on the LCD at the specified cursor coordinates. More...
 
void clean ()
 Clean the display. More...
 
void menu (String sect1, String sect2, String sect3, String sect4)
 Creates a menu screen. More...
 

Function Documentation

void clean ( )

Clean the display.

A delay of 100 ms is added after the hardware clear() call to give the display the time to complete the operation.

Definition at line 135 of file Display_Example.ino.

References lcd(), and LCDCLEAR_DELAY.

Referenced by menu().

135  {
136  lcd.clear();
137  delay(LCDCLEAR_DELAY);
138 }
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
#define LCDCLEAR_DELAY
Delay after a clear display call to hardware has been done.
Definition: LCD.h:48
void dec ( int  n)

Display an integer value in decimal format at the cursor position.

Parameters
nthe integer to show in decimal format

Definition at line 71 of file Display_Example.ino.

References lcd().

71  {
72  lcd.print(n, DEC);
73 }
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
void error ( String  m,
int  x,
int  y 
)

Display an error message at the specified cursor coordinates.

The error message is shown for a LCDERROR_DELAY milliseconds. After the timeout expires the screen is not cleared so the next steps should be managed by the program flow. It is expected that error messages are shown in a calling code that manages the error conditions.

Parameters
mthe message string
xthe cursor column zero based
ythe row number zero based

Definition at line 97 of file Display_Example.ino.

References LCDERROR_DELAY, and message().

97  {
98  message(m, x, y);
99  delay(LCDERROR_DELAY);
100 }
void message(String m)
Display a string on the LCD at the cursor position.
#define LCDERROR_DELAY
Delay after showing an error.
Definition: LCD.h:44
void error ( String  m)

Display an error message at the cursor position.

The error message is shown for a LCDERROR_DELAY milliseconds. After the timeout expires the screen is not cleared so the next steps should be managed by the program flow. It is expected that error messages are shown in a calling code that manages the error conditions.

Parameters
mthe string message

Definition at line 112 of file Display_Example.ino.

References LCDERROR_DELAY, and message().

112  {
113  message(m);
114  delay(LCDERROR_DELAY);
115 }
void message(String m)
Display a string on the LCD at the cursor position.
#define LCDERROR_DELAY
Delay after showing an error.
Definition: LCD.h:44
void hex ( int  n)

Display an integer value in hex format at the cursor position.

Parameters
nthe integer to show in hexadecimal format

Definition at line 80 of file Display_Example.ino.

References lcd().

80  {
81  lcd.print("0x");
82  lcd.print(n, HEX);
83 }
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
AlphaLCD lcd ( ,
,
 
)

AlphaLCD class instance for display hardware control.

Referenced by clean(), dec(), hex(), message(), setup(), and welcome().

void loop ( void  )

Definition at line 29 of file Display_Example.ino.

30 {
31 
32  // ...
33 
34 }
void menu ( String  sect1,
String  sect2,
String  sect3,
String  sect4 
)

Creates a menu screen.

The 2-lines LCD screen is divided in four sectors, that can be used or not. The LCD sectors length and position are defined and based on the LCD size. Every sector is filled with one of the four parameters string. Sectors 1 & 2 are in the top row, sectors 3 & 4 in the bottom row

Parameters
sect1The Upper Left display sector
sect2The Upper Right display sector
sect3The Lower Left display sector
sect4The Lower Right display sector

Definition at line 153 of file Display_Example.ino.

References clean(), LCD_SECTOR1, LCD_SECTOR2, LCD_SECTOR3, LCD_SECTOR4, LCDBOTTOMROW, LCDTOPROW, and message().

153  {
154  clean();
155  message(sect1, LCD_SECTOR1, LCDTOPROW);
156  message(sect2, LCD_SECTOR2, LCDTOPROW);
159 }
#define LCDBOTTOMROW
The bottom row number of the LCD.
Definition: LCD.h:33
void message(String m)
Display a string on the LCD at the cursor position.
#define LCD_SECTOR3
Bottom Left display sector column.
Definition: LCD.h:39
#define LCDTOPROW
The top row number of the LCD.
Definition: LCD.h:31
#define LCD_SECTOR4
Bottom Right display sector column.
Definition: LCD.h:41
#define LCD_SECTOR2
Top Right display sector column.
Definition: LCD.h:37
#define LCD_SECTOR1
Top Left display sector column.
Definition: LCD.h:35
void clean()
Clean the display.
void message ( String  m)

Display a string on the LCD at the cursor position.

Parameters
mthe message string

Definition at line 62 of file Display_Example.ino.

References lcd().

Referenced by error(), menu(), and message().

62  {
63  lcd.print(m);
64 }
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
void message ( String  m,
int  x,
int  y 
)

Display a string on the LCD at the specified cursor coordinates.

Parameters
mthe string message
xthe cursor column zero based
ythe row number zero based

Definition at line 124 of file Display_Example.ino.

References lcd(), and message().

124  {
125  lcd.setCursor(x, y);
126  message(m);
127 }
void message(String m)
Display a string on the LCD at the cursor position.
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
void setup ( )

Definition at line 15 of file Display_Example.ino.

References lcd(), LCDCHARS, LCDROWS, and welcome().

16 {
17 
18  // Initializes the LCD library
19  lcd.begin(LCDCHARS, LCDROWS);
20 
21  // Turn LCD On
22  lcd.display();
23 
24  welcome();
25 
26 }
#define LCDROWS
Display rows.
Definition: LCD.h:29
#define LCDCHARS
Display characters per line Define this value accordingly with the LCD Hardware datasheet.
Definition: LCD.h:27
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
void welcome()
Welcome message shown at device power-on.
void welcome ( )

Welcome message shown at device power-on.

Definition at line 42 of file Display_Example.ino.

References _SPACING, _VERSION, lcd(), LCDBOTTOMROW, LCDMESSAGE_DELAY, LCDTOPROW, and version.

Referenced by setup().

42  {
43 
44  lcd.clear();
45  lcd.setCursor(0, LCDTOPROW);
46  lcd << "Electrosch...";
47  delay(LCDMESSAGE_DELAY);
48  lcd.clear();
49 
50  lcd.setCursor(0, LCDBOTTOMROW);
51  lcd << _VERSION << _SPACING << version();
52  delay(LCDMESSAGE_DELAY);
53  lcd.clear();
54 
55 }
#define LCDBOTTOMROW
The bottom row number of the LCD.
Definition: LCD.h:33
#define _SPACING
Definition: Strings.h:13
#define LCDTOPROW
The top row number of the LCD.
Definition: LCD.h:31
#define LCDMESSAGE_DELAY
Delay after showing a temporary message e.g. the welcome screen.
Definition: LCD.h:46
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
#define _VERSION
Definition: Strings.h:16
#define version()
Firmware version.
Definition: Version.h:14