Adafruit RGB LCD Shield Library
Adafruit_RGBLCDShield.h
Go to the documentation of this file.
1 
5 #ifndef Adafruit_RGBLCDShield_h
6 #define Adafruit_RGBLCDShield_h
7 
8 #include "Print.h"
9 #include <inttypes.h>
10 #include <utility/Adafruit_MCP23017.h>
11 
12 // commands
13 #define LCD_CLEARDISPLAY 0x01
14 #define LCD_RETURNHOME 0x02
15 #define LCD_ENTRYMODESET 0x04
16 #define LCD_DISPLAYCONTROL \
17  0x08
18 #define LCD_CURSORSHIFT 0x10
19 #define LCD_FUNCTIONSET 0x20
20 #define LCD_SETCGRAMADDR \
21  0x40
22 #define LCD_SETDDRAMADDR 0x80
23 
24 // flags for display entry mode
25 #define LCD_ENTRYRIGHT 0x00
26 #define LCD_ENTRYLEFT 0x02
27 #define LCD_ENTRYSHIFTINCREMENT \
28  0x01
29 #define LCD_ENTRYSHIFTDECREMENT \
30  0x00
31 
32 // flags for display on/off control
33 #define LCD_DISPLAYON 0x04
34 #define LCD_DISPLAYOFF 0x00
35 #define LCD_CURSORON 0x02
36 #define LCD_CURSOROFF 0x00
37 #define LCD_BLINKON 0x01
38 #define LCD_BLINKOFF 0x00
39 
40 // flags for display/cursor shift
41 #define LCD_DISPLAYMOVE 0x08
42 #define LCD_CURSORMOVE 0x00
43 #define LCD_MOVERIGHT 0x04
44 #define LCD_MOVELEFT 0x00
45 
46 // flags for function set
47 #define LCD_8BITMODE 0x10
48 #define LCD_4BITMODE 0x00
49 #define LCD_2LINE 0x08
50 #define LCD_1LINE 0x00
51 #define LCD_5x10DOTS 0x04
52 #define LCD_5x8DOTS 0x00
53 
54 #define BUTTON_UP 0x08
55 #define BUTTON_DOWN 0x04
56 #define BUTTON_LEFT 0x10
57 #define BUTTON_RIGHT 0x02
58 #define BUTTON_SELECT 0x01
59 
60 #ifdef ARDUINO_ARCH_MEGAAVR
61 using namespace arduino;
62 #endif
63 
64 
67 class Adafruit_RGBLCDShield : public Print {
68 public:
70 
86  void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
87  uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4,
88  uint8_t d5, uint8_t d6, uint8_t d7);
89 
97  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
98 
102  void clear();
106  void home();
107 
111  void noDisplay();
115  void display();
119  void noBlink();
123  void blink();
127  void noCursor();
131  void cursor();
135  void scrollDisplayLeft();
139  void scrollDisplayRight();
143  void leftToRight();
147  void rightToLeft();
151  void autoscroll();
155  void noAutoscroll();
156 
162  void setBacklight(uint8_t status);
163 
169  void createChar(uint8_t, uint8_t[]);
175  void setCursor(uint8_t, uint8_t);
176 #if ARDUINO >= 100
177  virtual size_t write(uint8_t);
178 #else
179 
183  virtual void write(uint8_t);
184 #endif
185 
189  void command(uint8_t);
194  uint8_t readButtons();
195 
196 private:
197  void send(uint8_t, uint8_t);
198  void write4bits(uint8_t);
199  void write8bits(uint8_t);
200  void pulseEnable();
201  void _digitalWrite(uint8_t, uint8_t);
202  void _pinMode(uint8_t, uint8_t);
203 
204  uint8_t _rs_pin; // LOW: command. HIGH: character.
205  uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
206  uint8_t _enable_pin; // activated by a HIGH pulse.
207  uint8_t _data_pins[8];
208  uint8_t _button_pins[5];
209  uint8_t _displayfunction;
210  uint8_t _displaycontrol;
211  uint8_t _displaymode;
212 
213  uint8_t _initialized;
214 
215  uint8_t _numlines, _currline;
216 
217  uint8_t _i2cAddr;
218  Adafruit_MCP23017 _i2c;
219 };
220 
221 #endif
#define LCD_5x8DOTS
8 pixel high font mode
Definition: Adafruit_RGBLCDShield.h:52
Base class for RGB LCD shield.
Definition: Adafruit_RGBLCDShield.h:67