Adafruit LiquidCrystal Library
Adafruit_LiquidCrystal.h
Go to the documentation of this file.
1 
4 #ifndef Adafruit_LiquidCrystal_h
5 #define Adafruit_LiquidCrystal_h
6 
7 #include "Arduino.h"
8 #include "Print.h"
9 #include <Adafruit_MCP23X08.h>
10 
11 // commands
12 #define LCD_CLEARDISPLAY 0x01
13 #define LCD_RETURNHOME 0x02
14 #define LCD_ENTRYMODESET 0x04
15 #define LCD_DISPLAYCONTROL \
16  0x08
17 #define LCD_CURSORSHIFT 0x10
18 #define LCD_FUNCTIONSET \
19  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 
57 class Adafruit_LiquidCrystal : public Print {
58 public:
72  Adafruit_LiquidCrystal(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1,
73  uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5,
74  uint8_t d6, uint8_t d7);
90  Adafruit_LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0,
91  uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4,
92  uint8_t d5, uint8_t d6, uint8_t d7);
104  Adafruit_LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0,
105  uint8_t d1, uint8_t d2, uint8_t d3);
115  Adafruit_LiquidCrystal(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1,
116  uint8_t d2, uint8_t d3);
117 
124  Adafruit_LiquidCrystal(uint8_t i2cAddr, TwoWire *wire = &Wire);
131  Adafruit_LiquidCrystal(uint8_t data, uint8_t clock, uint8_t latch);
132 
149  void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
150  uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4,
151  uint8_t d5, uint8_t d6, uint8_t d7);
152 
160  bool begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
161 
165  void clear();
169  void home();
173  void noDisplay();
177  void display();
181  void noBlink();
185  void blink();
189  void noCursor();
193  void cursor();
197  void scrollDisplayLeft();
201  void scrollDisplayRight();
205  void leftToRight();
209  void rightToLeft();
213  void autoscroll();
217  void noAutoscroll();
218 
224  void setBacklight(uint8_t value);
225 
231  void createChar(uint8_t, uint8_t[]);
237  void setCursor(uint8_t, uint8_t);
238 #if ARDUINO >= 100
239  virtual size_t write(uint8_t);
240 #else
241 
245  virtual void write(uint8_t);
246 #endif
247 
251  void command(uint8_t);
252 
253 private:
254  void send(uint8_t value, boolean mode);
255  void write4bits(uint8_t);
256  void write8bits(uint8_t);
257  void pulseEnable();
258  void _digitalWrite(uint8_t, uint8_t);
259  void _pinMode(uint8_t, uint8_t);
260 
261  uint8_t _rs_pin; // LOW: command. HIGH: character.
262  uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
263  uint8_t _enable_pin; // activated by a HIGH pulse.
264  uint8_t _data_pins[8];
265 
266  uint8_t _displayfunction;
267  uint8_t _displaycontrol;
268  uint8_t _displaymode;
269 
270  uint8_t _initialized;
271 
272  uint8_t _numlines, _currline;
273 
274  uint8_t _SPIclock, _SPIdata, _SPIlatch;
275  uint8_t _SPIbuff;
276 
277  uint8_t _i2cAddr;
278  TwoWire *_wire;
279  Adafruit_MCP23X08 _mcp;
280 };
281 
282 #endif
void scrollDisplayLeft()
High-level command to scroll display left without changing the RAM.
Definition: Adafruit_LiquidCrystal.cpp:298
void noAutoscroll()
High-level command to &#39;left justify&#39; text from the cursor.
Definition: Adafruit_LiquidCrystal.cpp:324
void command(uint8_t)
Sends command to display.
Definition: Adafruit_LiquidCrystal.cpp:341
#define LCD_5x8DOTS
8 pixel high font mode
Definition: Adafruit_LiquidCrystal.h:52
void blink()
High-level command to turn the blinking cursor on.
Definition: Adafruit_LiquidCrystal.cpp:292
void autoscroll()
High-level command to &#39;right justify&#39; text from the cursor.
Definition: Adafruit_LiquidCrystal.cpp:318
void noDisplay()
High-level command to turn the display off quickly.
Definition: Adafruit_LiquidCrystal.cpp:268
void cursor()
High-level command to turn the underline cursor on.
Definition: Adafruit_LiquidCrystal.cpp:282
bool begin(uint8_t cols, uint8_t rows, uint8_t charsize=LCD_5x8DOTS)
Starts I2C connection with display.
Definition: Adafruit_LiquidCrystal.cpp:140
void createChar(uint8_t, uint8_t[])
High-level command that creates custom character in CGRAM.
Definition: Adafruit_LiquidCrystal.cpp:331
void noCursor()
High-level command to turn the underline cursor off.
Definition: Adafruit_LiquidCrystal.cpp:278
void home()
High-level command to set the cursor position to zero.
Definition: Adafruit_LiquidCrystal.cpp:253
Adafruit_LiquidCrystal(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
LiquidCrystal constructor for writing to a display.
Definition: Adafruit_LiquidCrystal.cpp:51
void setCursor(uint8_t, uint8_t)
High-level command that sets the location of the cursor.
Definition: Adafruit_LiquidCrystal.cpp:258
void rightToLeft()
High-level command to make text flow right to left.
Definition: Adafruit_LiquidCrystal.cpp:312
void scrollDisplayRight()
High-level command to scroll display right without changing the RAM.
Definition: Adafruit_LiquidCrystal.cpp:301
void leftToRight()
High-level command to make text flow left to right.
Definition: Adafruit_LiquidCrystal.cpp:306
void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
Initializes the display.
Definition: Adafruit_LiquidCrystal.cpp:114
virtual void write(uint8_t)
Mid-level command that sends data to the display.
Definition: Adafruit_LiquidCrystal.cpp:349
void setBacklight(uint8_t value)
High-level command to set the backlight, only if the LCD backpack is used.
Definition: Adafruit_LiquidCrystal.cpp:375
void noBlink()
High-level command to turn the blinking cursor off.
Definition: Adafruit_LiquidCrystal.cpp:288
Main LiquidCrystal class.
Definition: Adafruit_LiquidCrystal.h:57
void display()
High-level command to turn the display on quickly.
Definition: Adafruit_LiquidCrystal.cpp:272
void clear()
High-level command to clear the display.
Definition: Adafruit_LiquidCrystal.cpp:248