blob: 109fc9d85c409cb4ff73a2c33227f9ba0a7446ec [file] [log] [blame]
Erik Gilling8a715652011-03-22 14:00:56 -07001/*
2 * Copyright 2009-2011 Oleg Mazurov, Circuits At Home, http://www.circuitsathome.com
3 * MAX3421E USB host controller support
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the authors nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
Joe Fernandezabc51592012-05-21 11:49:55 -070029
30//HD44780 compatible LCD display via MAX3421E GPOUT support header
31//pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
32//
33//this code is heavily borrowed from official Arduino source v.0017
34// link to original http://code.google.com/p/arduino/source/browse/trunk/hardware/libraries/LiquidCrystal/LiquidCrystal.h
35//
36#ifndef _Max_LCD_h_
37#define _Max_LCD_h_
38
39#include <inttypes.h>
40#include "Print.h"
41
42// commands
43#define LCD_CLEARDISPLAY 0x01
44#define LCD_RETURNHOME 0x02
45#define LCD_ENTRYMODESET 0x04
46#define LCD_DISPLAYCONTROL 0x08
47#define LCD_CURSORSHIFT 0x10
48#define LCD_FUNCTIONSET 0x20
49#define LCD_SETCGRAMADDR 0x40
50#define LCD_SETDDRAMADDR 0x80
51
52// flags for display entry mode
53#define LCD_ENTRYRIGHT 0x00
54#define LCD_ENTRYLEFT 0x02
55#define LCD_ENTRYSHIFTINCREMENT 0x01
56#define LCD_ENTRYSHIFTDECREMENT 0x00
57
58// flags for display on/off control
59#define LCD_DISPLAYON 0x04
60#define LCD_DISPLAYOFF 0x00
61#define LCD_CURSORON 0x02
62#define LCD_CURSOROFF 0x00
63#define LCD_BLINKON 0x01
64#define LCD_BLINKOFF 0x00
65
66// flags for display/cursor shift
67#define LCD_DISPLAYMOVE 0x08
68#define LCD_CURSORMOVE 0x00
69#define LCD_MOVERIGHT 0x04
70#define LCD_MOVELEFT 0x00
71
72// flags for function set
73#define LCD_8BITMODE 0x10
74#define LCD_4BITMODE 0x00
75#define LCD_2LINE 0x08
76#define LCD_1LINE 0x00
77#define LCD_5x10DOTS 0x04
78#define LCD_5x8DOTS 0x00
79
80class Max_LCD : public Print {
81public:
82 Max_LCD();
83 void init();
84 void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
85 void clear();
86 void home();
87 void noDisplay();
88 void display();
89 void noBlink();
90 void blink();
91 void noCursor();
92 void cursor();
93 void scrollDisplayLeft();
94 void scrollDisplayRight();
95 void leftToRight();
96 void rightToLeft();
97 void autoscroll();
98 void noAutoscroll();
99 void createChar(uint8_t, uint8_t[]);
100 void setCursor(uint8_t, uint8_t);
101 virtual size_t write(uint8_t);
102 void command(uint8_t);
103private:
104 void sendbyte( uint8_t val );
105 uint8_t _displayfunction; //tokill
106 uint8_t _displaycontrol;
107 uint8_t _displaymode;
108 uint8_t _initialized;
109 uint8_t _numlines,_currline;
110};
111
112
113
114
Erik Gilling8a715652011-03-22 14:00:56 -0700115#endif