Alphanumeric LCD helper for Arduino  1.0.4
LCD helper class for Arduino + AlphaLCD library
 All Classes Files Functions Variables Macros
/Volumes/John Doe/Firmware/Arduino Sketches and components/Display/LCD.cpp
Go to the documentation of this file.
1 
18 #include <inttypes.h>
19 #include <Print.h>
20 #include <Stream.h>
21 
22 #include <AlphaLCD.cpp>
23 
24 #include "LCD.h"
25 
31 AlphaLCD lcd;
32 
38 LCD::LCD() {
39 
40  // Set the LCD Shift Register control pins
42 
43  // Initializes the LCD library
44  lcd.begin(LCDCHARS, LCDROWS);
45 
46  // Turn LCD On
47  lcd.display();
48 
49 } //LCD
50 
52 void LCD::enable(bool s) {
53  if(s)
54  lcd.display();
55  else
56  lcd.noDisplay();
57 }
58 
60 void LCD::blink(bool set) {
61  lcd.isBlinking(set);
62 }
63 
67 void LCD::welcome() {
68 
69  lcd.clear();
70  lcd.setCursor(0, LCDBOTTOMROW);
71  lcd << _VERSION << _SPACING << version() << _SPACING << build();
72  lcd.setCursor(0, LCDTOPROW);
73  lcd << project();
74 
75  delay(LCDMESSAGE_DELAY);
76 
77  lcd.clear();
78 }
79 
85 void LCD::message(String m) {
86  lcd.print(m);
87 }
88 
94 void LCD::dec(int n) {
95  lcd.print(n, DEC);
96 }
97 
103 void LCD::hex(int n) {
104  lcd << "0x" << _HEX(n);
105 }
106 
112 void LCD::bin(int n) {
113  lcd << "B_"<< _BIN(n);
114 }
115 
121 void LCD::oct(int n) {
122  lcd << "O_" << _OCT(n);
123 }
124 
137 void LCD::error(String m, int x, int y) {
138  message(m, x, y);
139  delay(LCDERROR_DELAY);
140 }
141 
152 void LCD::error(String m) {
153  message(m);
154  delay(LCDERROR_DELAY);
155 }
156 
164 void LCD::message(String m, int x, int y) {
165  lcd.setCursor(x, y);
166  message(m);
167 }
168 
175 void LCD::clean() {
176  lcd.clear();
177  delay(LCDCLEAR_DELAY);
178 }
179 
193 void LCD::menu(String sect1, String sect2, String sect3, String sect4) {
194  clean();
195  message(sect1, LCD_SECTOR1, LCDTOPROW);
196  message(sect2, LCD_SECTOR2, LCDTOPROW);
199 }
200 
202 LCD::~LCD()
203 {
204 } //~LCD
void enable(bool s)
Set the display on or off.
#define LCDBOTTOMROW
The bottom row number of the LCD.
Definition: LCD.h:39
void welcome()
shows the program welcome message
#define LCDROWS
Display rows.
Definition: LCD.h:35
#define LCDCHARS
Display characters per line Define this value accordingly with the LCD Hardware datasheet.
Definition: LCD.h:33
void message(String m)
shows a string message
void bin(int n)
shows an integer in binary format
#define LCDlatchPin
LCD Shift control pin - Latch signal Define this value accordingly with the Arduino board connections...
Definition: LCD.h:27
LCD display Manager include file.
void clean()
clean the LCD screen
#define LCD_SECTOR3
Bottom Left display sector column.
Definition: LCD.h:45
#define _SPACING
Definition: Strings.h:12
#define LCDdataPin
LCD Shift control pin - Data signal Define this value accordingly with the Arduino board connections...
Definition: LCD.h:30
void error(String m)
shows an error message
#define LCDTOPROW
The top row number of the LCD.
Definition: LCD.h:37
#define LCDMESSAGE_DELAY
Delay after showing a temporary message e.g. the welcome screen.
Definition: LCD.h:52
#define LCDERROR_DELAY
Delay after showing an error.
Definition: LCD.h:50
void blink(bool set)
Set blink mode.
~LCD()
void dec(int n)
shows an integer in decimal format
#define LCD_SECTOR4
Bottom Right display sector column.
Definition: LCD.h:47
AlphaLCD lcd
AlphaLCD class inherited instance.
Definition: LCD.h:67
#define LCDCLEAR_DELAY
Delay after a clear display call to hardware has been done.
Definition: LCD.h:54
#define LCD_SECTOR2
Top Right display sector column.
Definition: LCD.h:43
void menu(String sect1, String sect2, String sect3, String sect4)
void hex(int n)
shows an integer in hexadeciaml format
#define LCDclockPin
LCD Shift control pin - Clock signal Define this value accordingly with the Arduino board connections...
Definition: LCD.h:24
#define LCD_SECTOR1
Top Left display sector column.
Definition: LCD.h:41
void oct(int n)
shows an integer in octal format