Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
/* Copyright 2009-2011 Oleg Mazurov, Circuits At Home, http://www.circuitsathome.com */
2
//HD44780 compatible LCD display via MAX3421E GPOUT support header
3
//pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
4
//
5
//this code is heavily borrowed from official Arduino source v.0017
6
// link to original http://code.google.com/p/arduino/source/browse/trunk/hardware/libraries/LiquidCrystal/LiquidCrystal.h
7
//
8
#ifndef _Max_LCD_h_
9
#define _Max_LCD_h_
10
 
11
#include <inttypes.h>
12
#include "Print.h"
13
 
14
// commands
15
#define LCD_CLEARDISPLAY 0x01
16
#define LCD_RETURNHOME 0x02
17
#define LCD_ENTRYMODESET 0x04
18
#define LCD_DISPLAYCONTROL 0x08
19
#define LCD_CURSORSHIFT 0x10
20
#define LCD_FUNCTIONSET 0x20
21
#define LCD_SETCGRAMADDR 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 0x01
28
#define LCD_ENTRYSHIFTDECREMENT 0x00
29
 
30
// flags for display on/off control
31
#define LCD_DISPLAYON 0x04
32
#define LCD_DISPLAYOFF 0x00
33
#define LCD_CURSORON 0x02
34
#define LCD_CURSOROFF 0x00
35
#define LCD_BLINKON 0x01
36
#define LCD_BLINKOFF 0x00
37
 
38
// flags for display/cursor shift
39
#define LCD_DISPLAYMOVE 0x08
40
#define LCD_CURSORMOVE 0x00
41
#define LCD_MOVERIGHT 0x04
42
#define LCD_MOVELEFT 0x00
43
 
44
// flags for function set
45
#define LCD_8BITMODE 0x10
46
#define LCD_4BITMODE 0x00
47
#define LCD_2LINE 0x08
48
#define LCD_1LINE 0x00
49
#define LCD_5x10DOTS 0x04
50
#define LCD_5x8DOTS 0x00
51
 
52
class Max_LCD : public Print {
53
public:
54
  Max_LCD();
55
  void init();
56
  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
57
  void clear();
58
  void home();
59
  void noDisplay();
60
  void display();
61
  void noBlink();
62
  void blink();
63
  void noCursor();
64
  void cursor();
65
  void scrollDisplayLeft();
66
  void scrollDisplayRight();
67
  void leftToRight();
68
  void rightToLeft();
69
  void autoscroll();
70
  void noAutoscroll();
71
  void createChar(uint8_t, uint8_t[]);
72
  void setCursor(uint8_t, uint8_t);
73
  virtual void write(uint8_t);
74
  void command(uint8_t);
75
private:
76
  void sendbyte( uint8_t val );
77
  uint8_t _displayfunction; //tokill
78
  uint8_t _displaycontrol;
79
  uint8_t _displaymode;
80
  uint8_t _initialized;
81
  uint8_t _numlines,_currline;
82
};
83
 
84
 
85
 
86
 
87
#endif