Statistics
| Branch: | Revision:

root / arduino-1.0 / libraries / LiquidCrystal / LiquidCrystal.h @ 58d82c77

History | View | Annotate | Download (2.67 KB)

1
#ifndef LiquidCrystal_h
2
#define LiquidCrystal_h
3

    
4
#include <inttypes.h>
5
#include "Print.h"
6

    
7
// commands
8
#define LCD_CLEARDISPLAY 0x01
9
#define LCD_RETURNHOME 0x02
10
#define LCD_ENTRYMODESET 0x04
11
#define LCD_DISPLAYCONTROL 0x08
12
#define LCD_CURSORSHIFT 0x10
13
#define LCD_FUNCTIONSET 0x20
14
#define LCD_SETCGRAMADDR 0x40
15
#define LCD_SETDDRAMADDR 0x80
16

    
17
// flags for display entry mode
18
#define LCD_ENTRYRIGHT 0x00
19
#define LCD_ENTRYLEFT 0x02
20
#define LCD_ENTRYSHIFTINCREMENT 0x01
21
#define LCD_ENTRYSHIFTDECREMENT 0x00
22

    
23
// flags for display on/off control
24
#define LCD_DISPLAYON 0x04
25
#define LCD_DISPLAYOFF 0x00
26
#define LCD_CURSORON 0x02
27
#define LCD_CURSOROFF 0x00
28
#define LCD_BLINKON 0x01
29
#define LCD_BLINKOFF 0x00
30

    
31
// flags for display/cursor shift
32
#define LCD_DISPLAYMOVE 0x08
33
#define LCD_CURSORMOVE 0x00
34
#define LCD_MOVERIGHT 0x04
35
#define LCD_MOVELEFT 0x00
36

    
37
// flags for function set
38
#define LCD_8BITMODE 0x10
39
#define LCD_4BITMODE 0x00
40
#define LCD_2LINE 0x08
41
#define LCD_1LINE 0x00
42
#define LCD_5x10DOTS 0x04
43
#define LCD_5x8DOTS 0x00
44

    
45
class LiquidCrystal : public Print {
46
public:
47
  LiquidCrystal(uint8_t rs, uint8_t enable,
48
                uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
49
                uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
50
  LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
51
                uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
52
                uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
53
  LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
54
                uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
55
  LiquidCrystal(uint8_t rs, uint8_t enable,
56
                uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
57

    
58
  void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
59
            uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
60
            uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
61
    
62
  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
63

    
64
  void clear();
65
  void home();
66

    
67
  void noDisplay();
68
  void display();
69
  void noBlink();
70
  void blink();
71
  void noCursor();
72
  void cursor();
73
  void scrollDisplayLeft();
74
  void scrollDisplayRight();
75
  void leftToRight();
76
  void rightToLeft();
77
  void autoscroll();
78
  void noAutoscroll();
79

    
80
  void createChar(uint8_t, uint8_t[]);
81
  void setCursor(uint8_t, uint8_t); 
82
  virtual size_t write(uint8_t);
83
  void command(uint8_t);
84
  
85
  using Print::write;
86
private:
87
  void send(uint8_t, uint8_t);
88
  void write4bits(uint8_t);
89
  void write8bits(uint8_t);
90
  void pulseEnable();
91

    
92
  uint8_t _rs_pin; // LOW: command.  HIGH: character.
93
  uint8_t _rw_pin; // LOW: write to LCD.  HIGH: read from LCD.
94
  uint8_t _enable_pin; // activated by a HIGH pulse.
95
  uint8_t _data_pins[8];
96

    
97
  uint8_t _displayfunction;
98
  uint8_t _displaycontrol;
99
  uint8_t _displaymode;
100

    
101
  uint8_t _initialized;
102

    
103
  uint8_t _numlines,_currline;
104
};
105

    
106
#endif