USB Host Shield 2.0
max_LCD.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
8 the GPL2 ("Copyleft").
9 
10 Contact information
11 -------------------
12 
13 Circuits At Home, LTD
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
16  */
17 //HD44780 compatible LCD display via MAX3421E GPOUT support header
18 //pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
19 //
20 
21 #ifndef _Max_LCD_h_
22 #define _Max_LCD_h_
23 
24 #include "Usb.h"
25 #include "Print.h"
26 
27 // commands
28 #define LCD_CLEARDISPLAY 0x01
29 #define LCD_RETURNHOME 0x02
30 #define LCD_ENTRYMODESET 0x04
31 #define LCD_DISPLAYCONTROL 0x08
32 #define LCD_CURSORSHIFT 0x10
33 #define LCD_FUNCTIONSET 0x20
34 #define LCD_SETCGRAMADDR 0x40
35 #define LCD_SETDDRAMADDR 0x80
36 
37 // flags for display entry mode
38 #define LCD_ENTRYRIGHT 0x00
39 #define LCD_ENTRYLEFT 0x02
40 #define LCD_ENTRYSHIFTINCREMENT 0x01
41 #define LCD_ENTRYSHIFTDECREMENT 0x00
42 
43 // flags for display on/off control
44 #define LCD_DISPLAYON 0x04
45 #define LCD_DISPLAYOFF 0x00
46 #define LCD_CURSORON 0x02
47 #define LCD_CURSOROFF 0x00
48 #define LCD_BLINKON 0x01
49 #define LCD_BLINKOFF 0x00
50 
51 // flags for display/cursor shift
52 #define LCD_DISPLAYMOVE 0x08
53 #define LCD_CURSORMOVE 0x00
54 #define LCD_MOVERIGHT 0x04
55 #define LCD_MOVELEFT 0x00
56 
57 // flags for function set
58 #define LCD_8BITMODE 0x10
59 #define LCD_4BITMODE 0x00
60 #define LCD_2LINE 0x08
61 #define LCD_1LINE 0x00
62 #define LCD_5x10DOTS 0x04
63 #define LCD_5x8DOTS 0x00
64 
65 class Max_LCD : public Print {
66  USB *pUsb;
67 
68 public:
69  Max_LCD(USB *pusb);
70  void init();
71  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
72  void clear();
73  void home();
74  void noDisplay();
75  void display();
76  void noBlink();
77  void blink();
78  void noCursor();
79  void cursor();
80  void scrollDisplayLeft();
81  void scrollDisplayRight();
82  void leftToRight();
83  void rightToLeft();
84  void autoscroll();
85  void noAutoscroll();
86  void createChar(uint8_t, uint8_t[]);
87  void setCursor(uint8_t, uint8_t);
88  void command(uint8_t);
89 
90 #if defined(ARDUINO) && ARDUINO >=100
91  size_t write(uint8_t);
92  using Print::write;
93 #else
94  void write(uint8_t);
95 #endif
96 
97 private:
98  void sendbyte(uint8_t val);
99  uint8_t _displayfunction; //tokill
100  uint8_t _displaycontrol;
101  uint8_t _displaymode;
102  uint8_t _initialized;
103  uint8_t _numlines, _currline;
104 };
105 
106 #endif
void command(uint8_t)
Definition: max_LCD.cpp:221
void noBlink()
Definition: max_LCD.cpp:160
void leftToRight()
Definition: max_LCD.cpp:182
void init()
Definition: max_LCD.cpp:46
size_t write(uint8_t)
Definition: max_LCD.cpp:228
void noAutoscroll()
Definition: max_LCD.cpp:203
void autoscroll()
Definition: max_LCD.cpp:196
void cursor()
Definition: max_LCD.cpp:152
void clear()
Definition: max_LCD.cpp:114
Max_LCD(USB *pusb)
Definition: max_LCD.cpp:42
void createChar(uint8_t, uint8_t[])
Definition: max_LCD.cpp:211
void display()
Definition: max_LCD.cpp:140
void setCursor(uint8_t, uint8_t)
Definition: max_LCD.cpp:124
void blink()
Definition: max_LCD.cpp:165
void noDisplay()
Definition: max_LCD.cpp:135
void home()
Definition: max_LCD.cpp:119
void begin(uint8_t cols, uint8_t rows, uint8_t charsize=LCD_5x8DOTS)
Definition: max_LCD.cpp:54
void noCursor()
Definition: max_LCD.cpp:147
void scrollDisplayRight()
Definition: max_LCD.cpp:176
void rightToLeft()
Definition: max_LCD.cpp:189
void scrollDisplayLeft()
Definition: max_LCD.cpp:172
Definition: UsbCore.h:212
#define LCD_5x8DOTS
Definition: max_LCD.h:63