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
Go to the documentation of this file.
1 
2 
3 #include <AlphaLCD.h>
4 #include <Streaming.h>
5 
6 // Include the LCD helper and the application string
7 #include "LCD.h"
8 #include "Strings.h"
9 #include "Version.h"
10 
12 AlphaLCD lcd(2,3,4);
13 
14 // Your setup initialization here
15 void setup()
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 }
27 
28 // Your Arduino application here
29 void loop(void)
30 {
31 
32  // ...
33 
34 }
35 
36 
37 // -------- LCD Control functions
38 
42 void welcome() {
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 }
56 
62 void message(String m) {
63  lcd.print(m);
64 }
65 
71 void dec(int n) {
72  lcd.print(n, DEC);
73 }
74 
80 void hex(int n) {
81  lcd.print("0x");
82  lcd.print(n, HEX);
83 }
84 
97 void error(String m, int x, int y) {
98  message(m, x, y);
99  delay(LCDERROR_DELAY);
100 }
101 
112 void error(String m) {
113  message(m);
114  delay(LCDERROR_DELAY);
115 }
116 
124 void message(String m, int x, int y) {
125  lcd.setCursor(x, y);
126  message(m);
127 }
128 
135 void clean() {
136  lcd.clear();
137  delay(LCDCLEAR_DELAY);
138 }
139 
153 void menu(String sect1, String sect2, String sect3, String sect4) {
154  clean();
155  message(sect1, LCD_SECTOR1, LCDTOPROW);
156  message(sect2, LCD_SECTOR2, LCDTOPROW);
159 }
160 
#define LCDBOTTOMROW
The bottom row number of the LCD.
Definition: LCD.h:33
#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
void message(String m)
Display a string on the LCD at the cursor position.
void hex(int n)
Display an integer value in hex format at the cursor position.
LCD display Manager include file.
Version and Build NumberHelper Class.
#define LCD_SECTOR3
Bottom Left display sector column.
Definition: LCD.h:39
#define _SPACING
Definition: Strings.h:13
#define LCDTOPROW
The top row number of the LCD.
Definition: LCD.h:31
void setup()
#define LCDMESSAGE_DELAY
Delay after showing a temporary message e.g. the welcome screen.
Definition: LCD.h:46
#define LCDERROR_DELAY
Delay after showing an error.
Definition: LCD.h:44
AlphaLCD lcd(2, 3, 4)
AlphaLCD class instance for display hardware control.
void welcome()
Welcome message shown at device power-on.
#define LCD_SECTOR4
Bottom Right display sector column.
Definition: LCD.h:41
LCD Display base strings.
#define LCDCLEAR_DELAY
Delay after a clear display call to hardware has been done.
Definition: LCD.h:48
void menu(String sect1, String sect2, String sect3, String sect4)
Creates a menu screen.
#define LCD_SECTOR2
Top Right display sector column.
Definition: LCD.h:37
void dec(int n)
Display an integer value in decimal format at the cursor position.
#define _VERSION
Definition: Strings.h:16
void error(String m, int x, int y)
Display an error message at the specified cursor coordinates.
#define LCD_SECTOR1
Top Left display sector column.
Definition: LCD.h:35
#define version()
Firmware version.
Definition: Version.h:14
void loop(void)
void clean()
Clean the display.