USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 <inttypes.h>
25 #include "Print.h"
26 #include "Usb.h"
27 
28 // commands
29 #define LCD_CLEARDISPLAY 0x01
30 #define LCD_RETURNHOME 0x02
31 #define LCD_ENTRYMODESET 0x04
32 #define LCD_DISPLAYCONTROL 0x08
33 #define LCD_CURSORSHIFT 0x10
34 #define LCD_FUNCTIONSET 0x20
35 #define LCD_SETCGRAMADDR 0x40
36 #define LCD_SETDDRAMADDR 0x80
37 
38 // flags for display entry mode
39 #define LCD_ENTRYRIGHT 0x00
40 #define LCD_ENTRYLEFT 0x02
41 #define LCD_ENTRYSHIFTINCREMENT 0x01
42 #define LCD_ENTRYSHIFTDECREMENT 0x00
43 
44 // flags for display on/off control
45 #define LCD_DISPLAYON 0x04
46 #define LCD_DISPLAYOFF 0x00
47 #define LCD_CURSORON 0x02
48 #define LCD_CURSOROFF 0x00
49 #define LCD_BLINKON 0x01
50 #define LCD_BLINKOFF 0x00
51 
52 // flags for display/cursor shift
53 #define LCD_DISPLAYMOVE 0x08
54 #define LCD_CURSORMOVE 0x00
55 #define LCD_MOVERIGHT 0x04
56 #define LCD_MOVELEFT 0x00
57 
58 // flags for function set
59 #define LCD_8BITMODE 0x10
60 #define LCD_4BITMODE 0x00
61 #define LCD_2LINE 0x08
62 #define LCD_1LINE 0x00
63 #define LCD_5x10DOTS 0x04
64 #define LCD_5x8DOTS 0x00
65 
66 class Max_LCD //: public Print
67 {
68  USB *pUsb;
69 
70 public:
71  Max_LCD(USB *pusb);
72  void init();
73  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
74  void clear();
75  void home();
76  void noDisplay();
77  void display();
78  void noBlink();
79  void blink();
80  void noCursor();
81  void cursor();
82  void scrollDisplayLeft();
83  void scrollDisplayRight();
84  void leftToRight();
85  void rightToLeft();
86  void autoscroll();
87  void noAutoscroll();
88  void createChar(uint8_t, uint8_t[]);
89  void setCursor(uint8_t, uint8_t);
90  virtual void write(uint8_t);
91  void command(uint8_t);
92 
93 private:
94  void sendbyte( uint8_t val );
95  uint8_t _displayfunction; //tokill
96  uint8_t _displaycontrol;
97  uint8_t _displaymode;
98  uint8_t _initialized;
99  uint8_t _numlines,_currline;
100 };
101 
102 #endif