From 2ab7603f31a340d162c38e61d4c8bad0f769d36f Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 7 Nov 2009 17:54:56 +0000 Subject: [PATCH 01/73] Moving libraries out of arduino platform / core directory and to top-level. --- LiquidCrystal.cpp | 309 +++++++++++++++++++++++ LiquidCrystal.h | 104 ++++++++ examples/Autoscroll/Autoscroll.pde | 70 +++++ examples/Blink/Blink.pde | 58 +++++ examples/Cursor/Cursor.pde | 58 +++++ examples/Display/Display.pde | 58 +++++ examples/HelloWorld/HelloWorld.pde | 56 ++++ examples/Scroll/Scroll.pde | 83 ++++++ examples/SerialDisplay/SerialDisplay.pde | 62 +++++ examples/TextDirection/TextDirection.pde | 84 ++++++ examples/setCursor/setCursor.pde | 68 +++++ keywords.txt | 37 +++ 12 files changed, 1047 insertions(+) create mode 100755 LiquidCrystal.cpp create mode 100755 LiquidCrystal.h create mode 100644 examples/Autoscroll/Autoscroll.pde create mode 100644 examples/Blink/Blink.pde create mode 100644 examples/Cursor/Cursor.pde create mode 100644 examples/Display/Display.pde create mode 100644 examples/HelloWorld/HelloWorld.pde create mode 100644 examples/Scroll/Scroll.pde create mode 100644 examples/SerialDisplay/SerialDisplay.pde create mode 100644 examples/TextDirection/TextDirection.pde create mode 100644 examples/setCursor/setCursor.pde create mode 100755 keywords.txt diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp new file mode 100755 index 0000000..b66f107 --- /dev/null +++ b/LiquidCrystal.cpp @@ -0,0 +1,309 @@ +#include "LiquidCrystal.h" + +#include +#include +#include +#include "WProgram.h" + +// When the display powers up, it is configured as follows: +// +// 1. Display clear +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift +// +// Note, however, that resetting the Arduino doesn't reset the LCD, so we +// can't assume that its in that state when a sketch starts (and the +// LiquidCrystal constructor is called). + +LiquidCrystal::LiquidCrystal(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) +{ + init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); +} + +LiquidCrystal::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) +{ + init(0, rs, -1, enable, d0, d1, d2, d3, d4, d5, d6, d7); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) +{ + init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) +{ + init(1, rs, -1, enable, d0, d1, d2, d3, 0, 0, 0, 0); +} + +void LiquidCrystal::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) +{ + _rs_pin = rs; + _rw_pin = rw; + _enable_pin = enable; + + _data_pins[0] = d0; + _data_pins[1] = d1; + _data_pins[2] = d2; + _data_pins[3] = d3; + _data_pins[4] = d4; + _data_pins[5] = d5; + _data_pins[6] = d6; + _data_pins[7] = d7; + + pinMode(_rs_pin, OUTPUT); + // we can save 1 pin by not using RW. Indicate by passing -1 instead of pin# + if (_rw_pin != -1) { + pinMode(_rw_pin, OUTPUT); + } + pinMode(_enable_pin, OUTPUT); + + if (fourbitmode) + _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; + else + _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; + + begin(16, 1); +} + +void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { + if (lines > 1) { + _displayfunction |= LCD_2LINE; + } + _numlines = lines; + _currline = 0; + + // for some 1 line displays you can select a 10 pixel high font + if ((dotsize != 0) && (lines == 1)) { + _displayfunction |= LCD_5x10DOTS; + } + + // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! + // according to datasheet, we need at least 40ms after power rises above 2.7V + // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 + delayMicroseconds(50000); + // Now we pull both RS and R/W low to begin commands + digitalWrite(_rs_pin, LOW); + digitalWrite(_enable_pin, LOW); + if (_rw_pin != -1) { + digitalWrite(_rw_pin, LOW); + } + + //put the LCD into 4 bit or 8 bit mode + if (! (_displayfunction & LCD_8BITMODE)) { + // this is according to the hitachi HD44780 datasheet + // figure 24, pg 46 + + // we start in 8bit mode, try to set 4 bit mode + write4bits(0x03); + delayMicroseconds(4500); // wait min 4.1ms + + // second try + write4bits(0x03); + delayMicroseconds(4500); // wait min 4.1ms + + // third go! + write4bits(0x03); + delayMicroseconds(150); + + // finally, set to 8-bit interface + write4bits(0x02); + } else { + // this is according to the hitachi HD44780 datasheet + // page 45 figure 23 + + // Send function set command sequence + command(LCD_FUNCTIONSET | _displayfunction); + delayMicroseconds(4500); // wait more than 4.1ms + + // second try + command(LCD_FUNCTIONSET | _displayfunction); + delayMicroseconds(150); + + // third go + command(LCD_FUNCTIONSET | _displayfunction); + } + + // finally, set # lines, font size, etc. + command(LCD_FUNCTIONSET | _displayfunction); + + // turn the display on with no cursor or blinking default + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + display(); + + // clear it off + clear(); + + // Initialize to default text direction (for romance languages) + _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; + // set the entry mode + command(LCD_ENTRYMODESET | _displaymode); + +} + +/********** high level commands, for the user! */ +void LiquidCrystal::clear() +{ + command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal::home() +{ + command(LCD_RETURNHOME); // set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal::setCursor(uint8_t col, uint8_t row) +{ + int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + if ( row > _numlines ) { + row = _numlines-1; // we count rows starting w/0 + } + + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); +} + +// Turn the display on/off (quickly) +void LiquidCrystal::noDisplay() { + _displaycontrol &= ~LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::display() { + _displaycontrol |= LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turns the underline cursor on/off +void LiquidCrystal::noCursor() { + _displaycontrol &= ~LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::cursor() { + _displaycontrol |= LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turn on and off the blinking cursor +void LiquidCrystal::noBlink() { + _displaycontrol &= ~LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::blink() { + _displaycontrol |= LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// These commands scroll the display without changing the RAM +void LiquidCrystal::scrollDisplayLeft(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); +} +void LiquidCrystal::scrollDisplayRight(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); +} + +// This is for text that flows Left to Right +void LiquidCrystal::leftToRight(void) { + _displaymode |= LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This is for text that flows Right to Left +void LiquidCrystal::rightToLeft(void) { + _displaymode &= ~LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'right justify' text from the cursor +void LiquidCrystal::autoscroll(void) { + _displaymode |= LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'left justify' text from the cursor +void LiquidCrystal::noAutoscroll(void) { + _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// Allows us to fill the first 8 CGRAM locations +// with custom characters +void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { + location &= 0x7; // we only have 8 locations 0-7 + command(LCD_SETCGRAMADDR | (location << 3)); + for (int i=0; i<8; i++) { + write(charmap[i]); + } +} + +/*********** mid level commands, for sending data/cmds */ + +inline void LiquidCrystal::command(uint8_t value) { + send(value, LOW); +} + +inline void LiquidCrystal::write(uint8_t value) { + send(value, HIGH); +} + +/************ low level data pushing commands **********/ + +// write either command or data, with automatic 4/8-bit selection +void LiquidCrystal::send(uint8_t value, uint8_t mode) { + digitalWrite(_rs_pin, mode); + + // if there is a RW pin indicated, set it low to Write + if (_rw_pin != -1) { + digitalWrite(_rw_pin, LOW); + } + + if (_displayfunction & LCD_8BITMODE) { + write8bits(value); + } else { + write4bits(value>>4); + write4bits(value); + } +} + +void LiquidCrystal::pulseEnable(void) { + digitalWrite(_enable_pin, LOW); + delayMicroseconds(1); + digitalWrite(_enable_pin, HIGH); + delayMicroseconds(1); // enable pulse must be >450ns + digitalWrite(_enable_pin, LOW); + delayMicroseconds(100); // commands need > 37us to settle +} + +void LiquidCrystal::write4bits(uint8_t value) { + for (int i = 0; i < 4; i++) { + pinMode(_data_pins[i], OUTPUT); + digitalWrite(_data_pins[i], (value >> i) & 0x01); + } + + pulseEnable(); +} + +void LiquidCrystal::write8bits(uint8_t value) { + for (int i = 0; i < 8; i++) { + pinMode(_data_pins[i], OUTPUT); + digitalWrite(_data_pins[i], (value >> i) & 0x01); + } + + pulseEnable(); +} diff --git a/LiquidCrystal.h b/LiquidCrystal.h new file mode 100755 index 0000000..f66ec1b --- /dev/null +++ b/LiquidCrystal.h @@ -0,0 +1,104 @@ +#ifndef LiquidCrystal_h +#define LiquidCrystal_h + +#include +#include "Print.h" + +// commands +#define LCD_CLEARDISPLAY 0x01 +#define LCD_RETURNHOME 0x02 +#define LCD_ENTRYMODESET 0x04 +#define LCD_DISPLAYCONTROL 0x08 +#define LCD_CURSORSHIFT 0x10 +#define LCD_FUNCTIONSET 0x20 +#define LCD_SETCGRAMADDR 0x40 +#define LCD_SETDDRAMADDR 0x80 + +// flags for display entry mode +#define LCD_ENTRYRIGHT 0x00 +#define LCD_ENTRYLEFT 0x02 +#define LCD_ENTRYSHIFTINCREMENT 0x01 +#define LCD_ENTRYSHIFTDECREMENT 0x00 + +// flags for display on/off control +#define LCD_DISPLAYON 0x04 +#define LCD_DISPLAYOFF 0x00 +#define LCD_CURSORON 0x02 +#define LCD_CURSOROFF 0x00 +#define LCD_BLINKON 0x01 +#define LCD_BLINKOFF 0x00 + +// flags for display/cursor shift +#define LCD_DISPLAYMOVE 0x08 +#define LCD_CURSORMOVE 0x00 +#define LCD_MOVERIGHT 0x04 +#define LCD_MOVELEFT 0x00 + +// flags for function set +#define LCD_8BITMODE 0x10 +#define LCD_4BITMODE 0x00 +#define LCD_2LINE 0x08 +#define LCD_1LINE 0x00 +#define LCD_5x10DOTS 0x04 +#define LCD_5x8DOTS 0x00 + +class LiquidCrystal : public Print { +public: + 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(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); + LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); + LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); + + 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); + + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); + + void clear(); + void home(); + + void noDisplay(); + void display(); + void noBlink(); + void blink(); + void noCursor(); + void cursor(); + void scrollDisplayLeft(); + void scrollDisplayRight(); + void leftToRight(); + void rightToLeft(); + void autoscroll(); + void noAutoscroll(); + + void createChar(uint8_t, uint8_t[]); + void setCursor(uint8_t, uint8_t); + virtual void write(uint8_t); + void command(uint8_t); +private: + void send(uint8_t, uint8_t); + void write4bits(uint8_t); + void write8bits(uint8_t); + void pulseEnable(); + + uint8_t _rs_pin; // LOW: command. HIGH: character. + uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. + uint8_t _enable_pin; // activated by a HIGH pulse. + uint8_t _data_pins[8]; + + uint8_t _displayfunction; + uint8_t _displaycontrol; + uint8_t _displaymode; + + uint8_t _initialized; + + uint8_t _numlines,_currline; +}; + +#endif diff --git a/examples/Autoscroll/Autoscroll.pde b/examples/Autoscroll/Autoscroll.pde new file mode 100644 index 0000000..bf33743 --- /dev/null +++ b/examples/Autoscroll/Autoscroll.pde @@ -0,0 +1,70 @@ +/* + LiquidCrystal Library - Autoscroll + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates the use of the autoscroll() + and noAutoscroll() functions to make new text scroll or not. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16,2); +} + +void loop() { + // set the cursor to (0,0): + lcd.setCursor(0, 0); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + + // set the cursor to (16,1): + lcd.setCursor(16,1); + // set the display to automatically scroll: + lcd.autoscroll(); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + // turn off automatic scrolling + lcd.noAutoscroll(); + + // clear screen for the next loop: + lcd.clear(); +} + diff --git a/examples/Blink/Blink.pde b/examples/Blink/Blink.pde new file mode 100644 index 0000000..83c79b4 --- /dev/null +++ b/examples/Blink/Blink.pde @@ -0,0 +1,58 @@ +/* + LiquidCrystal Library - Blink + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and makes the + cursor block blink. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the blinking cursor: + lcd.noBlink(); + delay(3000); + // Turn on the blinking cursor: + lcd.blink(); + delay(3000); +} + + diff --git a/examples/Cursor/Cursor.pde b/examples/Cursor/Cursor.pde new file mode 100644 index 0000000..c0273f4 --- /dev/null +++ b/examples/Cursor/Cursor.pde @@ -0,0 +1,58 @@ +/* + LiquidCrystal Library - Cursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and + uses the cursor() and noCursor() methods to turn + on and off the cursor. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the cursor: + lcd.noCursor(); + delay(500); + // Turn on the cursor: + lcd.cursor(); + delay(500); +} + diff --git a/examples/Display/Display.pde b/examples/Display/Display.pde new file mode 100644 index 0000000..b430539 --- /dev/null +++ b/examples/Display/Display.pde @@ -0,0 +1,58 @@ +/* + LiquidCrystal Library - display() and noDisplay() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + display() and noDisplay() functions to turn on and off + the display. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the display: + lcd.noDisplay(); + delay(500); + // Turn on the display: + lcd.display(); + delay(500); +} + diff --git a/examples/HelloWorld/HelloWorld.pde b/examples/HelloWorld/HelloWorld.pde new file mode 100644 index 0000000..76cd746 --- /dev/null +++ b/examples/HelloWorld/HelloWorld.pde @@ -0,0 +1,56 @@ +/* + LiquidCrystal Library - Hello World + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD + and shows the time. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // set the cursor to column 0, line 1 + // (note: line 1 is the second row, since counting begins with 0): + lcd.setCursor(0, 1); + // print the number of seconds since reset: + lcd.print(millis()/1000); +} + diff --git a/examples/Scroll/Scroll.pde b/examples/Scroll/Scroll.pde new file mode 100644 index 0000000..9276553 --- /dev/null +++ b/examples/Scroll/Scroll.pde @@ -0,0 +1,83 @@ +/* + LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + scrollDisplayLeft() and scrollDisplayRight() methods to scroll + the text. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + //lcd.setCursor(0,7); + // Print a message to the LCD. + lcd.print("hello, world!"); + delay(1000); +} + +void loop() { + // scroll 13 positions (string length) to the left + // to move it offscreen left: + for (int positionCounter = 0; positionCounter < 13; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // scroll 29 positions (string length + display length) to the right + // to move it offscreen right: + for (int positionCounter = 0; positionCounter < 29; positionCounter++) { + // scroll one position right: + lcd.scrollDisplayRight(); + // wait a bit: + delay(150); + } + + // scroll 16 positions (display length + string length) to the left + // to move it back to center: + for (int positionCounter = 0; positionCounter < 16; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // delay at the end of the full loop: + delay(1000); + +} + diff --git a/examples/SerialDisplay/SerialDisplay.pde b/examples/SerialDisplay/SerialDisplay.pde new file mode 100644 index 0000000..a094c24 --- /dev/null +++ b/examples/SerialDisplay/SerialDisplay.pde @@ -0,0 +1,62 @@ +/* + LiquidCrystal Library - Serial Input + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch displays text sent over the serial port + (e.g. from the Serial Monitor) on an attached LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe +modified 25 July 2009 + by David A. Mellis + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup(){ + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + // initialize the serial communications: + Serial.begin(9600); +} + +void loop() +{ + // when characters arrive over the serial port... + if (Serial.available()) { + // wait a bit for the entire message to arrive + delay(100); + // clear the screen + lcd.clear(); + // read all the available characters + while (Serial.available() > 0) { + // display each character to the LCD + lcd.write(Serial.read()); + } + } +} diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.pde new file mode 100644 index 0000000..725eb0d --- /dev/null +++ b/examples/TextDirection/TextDirection.pde @@ -0,0 +1,84 @@ + /* + LiquidCrystal Library - TextDirection + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates how to use leftToRight() and rightToLeft() + to move the cursor. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +int thisChar = 'a'; + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(16, 2); + // turn on the cursor: + lcd.cursor(); + Serial.begin(9600); +} + +void loop() { + // reverse directions at 'm': + if (thisChar == 'm') { + // go right for the next letter + lcd.rightToLeft(); + } + // reverse again at 's': + if (thisChar == 's') { + // go left for the next letter + lcd.leftToRight(); + } + // reset at 'z': + if (thisChar > 'z') { + // go to (0,0): + lcd.home(); + // start again at 0 + thisChar = 'a'; + } + // print the character + lcd.print(thisChar, BYTE); + // wait a second: + delay(1000); + // increment the letter: + thisChar++; +} + + + + + + + + diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.pde new file mode 100644 index 0000000..edd2e77 --- /dev/null +++ b/examples/setCursor/setCursor.pde @@ -0,0 +1,68 @@ +/* + LiquidCrystal Library - setCursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints to all the positions of the LCD using the + setCursor(0 method: + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 25 July 2009 + by David A. Mellis + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// these constants won't change. But you can change the size of +// your LCD using them: +const int numRows = 2; +const int numCols = 16; + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of rows and columns: + lcd.begin(numRows, numCols); +} + +void loop() { + // loop from ASCII 'a' to ASCII 'z': + for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { + // loop over the columns: + for (int thisCol = 0; thisCol < numRows; thisCol++) { + // loop over the rows: + for (int thisRow = 0; thisRow < numCols; thisRow++) { + // set the cursor position: + lcd.setCursor(thisRow,thisCol); + // print the letter: + lcd.print(thisLetter, BYTE); + delay(200); + } + } + } +} + + diff --git a/keywords.txt b/keywords.txt new file mode 100755 index 0000000..132845c --- /dev/null +++ b/keywords.txt @@ -0,0 +1,37 @@ +####################################### +# Syntax Coloring Map For LiquidCrystal +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LiquidCrystal KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +clear KEYWORD2 +home KEYWORD2 +print KEYWORD2 +setCursor KEYWORD2 +cursor KEYWORD2 +noCursor KEYWORD2 +blink KEYWORD2 +noBlink KEYWORD2 +display KEYWORD2 +noDisplay KEYWORD2 +autoscroll KEYWORD2 +noAutoscroll KEYWORD2 +leftToRight KEYWORD2 +rightToLeft KEYWORD2 +scrollDisplayLeft KEYWORD2 +scrollDisplayRight KEYWORD2 +createChar KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + From c12c9a39c9d27217440f5482d66de795f599a3f9 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 18 Dec 2009 16:36:45 +0000 Subject: [PATCH 02/73] Fixing RW pin bug in LiquidCrystal library. Now using 255 to disable pin instead of -1. --- LiquidCrystal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index b66f107..f2a4115 100755 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -35,7 +35,7 @@ LiquidCrystal::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) { - init(0, rs, -1, enable, d0, d1, d2, d3, d4, d5, d6, d7); + init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); } LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, @@ -47,7 +47,7 @@ LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) { - init(1, rs, -1, enable, d0, d1, d2, d3, 0, 0, 0, 0); + init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); } void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, @@ -68,8 +68,8 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); - // we can save 1 pin by not using RW. Indicate by passing -1 instead of pin# - if (_rw_pin != -1) { + // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); @@ -101,7 +101,7 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != -1) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } @@ -269,7 +269,7 @@ void LiquidCrystal::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != -1) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } From fefdbb886b21bed61f4a9d09b38119d6fe84e2f8 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:13:59 +0000 Subject: [PATCH 03/73] --- examples/HelloWorld/HelloWorld.pde | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/HelloWorld/HelloWorld.pde b/examples/HelloWorld/HelloWorld.pde index 76cd746..7418607 100644 --- a/examples/HelloWorld/HelloWorld.pde +++ b/examples/HelloWorld/HelloWorld.pde @@ -26,8 +26,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 8 Feb 2010 + by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal @@ -40,7 +40,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); From 6837803f218476ef2fc9dd29df17862044246a2e Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:21:13 +0000 Subject: [PATCH 04/73] Corrected comments in LiquidCrystal examples --- examples/Blink/Blink.pde | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Blink/Blink.pde b/examples/Blink/Blink.pde index 83c79b4..0b70a4e 100644 --- a/examples/Blink/Blink.pde +++ b/examples/Blink/Blink.pde @@ -26,8 +26,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 8 Feb 2010 + by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal @@ -40,7 +40,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); From d02b3aa0aa0bf0b6251584804c0cdf8a43c3bde4 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:24:18 +0000 Subject: [PATCH 05/73] Corrected comments in LiquidCrystal examples --- examples/Cursor/Cursor.pde | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Cursor/Cursor.pde b/examples/Cursor/Cursor.pde index c0273f4..461362b 100644 --- a/examples/Cursor/Cursor.pde +++ b/examples/Cursor/Cursor.pde @@ -27,8 +27,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 8 Feb 2010 + by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal @@ -41,7 +41,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); From 519f664f5ee429683a1c1bf3eee700c6a5b9a681 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:26:07 +0000 Subject: [PATCH 06/73] Corrected comments in LiquidCrystal examples --- examples/Display/Display.pde | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Display/Display.pde b/examples/Display/Display.pde index b430539..2e5c1df 100644 --- a/examples/Display/Display.pde +++ b/examples/Display/Display.pde @@ -27,8 +27,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 8 Feb 2010 + by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal @@ -41,7 +41,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); From 87aa682b17ef7e71dd25755dd6ce6515f2c94f42 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:31:21 +0000 Subject: [PATCH 07/73] Corrected comments in LiquidCrystal examples --- examples/TextDirection/TextDirection.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.pde index 725eb0d..c63bb10 100644 --- a/examples/TextDirection/TextDirection.pde +++ b/examples/TextDirection/TextDirection.pde @@ -42,7 +42,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int thisChar = 'a'; void setup() { - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // turn on the cursor: lcd.cursor(); From ed899cd2ddb2b7aa604cac7a682b577ba83a5950 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:34:07 +0000 Subject: [PATCH 08/73] Corrected comments in LiquidCrystal examples --- examples/SerialDisplay/SerialDisplay.pde | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/SerialDisplay/SerialDisplay.pde b/examples/SerialDisplay/SerialDisplay.pde index a094c24..49cc755 100644 --- a/examples/SerialDisplay/SerialDisplay.pde +++ b/examples/SerialDisplay/SerialDisplay.pde @@ -26,8 +26,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe -modified 25 July 2009 - by David A. Mellis + modified 8 Feb 2010 + by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal */ @@ -39,7 +39,7 @@ modified 25 July 2009 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup(){ - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // initialize the serial communications: Serial.begin(9600); From 4f93a8f0aaa5ad8ff9faf9b86bceeb41594d2033 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:35:15 +0000 Subject: [PATCH 09/73] Corrected comments in LiquidCrystal examples --- examples/setCursor/setCursor.pde | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.pde index edd2e77..ca6f62e 100644 --- a/examples/setCursor/setCursor.pde +++ b/examples/setCursor/setCursor.pde @@ -26,8 +26,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 8 Feb 2010 + by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal */ @@ -44,8 +44,8 @@ const int numCols = 16; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of rows and columns: - lcd.begin(numRows, numCols); + // set up the LCD's number of columns and rows: + lcd.begin(numCols,numRows); } void loop() { From 7c3dbd15e803e4f9058495bae5cfbd8f209e7cfc Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 8 Feb 2010 23:36:02 +0000 Subject: [PATCH 10/73] Corrected comments in LiquidCrystal examples --- examples/Scroll/Scroll.pde | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/Scroll/Scroll.pde b/examples/Scroll/Scroll.pde index 9276553..13493ee 100644 --- a/examples/Scroll/Scroll.pde +++ b/examples/Scroll/Scroll.pde @@ -40,9 +40,8 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of rows and columns: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); - //lcd.setCursor(0,7); // Print a message to the LCD. lcd.print("hello, world!"); delay(1000); From 19e9cbfe780ce7e8eb573e792eb56626348df292 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:20 +0000 Subject: [PATCH 11/73] Added public domain notice --- examples/Autoscroll/Autoscroll.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/Autoscroll/Autoscroll.pde b/examples/Autoscroll/Autoscroll.pde index bf33743..0352090 100644 --- a/examples/Autoscroll/Autoscroll.pde +++ b/examples/Autoscroll/Autoscroll.pde @@ -29,6 +29,8 @@ modified 25 July 2009 by David A. Mellis + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From 8bdf64511c69a1fb53555ca683bc04e5d047851d Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:25 +0000 Subject: [PATCH 12/73] Added public domain notice --- examples/Blink/Blink.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/Blink/Blink.pde b/examples/Blink/Blink.pde index 0b70a4e..5156336 100644 --- a/examples/Blink/Blink.pde +++ b/examples/Blink/Blink.pde @@ -29,6 +29,8 @@ modified 8 Feb 2010 by Tom Igoe + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From 1c469e2182fc7cdcffc60ef4200bdba56f509fe3 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:28 +0000 Subject: [PATCH 13/73] Added public domain notice --- examples/Cursor/Cursor.pde | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/Cursor/Cursor.pde b/examples/Cursor/Cursor.pde index 461362b..efc49cc 100644 --- a/examples/Cursor/Cursor.pde +++ b/examples/Cursor/Cursor.pde @@ -30,7 +30,8 @@ modified 8 Feb 2010 by Tom Igoe - + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From 04ab873ee05a73bbd5950bbaa22da671c1fc7bd4 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:34 +0000 Subject: [PATCH 14/73] Added public domain notice --- examples/Display/Display.pde | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/Display/Display.pde b/examples/Display/Display.pde index 2e5c1df..e9196c7 100644 --- a/examples/Display/Display.pde +++ b/examples/Display/Display.pde @@ -30,7 +30,8 @@ modified 8 Feb 2010 by Tom Igoe - + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From be83c22a9a852c730aaa129b634d0ee56dd21082 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:38 +0000 Subject: [PATCH 15/73] Added public domain notice --- examples/HelloWorld/HelloWorld.pde | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/HelloWorld/HelloWorld.pde b/examples/HelloWorld/HelloWorld.pde index 7418607..17116a3 100644 --- a/examples/HelloWorld/HelloWorld.pde +++ b/examples/HelloWorld/HelloWorld.pde @@ -29,7 +29,8 @@ modified 8 Feb 2010 by Tom Igoe - + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From 20b258275ddc36f2612fea802e5d404dd2906c8b Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:43 +0000 Subject: [PATCH 16/73] Added public domain notice --- examples/Scroll/Scroll.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/Scroll/Scroll.pde b/examples/Scroll/Scroll.pde index 13493ee..edc95cc 100644 --- a/examples/Scroll/Scroll.pde +++ b/examples/Scroll/Scroll.pde @@ -30,6 +30,8 @@ modified 25 July 2009 by David A. Mellis + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From e2e448b49e97132da20e0315f33af96f6d7b1490 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:44 +0000 Subject: [PATCH 17/73] Added public domain notice --- examples/SerialDisplay/SerialDisplay.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/SerialDisplay/SerialDisplay.pde b/examples/SerialDisplay/SerialDisplay.pde index 49cc755..aa977f4 100644 --- a/examples/SerialDisplay/SerialDisplay.pde +++ b/examples/SerialDisplay/SerialDisplay.pde @@ -29,6 +29,8 @@ modified 8 Feb 2010 by Tom Igoe + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From cd518fbf5cd970637466d5f253246ab6cb81a799 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:48:54 +0000 Subject: [PATCH 18/73] Added public domain notice --- examples/setCursor/setCursor.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.pde index ca6f62e..bc85c8a 100644 --- a/examples/setCursor/setCursor.pde +++ b/examples/setCursor/setCursor.pde @@ -29,6 +29,8 @@ modified 8 Feb 2010 by Tom Igoe + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From 67133486a322ddd8aa51af78b420e4e3c7524c7c Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Wed, 24 Feb 2010 03:49:03 +0000 Subject: [PATCH 19/73] Added public domain notice --- examples/TextDirection/TextDirection.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.pde index c63bb10..b115c76 100644 --- a/examples/TextDirection/TextDirection.pde +++ b/examples/TextDirection/TextDirection.pde @@ -29,6 +29,8 @@ modified 25 July 2009 by David A. Mellis + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal */ From 6d2658c0367e08f4a04e07a0a86a92735b5c9d3f Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 2 Aug 2010 22:22:51 +0000 Subject: [PATCH 20/73] Adding #include . --- LiquidCrystal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/LiquidCrystal.h b/LiquidCrystal.h index f66ec1b..572c139 100755 --- a/LiquidCrystal.h +++ b/LiquidCrystal.h @@ -2,6 +2,7 @@ #define LiquidCrystal_h #include +#include "WProgram.h" #include "Print.h" // commands From 338f67fa3cfbe9240c8deb63b6d8be869a3468dc Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 6 Aug 2010 01:23:19 +0000 Subject: [PATCH 21/73] No longer requiring WProgram.h for Print / Stream classes (replaced Arduino-specific type names in String). --- LiquidCrystal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/LiquidCrystal.h b/LiquidCrystal.h index 572c139..f66ec1b 100755 --- a/LiquidCrystal.h +++ b/LiquidCrystal.h @@ -2,7 +2,6 @@ #define LiquidCrystal_h #include -#include "WProgram.h" #include "Print.h" // commands From 8ea7c002c5ce1b6fa78b0ab5aa7d89b8e9a85a6b Mon Sep 17 00:00:00 2001 From: Joshua Nussbaum Date: Fri, 1 Oct 2010 00:26:40 -0700 Subject: [PATCH 22/73] When initializing LCD, comment specified "8-bit" mode when it should day "4 bit mode" --- LiquidCrystal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 LiquidCrystal.cpp diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp old mode 100755 new mode 100644 index f2a4115..23713f4 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -122,7 +122,7 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { write4bits(0x03); delayMicroseconds(150); - // finally, set to 8-bit interface + // finally, set to 4-bit interface write4bits(0x02); } else { // this is according to the hitachi HD44780 datasheet From a2ce323bae2b740df10c57128c33a321d1024872 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 22 Nov 2010 09:36:23 -0500 Subject: [PATCH 23/73] fixed comments in LIquidCrystal examples per issue 402 --- examples/Autoscroll/Autoscroll.pde | 5 +++-- examples/Blink/Blink.pde | 3 ++- examples/Cursor/Cursor.pde | 3 ++- examples/Display/Display.pde | 3 ++- examples/HelloWorld/HelloWorld.pde | 3 ++- examples/Scroll/Scroll.pde | 5 +++-- examples/SerialDisplay/SerialDisplay.pde | 3 ++- examples/TextDirection/TextDirection.pde | 5 +++-- examples/setCursor/setCursor.pde | 3 ++- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/examples/Autoscroll/Autoscroll.pde b/examples/Autoscroll/Autoscroll.pde index 0352090..27123ad 100644 --- a/examples/Autoscroll/Autoscroll.pde +++ b/examples/Autoscroll/Autoscroll.pde @@ -16,6 +16,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -26,8 +27,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 22 Nov 2010 + by Tom Igoe This example code is in the public domain. diff --git a/examples/Blink/Blink.pde b/examples/Blink/Blink.pde index 5156336..e410424 100644 --- a/examples/Blink/Blink.pde +++ b/examples/Blink/Blink.pde @@ -16,6 +16,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -26,7 +27,7 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 8 Feb 2010 + modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. diff --git a/examples/Cursor/Cursor.pde b/examples/Cursor/Cursor.pde index efc49cc..28e2a6a 100644 --- a/examples/Cursor/Cursor.pde +++ b/examples/Cursor/Cursor.pde @@ -17,6 +17,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -27,7 +28,7 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 8 Feb 2010 + modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. diff --git a/examples/Display/Display.pde b/examples/Display/Display.pde index e9196c7..b000731 100644 --- a/examples/Display/Display.pde +++ b/examples/Display/Display.pde @@ -17,6 +17,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -27,7 +28,7 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 8 Feb 2010 + modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. diff --git a/examples/HelloWorld/HelloWorld.pde b/examples/HelloWorld/HelloWorld.pde index 17116a3..e99957d 100644 --- a/examples/HelloWorld/HelloWorld.pde +++ b/examples/HelloWorld/HelloWorld.pde @@ -16,6 +16,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -26,7 +27,7 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 8 Feb 2010 + modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. diff --git a/examples/Scroll/Scroll.pde b/examples/Scroll/Scroll.pde index edc95cc..71e5e8c 100644 --- a/examples/Scroll/Scroll.pde +++ b/examples/Scroll/Scroll.pde @@ -17,6 +17,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -27,8 +28,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 22 Nov 2010 + by Tom Igoe This example code is in the public domain. diff --git a/examples/SerialDisplay/SerialDisplay.pde b/examples/SerialDisplay/SerialDisplay.pde index aa977f4..9727cee 100644 --- a/examples/SerialDisplay/SerialDisplay.pde +++ b/examples/SerialDisplay/SerialDisplay.pde @@ -16,6 +16,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -26,7 +27,7 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 8 Feb 2010 + modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.pde index b115c76..30e4ac5 100644 --- a/examples/TextDirection/TextDirection.pde +++ b/examples/TextDirection/TextDirection.pde @@ -16,6 +16,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -26,8 +27,8 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 25 July 2009 - by David A. Mellis + modified 22 Nov 2010 + by Tom Igoe This example code is in the public domain. diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.pde index bc85c8a..279f3ec 100644 --- a/examples/setCursor/setCursor.pde +++ b/examples/setCursor/setCursor.pde @@ -16,6 +16,7 @@ * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) @@ -26,7 +27,7 @@ by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe - modified 8 Feb 2010 + modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. From eecd3b3f4369a44d3473cada9bfd4871e91e83eb Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 26 Feb 2011 13:57:41 -0500 Subject: [PATCH 24/73] Modifying examples to use Serial.write() instead of Serial.print(BYTE). --- examples/TextDirection/TextDirection.pde | 2 +- examples/setCursor/setCursor.pde | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.pde index 30e4ac5..51bab1f 100644 --- a/examples/TextDirection/TextDirection.pde +++ b/examples/TextDirection/TextDirection.pde @@ -71,7 +71,7 @@ void loop() { thisChar = 'a'; } // print the character - lcd.print(thisChar, BYTE); + lcd.write(thisChar); // wait a second: delay(1000); // increment the letter: diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.pde index 279f3ec..3c4edf3 100644 --- a/examples/setCursor/setCursor.pde +++ b/examples/setCursor/setCursor.pde @@ -61,7 +61,7 @@ void loop() { // set the cursor position: lcd.setCursor(thisRow,thisCol); // print the letter: - lcd.print(thisLetter, BYTE); + lcd.write(thisLetter); delay(200); } } From 4eac8d47696cec1dc1a29ab540b56afd8933ca0b Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 26 Feb 2011 13:57:41 -0500 Subject: [PATCH 25/73] Modifying examples to use Serial.write() instead of Serial.print(BYTE). --- examples/TextDirection/TextDirection.pde | 2 +- examples/setCursor/setCursor.pde | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.pde index 30e4ac5..51bab1f 100644 --- a/examples/TextDirection/TextDirection.pde +++ b/examples/TextDirection/TextDirection.pde @@ -71,7 +71,7 @@ void loop() { thisChar = 'a'; } // print the character - lcd.print(thisChar, BYTE); + lcd.write(thisChar); // wait a second: delay(1000); // increment the letter: diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.pde index 279f3ec..3c4edf3 100644 --- a/examples/setCursor/setCursor.pde +++ b/examples/setCursor/setCursor.pde @@ -61,7 +61,7 @@ void loop() { // set the cursor position: lcd.setCursor(thisRow,thisCol); // print the letter: - lcd.print(thisLetter, BYTE); + lcd.write(thisLetter); delay(200); } } From e152e12bf9845915764838e17952a42d4a961720 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 1 Mar 2011 19:52:13 -0500 Subject: [PATCH 26/73] Renamed WProgram.h to Arduino.h. --- LiquidCrystal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index 23713f4..04d0f50 100644 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "WProgram.h" +#include "Arduino.h" // When the display powers up, it is configured as follows: // From 1a9759a112d14a1952f0fa23abcd00d60d1030f4 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 21 Mar 2011 12:27:18 -0400 Subject: [PATCH 27/73] Added example to demonstrate LiquidCrystal chreateChar() function --- examples/CustomCharacter/CustomCharacter.pde | 138 +++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 examples/CustomCharacter/CustomCharacter.pde diff --git a/examples/CustomCharacter/CustomCharacter.pde b/examples/CustomCharacter/CustomCharacter.pde new file mode 100644 index 0000000..d3ce479 --- /dev/null +++ b/examples/CustomCharacter/CustomCharacter.pde @@ -0,0 +1,138 @@ +/* + LiquidCrystal Library - Custom Characters + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of + them out there, and you can usually tell them by the 16-pin interface. + + This sketch prints "I Arduino!" and a little dancing man + to the LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K potentiometer: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + * 10K poterntiometer on pin A0 + + created21 Mar 2011 + by Tom Igoe + Based on Adafruit's example at + https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde + + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + Also useful: + http://icontexto.com/charactercreator/ + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +// make some custom characters: +byte heart[8] = { + 0b00000, + 0b01010, + 0b11111, + 0b11111, + 0b11111, + 0b01110, + 0b00100, + 0b00000 +}; + +byte smiley[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b10001, + 0b01110, + 0b00000 +}; + +byte frownie[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b00000, + 0b01110, + 0b10001 +}; + +byte armsDown[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b00100, + 0b01110, + 0b10101, + 0b00100, + 0b01010 +}; + +byte armsUp[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b10101, + 0b01110, + 0b00100, + 0b00100, + 0b01010 +}; +void setup() { + // create a new character + lcd.createChar(0, heart); + // create a new character + lcd.createChar(1, smiley); + // create a new character + lcd.createChar(2, frownie); + // create a new character + lcd.createChar(3, armsDown); + // create a new character + lcd.createChar(4, armsUp); + + // set up the lcd's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the lcd. + lcd.print("I "); + lcd.write(0); + lcd.print(" Arduino! "); + lcd.write(1); + +} + +void loop() { + // read the potentiometer on A0: + int sensorReading = analogRead(A0); + // map the result to 200 - 1000: + int delayTime = map(sensorReading, 0, 1023, 200, 1000); + // set the cursor to the bottom row, 5th position: + lcd.setCursor(4, 1); + // draw the little man, arms down: + lcd.write(3); + delay(delayTime); + lcd.setCursor(4, 1); + // draw him arms up: + lcd.write(4); + delay(delayTime); +} + + + From f3ea1afd0411a7d79809db5c4d8a26beccfd0003 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Mon, 21 Mar 2011 12:27:18 -0400 Subject: [PATCH 28/73] Added example to demonstrate LiquidCrystal chreateChar() function --- examples/CustomCharacter/CustomCharacter.pde | 138 +++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 examples/CustomCharacter/CustomCharacter.pde diff --git a/examples/CustomCharacter/CustomCharacter.pde b/examples/CustomCharacter/CustomCharacter.pde new file mode 100644 index 0000000..d3ce479 --- /dev/null +++ b/examples/CustomCharacter/CustomCharacter.pde @@ -0,0 +1,138 @@ +/* + LiquidCrystal Library - Custom Characters + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of + them out there, and you can usually tell them by the 16-pin interface. + + This sketch prints "I Arduino!" and a little dancing man + to the LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K potentiometer: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + * 10K poterntiometer on pin A0 + + created21 Mar 2011 + by Tom Igoe + Based on Adafruit's example at + https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde + + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + Also useful: + http://icontexto.com/charactercreator/ + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +// make some custom characters: +byte heart[8] = { + 0b00000, + 0b01010, + 0b11111, + 0b11111, + 0b11111, + 0b01110, + 0b00100, + 0b00000 +}; + +byte smiley[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b10001, + 0b01110, + 0b00000 +}; + +byte frownie[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b00000, + 0b01110, + 0b10001 +}; + +byte armsDown[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b00100, + 0b01110, + 0b10101, + 0b00100, + 0b01010 +}; + +byte armsUp[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b10101, + 0b01110, + 0b00100, + 0b00100, + 0b01010 +}; +void setup() { + // create a new character + lcd.createChar(0, heart); + // create a new character + lcd.createChar(1, smiley); + // create a new character + lcd.createChar(2, frownie); + // create a new character + lcd.createChar(3, armsDown); + // create a new character + lcd.createChar(4, armsUp); + + // set up the lcd's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the lcd. + lcd.print("I "); + lcd.write(0); + lcd.print(" Arduino! "); + lcd.write(1); + +} + +void loop() { + // read the potentiometer on A0: + int sensorReading = analogRead(A0); + // map the result to 200 - 1000: + int delayTime = map(sensorReading, 0, 1023, 200, 1000); + // set the cursor to the bottom row, 5th position: + lcd.setCursor(4, 1); + // draw the little man, arms down: + lcd.write(3); + delay(delayTime); + lcd.setCursor(4, 1); + // draw him arms up: + lcd.write(4); + delay(delayTime); +} + + + From 46ff301e259b2befa0f83b1be9fdc7e8bdb183e4 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 23 Aug 2011 19:12:03 -0400 Subject: [PATCH 29/73] write(), print(), and println() now return number of bytes written. The type is long, and negative values indicate errors. Needs more testing. http://code.google.com/p/arduino/issues/detail?id=551 --- LiquidCrystal.cpp | 3 ++- LiquidCrystal.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index 04d0f50..53119df 100644 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -258,8 +258,9 @@ inline void LiquidCrystal::command(uint8_t value) { send(value, LOW); } -inline void LiquidCrystal::write(uint8_t value) { +inline long LiquidCrystal::write(uint8_t value) { send(value, HIGH); + return 1; // assume sucess } /************ low level data pushing commands **********/ diff --git a/LiquidCrystal.h b/LiquidCrystal.h index f66ec1b..2788fe0 100755 --- a/LiquidCrystal.h +++ b/LiquidCrystal.h @@ -79,7 +79,7 @@ public: void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - virtual void write(uint8_t); + virtual long write(uint8_t); void command(uint8_t); private: void send(uint8_t, uint8_t); From 39582bc7a9996829c15ab3e4746a75a3971322c9 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 26 Aug 2011 14:20:41 -0400 Subject: [PATCH 30/73] Changing from long to ssize_t (int) for write(), print(), println() return. --- LiquidCrystal.cpp | 2 +- LiquidCrystal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index 53119df..67f4694 100644 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -258,7 +258,7 @@ inline void LiquidCrystal::command(uint8_t value) { send(value, LOW); } -inline long LiquidCrystal::write(uint8_t value) { +inline ssize_t LiquidCrystal::write(uint8_t value) { send(value, HIGH); return 1; // assume sucess } diff --git a/LiquidCrystal.h b/LiquidCrystal.h index 2788fe0..4491424 100755 --- a/LiquidCrystal.h +++ b/LiquidCrystal.h @@ -79,7 +79,7 @@ public: void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - virtual long write(uint8_t); + virtual ssize_t write(uint8_t); void command(uint8_t); private: void send(uint8_t, uint8_t); From 856e5dcfa49899ac9231ee2f78c1dc9ab66681a2 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 26 Aug 2011 16:08:14 -0400 Subject: [PATCH 31/73] Moving write errors out of return value into separate API methods. write(), print(), println() now return size_t (and don't use negative values to signal errors). Print adds writeError() for checking for write errors, clearWriteError() to reset the flag to false, and a protected setWriteError() for signalling errors. http://code.google.com/p/arduino/issues/detail?id=598 --- LiquidCrystal.cpp | 2 +- LiquidCrystal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index 67f4694..81a3b7f 100644 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -258,7 +258,7 @@ inline void LiquidCrystal::command(uint8_t value) { send(value, LOW); } -inline ssize_t LiquidCrystal::write(uint8_t value) { +inline size_t LiquidCrystal::write(uint8_t value) { send(value, HIGH); return 1; // assume sucess } diff --git a/LiquidCrystal.h b/LiquidCrystal.h index 4491424..f4352f3 100755 --- a/LiquidCrystal.h +++ b/LiquidCrystal.h @@ -79,7 +79,7 @@ public: void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - virtual ssize_t write(uint8_t); + virtual size_t write(uint8_t); void command(uint8_t); private: void send(uint8_t, uint8_t); From 6530a3b218c91899f38d2eead1891322463a17a2 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Tue, 30 Aug 2011 15:33:32 -0400 Subject: [PATCH 32/73] Changed all .pde examples to .ino All examples in /build/shared/examples/ and /libraries/ have had their extensions changed to .ino --- examples/Autoscroll/{Autoscroll.pde => Autoscroll.ino} | 0 examples/Blink/{Blink.pde => Blink.ino} | 0 examples/Cursor/{Cursor.pde => Cursor.ino} | 0 .../CustomCharacter/{CustomCharacter.pde => CustomCharacter.ino} | 0 examples/Display/{Display.pde => Display.ino} | 0 examples/HelloWorld/{HelloWorld.pde => HelloWorld.ino} | 0 examples/Scroll/{Scroll.pde => Scroll.ino} | 0 examples/SerialDisplay/{SerialDisplay.pde => SerialDisplay.ino} | 0 examples/TextDirection/{TextDirection.pde => TextDirection.ino} | 0 examples/setCursor/{setCursor.pde => setCursor.ino} | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename examples/Autoscroll/{Autoscroll.pde => Autoscroll.ino} (100%) rename examples/Blink/{Blink.pde => Blink.ino} (100%) rename examples/Cursor/{Cursor.pde => Cursor.ino} (100%) rename examples/CustomCharacter/{CustomCharacter.pde => CustomCharacter.ino} (100%) rename examples/Display/{Display.pde => Display.ino} (100%) rename examples/HelloWorld/{HelloWorld.pde => HelloWorld.ino} (100%) rename examples/Scroll/{Scroll.pde => Scroll.ino} (100%) rename examples/SerialDisplay/{SerialDisplay.pde => SerialDisplay.ino} (100%) rename examples/TextDirection/{TextDirection.pde => TextDirection.ino} (100%) rename examples/setCursor/{setCursor.pde => setCursor.ino} (100%) diff --git a/examples/Autoscroll/Autoscroll.pde b/examples/Autoscroll/Autoscroll.ino similarity index 100% rename from examples/Autoscroll/Autoscroll.pde rename to examples/Autoscroll/Autoscroll.ino diff --git a/examples/Blink/Blink.pde b/examples/Blink/Blink.ino similarity index 100% rename from examples/Blink/Blink.pde rename to examples/Blink/Blink.ino diff --git a/examples/Cursor/Cursor.pde b/examples/Cursor/Cursor.ino similarity index 100% rename from examples/Cursor/Cursor.pde rename to examples/Cursor/Cursor.ino diff --git a/examples/CustomCharacter/CustomCharacter.pde b/examples/CustomCharacter/CustomCharacter.ino similarity index 100% rename from examples/CustomCharacter/CustomCharacter.pde rename to examples/CustomCharacter/CustomCharacter.ino diff --git a/examples/Display/Display.pde b/examples/Display/Display.ino similarity index 100% rename from examples/Display/Display.pde rename to examples/Display/Display.ino diff --git a/examples/HelloWorld/HelloWorld.pde b/examples/HelloWorld/HelloWorld.ino similarity index 100% rename from examples/HelloWorld/HelloWorld.pde rename to examples/HelloWorld/HelloWorld.ino diff --git a/examples/Scroll/Scroll.pde b/examples/Scroll/Scroll.ino similarity index 100% rename from examples/Scroll/Scroll.pde rename to examples/Scroll/Scroll.ino diff --git a/examples/SerialDisplay/SerialDisplay.pde b/examples/SerialDisplay/SerialDisplay.ino similarity index 100% rename from examples/SerialDisplay/SerialDisplay.pde rename to examples/SerialDisplay/SerialDisplay.ino diff --git a/examples/TextDirection/TextDirection.pde b/examples/TextDirection/TextDirection.ino similarity index 100% rename from examples/TextDirection/TextDirection.pde rename to examples/TextDirection/TextDirection.ino diff --git a/examples/setCursor/setCursor.pde b/examples/setCursor/setCursor.ino similarity index 100% rename from examples/setCursor/setCursor.pde rename to examples/setCursor/setCursor.ino From b90a84c7638c3df40fa72af19bd4dc0f9cb9182d Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 7 Sep 2011 18:41:05 -0400 Subject: [PATCH 33/73] Making Print::write(char *) non-virtual. http://code.google.com/p/arduino/issues/detail?id=607 --- LiquidCrystal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LiquidCrystal.h b/LiquidCrystal.h index f4352f3..24ec5af 100755 --- a/LiquidCrystal.h +++ b/LiquidCrystal.h @@ -81,6 +81,8 @@ public: void setCursor(uint8_t, uint8_t); virtual size_t write(uint8_t); void command(uint8_t); + + using Print::write; private: void send(uint8_t, uint8_t); void write4bits(uint8_t); From 247e3b8be0507b77eefb44780f1da8fe56421e97 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 10 Oct 2011 12:35:36 -0400 Subject: [PATCH 34/73] Fixing bug in LiquidCrystal::setCursor() for row == numrows. http://code.google.com/p/arduino/issues/detail?id=671 --- LiquidCrystal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index 81a3b7f..0653487 100644 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -173,7 +173,7 @@ void LiquidCrystal::home() void LiquidCrystal::setCursor(uint8_t col, uint8_t row) { int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; - if ( row > _numlines ) { + if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } From 84638cbd988258a5d483e66a625ffe1ccf793ceb Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Thu, 27 Oct 2011 11:45:13 -0400 Subject: [PATCH 35/73] Revert "Merge branch 'master' of github.com:arduino/Arduino into diskloader_reboot" This reverts commit df9835efafd13685251749bc210c0b96a18a96a5, reversing changes made to ec45af8bfa9222a807c075dd1db4b5aa798bba03. Conflicts: hardware/arduino/variants/mega/pins_arduino.h libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino --- examples/CustomCharacter/CustomCharacter.pde | 138 ------------------- 1 file changed, 138 deletions(-) delete mode 100644 examples/CustomCharacter/CustomCharacter.pde diff --git a/examples/CustomCharacter/CustomCharacter.pde b/examples/CustomCharacter/CustomCharacter.pde deleted file mode 100644 index d3ce479..0000000 --- a/examples/CustomCharacter/CustomCharacter.pde +++ /dev/null @@ -1,138 +0,0 @@ -/* - LiquidCrystal Library - Custom Characters - - Demonstrates how to add custom characters on an LCD display. - The LiquidCrystal library works with all LCD displays that are - compatible with the Hitachi HD44780 driver. There are many of - them out there, and you can usually tell them by the 16-pin interface. - - This sketch prints "I Arduino!" and a little dancing man - to the LCD. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K potentiometer: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - * 10K poterntiometer on pin A0 - - created21 Mar 2011 - by Tom Igoe - Based on Adafruit's example at - https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde - - This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal - - Also useful: - http://icontexto.com/charactercreator/ - - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -// make some custom characters: -byte heart[8] = { - 0b00000, - 0b01010, - 0b11111, - 0b11111, - 0b11111, - 0b01110, - 0b00100, - 0b00000 -}; - -byte smiley[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b10001, - 0b01110, - 0b00000 -}; - -byte frownie[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b00000, - 0b01110, - 0b10001 -}; - -byte armsDown[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b00100, - 0b01110, - 0b10101, - 0b00100, - 0b01010 -}; - -byte armsUp[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b10101, - 0b01110, - 0b00100, - 0b00100, - 0b01010 -}; -void setup() { - // create a new character - lcd.createChar(0, heart); - // create a new character - lcd.createChar(1, smiley); - // create a new character - lcd.createChar(2, frownie); - // create a new character - lcd.createChar(3, armsDown); - // create a new character - lcd.createChar(4, armsUp); - - // set up the lcd's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the lcd. - lcd.print("I "); - lcd.write(0); - lcd.print(" Arduino! "); - lcd.write(1); - -} - -void loop() { - // read the potentiometer on A0: - int sensorReading = analogRead(A0); - // map the result to 200 - 1000: - int delayTime = map(sensorReading, 0, 1023, 200, 1000); - // set the cursor to the bottom row, 5th position: - lcd.setCursor(4, 1); - // draw the little man, arms down: - lcd.write(3); - delay(delayTime); - lcd.setCursor(4, 1); - // draw him arms up: - lcd.write(4); - delay(delayTime); -} - - - From 904942006ea36cd5895962d5274e92ea3729dc2c Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 4 Jan 2012 15:14:51 +0100 Subject: [PATCH 36/73] Moved libraries folder inside platform folder. Now libraries and examples are searched per board/platform --- LiquidCrystal.cpp | 310 ------------------- LiquidCrystal.h | 106 ------- examples/Autoscroll/Autoscroll.ino | 73 ----- examples/Blink/Blink.ino | 61 ---- examples/Cursor/Cursor.ino | 60 ---- examples/CustomCharacter/CustomCharacter.ino | 138 --------- examples/Display/Display.ino | 60 ---- examples/HelloWorld/HelloWorld.ino | 58 ---- examples/Scroll/Scroll.ino | 85 ----- examples/SerialDisplay/SerialDisplay.ino | 65 ---- examples/TextDirection/TextDirection.ino | 87 ------ examples/setCursor/setCursor.ino | 71 ----- keywords.txt | 37 --- 13 files changed, 1211 deletions(-) delete mode 100644 LiquidCrystal.cpp delete mode 100755 LiquidCrystal.h delete mode 100644 examples/Autoscroll/Autoscroll.ino delete mode 100644 examples/Blink/Blink.ino delete mode 100644 examples/Cursor/Cursor.ino delete mode 100644 examples/CustomCharacter/CustomCharacter.ino delete mode 100644 examples/Display/Display.ino delete mode 100644 examples/HelloWorld/HelloWorld.ino delete mode 100644 examples/Scroll/Scroll.ino delete mode 100644 examples/SerialDisplay/SerialDisplay.ino delete mode 100644 examples/TextDirection/TextDirection.ino delete mode 100644 examples/setCursor/setCursor.ino delete mode 100755 keywords.txt diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp deleted file mode 100644 index 0653487..0000000 --- a/LiquidCrystal.cpp +++ /dev/null @@ -1,310 +0,0 @@ -#include "LiquidCrystal.h" - -#include -#include -#include -#include "Arduino.h" - -// When the display powers up, it is configured as follows: -// -// 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift -// -// Note, however, that resetting the Arduino doesn't reset the LCD, so we -// can't assume that its in that state when a sketch starts (and the -// LiquidCrystal constructor is called). - -LiquidCrystal::LiquidCrystal(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) -{ - init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::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) -{ - init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) -{ - init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) -{ - init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -void LiquidCrystal::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) -{ - _rs_pin = rs; - _rw_pin = rw; - _enable_pin = enable; - - _data_pins[0] = d0; - _data_pins[1] = d1; - _data_pins[2] = d2; - _data_pins[3] = d3; - _data_pins[4] = d4; - _data_pins[5] = d5; - _data_pins[6] = d6; - _data_pins[7] = d7; - - pinMode(_rs_pin, OUTPUT); - // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { - pinMode(_rw_pin, OUTPUT); - } - pinMode(_enable_pin, OUTPUT); - - if (fourbitmode) - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else - _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); -} - -void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { - if (lines > 1) { - _displayfunction |= LCD_2LINE; - } - _numlines = lines; - _currline = 0; - - // for some 1 line displays you can select a 10 pixel high font - if ((dotsize != 0) && (lines == 1)) { - _displayfunction |= LCD_5x10DOTS; - } - - // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! - // according to datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 - delayMicroseconds(50000); - // Now we pull both RS and R/W low to begin commands - digitalWrite(_rs_pin, LOW); - digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { - digitalWrite(_rw_pin, LOW); - } - - //put the LCD into 4 bit or 8 bit mode - if (! (_displayfunction & LCD_8BITMODE)) { - // this is according to the hitachi HD44780 datasheet - // figure 24, pg 46 - - // we start in 8bit mode, try to set 4 bit mode - write4bits(0x03); - delayMicroseconds(4500); // wait min 4.1ms - - // second try - write4bits(0x03); - delayMicroseconds(4500); // wait min 4.1ms - - // third go! - write4bits(0x03); - delayMicroseconds(150); - - // finally, set to 4-bit interface - write4bits(0x02); - } else { - // this is according to the hitachi HD44780 datasheet - // page 45 figure 23 - - // Send function set command sequence - command(LCD_FUNCTIONSET | _displayfunction); - delayMicroseconds(4500); // wait more than 4.1ms - - // second try - command(LCD_FUNCTIONSET | _displayfunction); - delayMicroseconds(150); - - // third go - command(LCD_FUNCTIONSET | _displayfunction); - } - - // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); - - // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - display(); - - // clear it off - clear(); - - // Initialize to default text direction (for romance languages) - _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - // set the entry mode - command(LCD_ENTRYMODESET | _displaymode); - -} - -/********** high level commands, for the user! */ -void LiquidCrystal::clear() -{ - command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - delayMicroseconds(2000); // this command takes a long time! -} - -void LiquidCrystal::home() -{ - command(LCD_RETURNHOME); // set cursor position to zero - delayMicroseconds(2000); // this command takes a long time! -} - -void LiquidCrystal::setCursor(uint8_t col, uint8_t row) -{ - int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; - if ( row >= _numlines ) { - row = _numlines-1; // we count rows starting w/0 - } - - command(LCD_SETDDRAMADDR | (col + row_offsets[row])); -} - -// Turn the display on/off (quickly) -void LiquidCrystal::noDisplay() { - _displaycontrol &= ~LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::display() { - _displaycontrol |= LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turns the underline cursor on/off -void LiquidCrystal::noCursor() { - _displaycontrol &= ~LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::cursor() { - _displaycontrol |= LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turn on and off the blinking cursor -void LiquidCrystal::noBlink() { - _displaycontrol &= ~LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::blink() { - _displaycontrol |= LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// These commands scroll the display without changing the RAM -void LiquidCrystal::scrollDisplayLeft(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} -void LiquidCrystal::scrollDisplayRight(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -// This is for text that flows Left to Right -void LiquidCrystal::leftToRight(void) { - _displaymode |= LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This is for text that flows Right to Left -void LiquidCrystal::rightToLeft(void) { - _displaymode &= ~LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'right justify' text from the cursor -void LiquidCrystal::autoscroll(void) { - _displaymode |= LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'left justify' text from the cursor -void LiquidCrystal::noAutoscroll(void) { - _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// Allows us to fill the first 8 CGRAM locations -// with custom characters -void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { - location &= 0x7; // we only have 8 locations 0-7 - command(LCD_SETCGRAMADDR | (location << 3)); - for (int i=0; i<8; i++) { - write(charmap[i]); - } -} - -/*********** mid level commands, for sending data/cmds */ - -inline void LiquidCrystal::command(uint8_t value) { - send(value, LOW); -} - -inline size_t LiquidCrystal::write(uint8_t value) { - send(value, HIGH); - return 1; // assume sucess -} - -/************ low level data pushing commands **********/ - -// write either command or data, with automatic 4/8-bit selection -void LiquidCrystal::send(uint8_t value, uint8_t mode) { - digitalWrite(_rs_pin, mode); - - // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { - digitalWrite(_rw_pin, LOW); - } - - if (_displayfunction & LCD_8BITMODE) { - write8bits(value); - } else { - write4bits(value>>4); - write4bits(value); - } -} - -void LiquidCrystal::pulseEnable(void) { - digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); - digitalWrite(_enable_pin, HIGH); - delayMicroseconds(1); // enable pulse must be >450ns - digitalWrite(_enable_pin, LOW); - delayMicroseconds(100); // commands need > 37us to settle -} - -void LiquidCrystal::write4bits(uint8_t value) { - for (int i = 0; i < 4; i++) { - pinMode(_data_pins[i], OUTPUT); - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - - pulseEnable(); -} - -void LiquidCrystal::write8bits(uint8_t value) { - for (int i = 0; i < 8; i++) { - pinMode(_data_pins[i], OUTPUT); - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - - pulseEnable(); -} diff --git a/LiquidCrystal.h b/LiquidCrystal.h deleted file mode 100755 index 24ec5af..0000000 --- a/LiquidCrystal.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef LiquidCrystal_h -#define LiquidCrystal_h - -#include -#include "Print.h" - -// commands -#define LCD_CLEARDISPLAY 0x01 -#define LCD_RETURNHOME 0x02 -#define LCD_ENTRYMODESET 0x04 -#define LCD_DISPLAYCONTROL 0x08 -#define LCD_CURSORSHIFT 0x10 -#define LCD_FUNCTIONSET 0x20 -#define LCD_SETCGRAMADDR 0x40 -#define LCD_SETDDRAMADDR 0x80 - -// flags for display entry mode -#define LCD_ENTRYRIGHT 0x00 -#define LCD_ENTRYLEFT 0x02 -#define LCD_ENTRYSHIFTINCREMENT 0x01 -#define LCD_ENTRYSHIFTDECREMENT 0x00 - -// flags for display on/off control -#define LCD_DISPLAYON 0x04 -#define LCD_DISPLAYOFF 0x00 -#define LCD_CURSORON 0x02 -#define LCD_CURSOROFF 0x00 -#define LCD_BLINKON 0x01 -#define LCD_BLINKOFF 0x00 - -// flags for display/cursor shift -#define LCD_DISPLAYMOVE 0x08 -#define LCD_CURSORMOVE 0x00 -#define LCD_MOVERIGHT 0x04 -#define LCD_MOVELEFT 0x00 - -// flags for function set -#define LCD_8BITMODE 0x10 -#define LCD_4BITMODE 0x00 -#define LCD_2LINE 0x08 -#define LCD_1LINE 0x00 -#define LCD_5x10DOTS 0x04 -#define LCD_5x8DOTS 0x00 - -class LiquidCrystal : public Print { -public: - 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(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); - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); - - 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); - - void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); - - void clear(); - void home(); - - void noDisplay(); - void display(); - void noBlink(); - void blink(); - void noCursor(); - void cursor(); - void scrollDisplayLeft(); - void scrollDisplayRight(); - void leftToRight(); - void rightToLeft(); - void autoscroll(); - void noAutoscroll(); - - void createChar(uint8_t, uint8_t[]); - void setCursor(uint8_t, uint8_t); - virtual size_t write(uint8_t); - void command(uint8_t); - - using Print::write; -private: - void send(uint8_t, uint8_t); - void write4bits(uint8_t); - void write8bits(uint8_t); - void pulseEnable(); - - uint8_t _rs_pin; // LOW: command. HIGH: character. - uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. - uint8_t _enable_pin; // activated by a HIGH pulse. - uint8_t _data_pins[8]; - - uint8_t _displayfunction; - uint8_t _displaycontrol; - uint8_t _displaymode; - - uint8_t _initialized; - - uint8_t _numlines,_currline; -}; - -#endif diff --git a/examples/Autoscroll/Autoscroll.ino b/examples/Autoscroll/Autoscroll.ino deleted file mode 100644 index 27123ad..0000000 --- a/examples/Autoscroll/Autoscroll.ino +++ /dev/null @@ -1,73 +0,0 @@ -/* - LiquidCrystal Library - Autoscroll - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch demonstrates the use of the autoscroll() - and noAutoscroll() functions to make new text scroll or not. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16,2); -} - -void loop() { - // set the cursor to (0,0): - lcd.setCursor(0, 0); - // print from 0 to 9: - for (int thisChar = 0; thisChar < 10; thisChar++) { - lcd.print(thisChar); - delay(500); - } - - // set the cursor to (16,1): - lcd.setCursor(16,1); - // set the display to automatically scroll: - lcd.autoscroll(); - // print from 0 to 9: - for (int thisChar = 0; thisChar < 10; thisChar++) { - lcd.print(thisChar); - delay(500); - } - // turn off automatic scrolling - lcd.noAutoscroll(); - - // clear screen for the next loop: - lcd.clear(); -} - diff --git a/examples/Blink/Blink.ino b/examples/Blink/Blink.ino deleted file mode 100644 index e410424..0000000 --- a/examples/Blink/Blink.ino +++ /dev/null @@ -1,61 +0,0 @@ -/* - LiquidCrystal Library - Blink - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD and makes the - cursor block blink. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); -} - -void loop() { - // Turn off the blinking cursor: - lcd.noBlink(); - delay(3000); - // Turn on the blinking cursor: - lcd.blink(); - delay(3000); -} - - diff --git a/examples/Cursor/Cursor.ino b/examples/Cursor/Cursor.ino deleted file mode 100644 index 28e2a6a..0000000 --- a/examples/Cursor/Cursor.ino +++ /dev/null @@ -1,60 +0,0 @@ -/* - LiquidCrystal Library - Cursor - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD and - uses the cursor() and noCursor() methods to turn - on and off the cursor. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); -} - -void loop() { - // Turn off the cursor: - lcd.noCursor(); - delay(500); - // Turn on the cursor: - lcd.cursor(); - delay(500); -} - diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/CustomCharacter/CustomCharacter.ino deleted file mode 100644 index d3ce479..0000000 --- a/examples/CustomCharacter/CustomCharacter.ino +++ /dev/null @@ -1,138 +0,0 @@ -/* - LiquidCrystal Library - Custom Characters - - Demonstrates how to add custom characters on an LCD display. - The LiquidCrystal library works with all LCD displays that are - compatible with the Hitachi HD44780 driver. There are many of - them out there, and you can usually tell them by the 16-pin interface. - - This sketch prints "I Arduino!" and a little dancing man - to the LCD. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K potentiometer: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - * 10K poterntiometer on pin A0 - - created21 Mar 2011 - by Tom Igoe - Based on Adafruit's example at - https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde - - This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal - - Also useful: - http://icontexto.com/charactercreator/ - - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -// make some custom characters: -byte heart[8] = { - 0b00000, - 0b01010, - 0b11111, - 0b11111, - 0b11111, - 0b01110, - 0b00100, - 0b00000 -}; - -byte smiley[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b10001, - 0b01110, - 0b00000 -}; - -byte frownie[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b00000, - 0b01110, - 0b10001 -}; - -byte armsDown[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b00100, - 0b01110, - 0b10101, - 0b00100, - 0b01010 -}; - -byte armsUp[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b10101, - 0b01110, - 0b00100, - 0b00100, - 0b01010 -}; -void setup() { - // create a new character - lcd.createChar(0, heart); - // create a new character - lcd.createChar(1, smiley); - // create a new character - lcd.createChar(2, frownie); - // create a new character - lcd.createChar(3, armsDown); - // create a new character - lcd.createChar(4, armsUp); - - // set up the lcd's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the lcd. - lcd.print("I "); - lcd.write(0); - lcd.print(" Arduino! "); - lcd.write(1); - -} - -void loop() { - // read the potentiometer on A0: - int sensorReading = analogRead(A0); - // map the result to 200 - 1000: - int delayTime = map(sensorReading, 0, 1023, 200, 1000); - // set the cursor to the bottom row, 5th position: - lcd.setCursor(4, 1); - // draw the little man, arms down: - lcd.write(3); - delay(delayTime); - lcd.setCursor(4, 1); - // draw him arms up: - lcd.write(4); - delay(delayTime); -} - - - diff --git a/examples/Display/Display.ino b/examples/Display/Display.ino deleted file mode 100644 index b000731..0000000 --- a/examples/Display/Display.ino +++ /dev/null @@ -1,60 +0,0 @@ -/* - LiquidCrystal Library - display() and noDisplay() - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD and uses the - display() and noDisplay() functions to turn on and off - the display. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); -} - -void loop() { - // Turn off the display: - lcd.noDisplay(); - delay(500); - // Turn on the display: - lcd.display(); - delay(500); -} - diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino deleted file mode 100644 index e99957d..0000000 --- a/examples/HelloWorld/HelloWorld.ino +++ /dev/null @@ -1,58 +0,0 @@ -/* - LiquidCrystal Library - Hello World - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD - and shows the time. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); -} - -void loop() { - // set the cursor to column 0, line 1 - // (note: line 1 is the second row, since counting begins with 0): - lcd.setCursor(0, 1); - // print the number of seconds since reset: - lcd.print(millis()/1000); -} - diff --git a/examples/Scroll/Scroll.ino b/examples/Scroll/Scroll.ino deleted file mode 100644 index 71e5e8c..0000000 --- a/examples/Scroll/Scroll.ino +++ /dev/null @@ -1,85 +0,0 @@ -/* - LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD and uses the - scrollDisplayLeft() and scrollDisplayRight() methods to scroll - the text. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); - delay(1000); -} - -void loop() { - // scroll 13 positions (string length) to the left - // to move it offscreen left: - for (int positionCounter = 0; positionCounter < 13; positionCounter++) { - // scroll one position left: - lcd.scrollDisplayLeft(); - // wait a bit: - delay(150); - } - - // scroll 29 positions (string length + display length) to the right - // to move it offscreen right: - for (int positionCounter = 0; positionCounter < 29; positionCounter++) { - // scroll one position right: - lcd.scrollDisplayRight(); - // wait a bit: - delay(150); - } - - // scroll 16 positions (display length + string length) to the left - // to move it back to center: - for (int positionCounter = 0; positionCounter < 16; positionCounter++) { - // scroll one position left: - lcd.scrollDisplayLeft(); - // wait a bit: - delay(150); - } - - // delay at the end of the full loop: - delay(1000); - -} - diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/SerialDisplay/SerialDisplay.ino deleted file mode 100644 index 9727cee..0000000 --- a/examples/SerialDisplay/SerialDisplay.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* - LiquidCrystal Library - Serial Input - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch displays text sent over the serial port - (e.g. from the Serial Monitor) on an attached LCD. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup(){ - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // initialize the serial communications: - Serial.begin(9600); -} - -void loop() -{ - // when characters arrive over the serial port... - if (Serial.available()) { - // wait a bit for the entire message to arrive - delay(100); - // clear the screen - lcd.clear(); - // read all the available characters - while (Serial.available() > 0) { - // display each character to the LCD - lcd.write(Serial.read()); - } - } -} diff --git a/examples/TextDirection/TextDirection.ino b/examples/TextDirection/TextDirection.ino deleted file mode 100644 index 51bab1f..0000000 --- a/examples/TextDirection/TextDirection.ino +++ /dev/null @@ -1,87 +0,0 @@ - /* - LiquidCrystal Library - TextDirection - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch demonstrates how to use leftToRight() and rightToLeft() - to move the cursor. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -int thisChar = 'a'; - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // turn on the cursor: - lcd.cursor(); - Serial.begin(9600); -} - -void loop() { - // reverse directions at 'm': - if (thisChar == 'm') { - // go right for the next letter - lcd.rightToLeft(); - } - // reverse again at 's': - if (thisChar == 's') { - // go left for the next letter - lcd.leftToRight(); - } - // reset at 'z': - if (thisChar > 'z') { - // go to (0,0): - lcd.home(); - // start again at 0 - thisChar = 'a'; - } - // print the character - lcd.write(thisChar); - // wait a second: - delay(1000); - // increment the letter: - thisChar++; -} - - - - - - - - diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino deleted file mode 100644 index 3c4edf3..0000000 --- a/examples/setCursor/setCursor.ino +++ /dev/null @@ -1,71 +0,0 @@ -/* - LiquidCrystal Library - setCursor - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints to all the positions of the LCD using the - setCursor(0 method: - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include - -// these constants won't change. But you can change the size of -// your LCD using them: -const int numRows = 2; -const int numCols = 16; - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(numCols,numRows); -} - -void loop() { - // loop from ASCII 'a' to ASCII 'z': - for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { - // loop over the columns: - for (int thisCol = 0; thisCol < numRows; thisCol++) { - // loop over the rows: - for (int thisRow = 0; thisRow < numCols; thisRow++) { - // set the cursor position: - lcd.setCursor(thisRow,thisCol); - // print the letter: - lcd.write(thisLetter); - delay(200); - } - } - } -} - - diff --git a/keywords.txt b/keywords.txt deleted file mode 100755 index 132845c..0000000 --- a/keywords.txt +++ /dev/null @@ -1,37 +0,0 @@ -####################################### -# Syntax Coloring Map For LiquidCrystal -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -LiquidCrystal KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -begin KEYWORD2 -clear KEYWORD2 -home KEYWORD2 -print KEYWORD2 -setCursor KEYWORD2 -cursor KEYWORD2 -noCursor KEYWORD2 -blink KEYWORD2 -noBlink KEYWORD2 -display KEYWORD2 -noDisplay KEYWORD2 -autoscroll KEYWORD2 -noAutoscroll KEYWORD2 -leftToRight KEYWORD2 -rightToLeft KEYWORD2 -scrollDisplayLeft KEYWORD2 -scrollDisplayRight KEYWORD2 -createChar KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - From b57bba1cfc78f7c1f8ae1b6410b71a3dd13647e3 Mon Sep 17 00:00:00 2001 From: Federico Vanzati Date: Wed, 11 Apr 2012 12:56:31 +0200 Subject: [PATCH 37/73] updated URLs in LiquidCrystal examples --- examples/Autoscroll/Autoscroll.ino | 3 ++- examples/Blink/Blink.ino | 2 +- examples/Cursor/Cursor.ino | 3 ++- examples/Display/Display.ino | 3 ++- examples/Scroll/Scroll.ino | 3 ++- examples/SerialDisplay/SerialDisplay.ino | 2 +- examples/TextDirection/TextDirection.ino | 3 +-- examples/setCursor/setCursor.ino | 3 ++- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/Autoscroll/Autoscroll.ino b/examples/Autoscroll/Autoscroll.ino index 27123ad..1127d8f 100644 --- a/examples/Autoscroll/Autoscroll.ino +++ b/examples/Autoscroll/Autoscroll.ino @@ -32,7 +32,8 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll + */ // include the library code: diff --git a/examples/Blink/Blink.ino b/examples/Blink/Blink.ino index e410424..9667b5d 100644 --- a/examples/Blink/Blink.ino +++ b/examples/Blink/Blink.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalBlink */ diff --git a/examples/Cursor/Cursor.ino b/examples/Cursor/Cursor.ino index 28e2a6a..05862a4 100644 --- a/examples/Cursor/Cursor.ino +++ b/examples/Cursor/Cursor.ino @@ -33,7 +33,8 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalCursor + */ // include the library code: diff --git a/examples/Display/Display.ino b/examples/Display/Display.ino index b000731..a85effb 100644 --- a/examples/Display/Display.ino +++ b/examples/Display/Display.ino @@ -33,7 +33,8 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalDisplay + */ // include the library code: diff --git a/examples/Scroll/Scroll.ino b/examples/Scroll/Scroll.ino index 71e5e8c..0d6d8dc 100644 --- a/examples/Scroll/Scroll.ino +++ b/examples/Scroll/Scroll.ino @@ -33,7 +33,8 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalScroll + */ // include the library code: diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/SerialDisplay/SerialDisplay.ino index 9727cee..a6f8f40 100644 --- a/examples/SerialDisplay/SerialDisplay.ino +++ b/examples/SerialDisplay/SerialDisplay.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalSerial */ // include the library code: diff --git a/examples/TextDirection/TextDirection.ino b/examples/TextDirection/TextDirection.ino index 51bab1f..cabd8ea 100644 --- a/examples/TextDirection/TextDirection.ino +++ b/examples/TextDirection/TextDirection.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection */ @@ -49,7 +49,6 @@ void setup() { lcd.begin(16, 2); // turn on the cursor: lcd.cursor(); - Serial.begin(9600); } void loop() { diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino index 3c4edf3..e45c491 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setCursor/setCursor.ino @@ -32,7 +32,8 @@ This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal + http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor + */ // include the library code: From b2cbc5eb4cc5142b932f4d20651b167ff37cfbd0 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 3 Sep 2012 16:13:28 +0200 Subject: [PATCH 38/73] LiquidCrystal library is already multiplatform compliant, moved into libraries folder --- LiquidCrystal.cpp | 310 +++++++++++++++++++ LiquidCrystal.h | 106 +++++++ examples/Autoscroll/Autoscroll.ino | 74 +++++ examples/Blink/Blink.ino | 61 ++++ examples/Cursor/Cursor.ino | 61 ++++ examples/CustomCharacter/CustomCharacter.ino | 138 +++++++++ examples/Display/Display.ino | 61 ++++ examples/HelloWorld/HelloWorld.ino | 58 ++++ examples/Scroll/Scroll.ino | 86 +++++ examples/SerialDisplay/SerialDisplay.ino | 65 ++++ examples/TextDirection/TextDirection.ino | 86 +++++ examples/setCursor/setCursor.ino | 72 +++++ keywords.txt | 37 +++ 13 files changed, 1215 insertions(+) create mode 100644 LiquidCrystal.cpp create mode 100755 LiquidCrystal.h create mode 100644 examples/Autoscroll/Autoscroll.ino create mode 100644 examples/Blink/Blink.ino create mode 100644 examples/Cursor/Cursor.ino create mode 100644 examples/CustomCharacter/CustomCharacter.ino create mode 100644 examples/Display/Display.ino create mode 100644 examples/HelloWorld/HelloWorld.ino create mode 100644 examples/Scroll/Scroll.ino create mode 100644 examples/SerialDisplay/SerialDisplay.ino create mode 100644 examples/TextDirection/TextDirection.ino create mode 100644 examples/setCursor/setCursor.ino create mode 100755 keywords.txt diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp new file mode 100644 index 0000000..0653487 --- /dev/null +++ b/LiquidCrystal.cpp @@ -0,0 +1,310 @@ +#include "LiquidCrystal.h" + +#include +#include +#include +#include "Arduino.h" + +// When the display powers up, it is configured as follows: +// +// 1. Display clear +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift +// +// Note, however, that resetting the Arduino doesn't reset the LCD, so we +// can't assume that its in that state when a sketch starts (and the +// LiquidCrystal constructor is called). + +LiquidCrystal::LiquidCrystal(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) +{ + init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); +} + +LiquidCrystal::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) +{ + init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) +{ + init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); +} + +LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) +{ + init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); +} + +void LiquidCrystal::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) +{ + _rs_pin = rs; + _rw_pin = rw; + _enable_pin = enable; + + _data_pins[0] = d0; + _data_pins[1] = d1; + _data_pins[2] = d2; + _data_pins[3] = d3; + _data_pins[4] = d4; + _data_pins[5] = d5; + _data_pins[6] = d6; + _data_pins[7] = d7; + + pinMode(_rs_pin, OUTPUT); + // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# + if (_rw_pin != 255) { + pinMode(_rw_pin, OUTPUT); + } + pinMode(_enable_pin, OUTPUT); + + if (fourbitmode) + _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; + else + _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; + + begin(16, 1); +} + +void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { + if (lines > 1) { + _displayfunction |= LCD_2LINE; + } + _numlines = lines; + _currline = 0; + + // for some 1 line displays you can select a 10 pixel high font + if ((dotsize != 0) && (lines == 1)) { + _displayfunction |= LCD_5x10DOTS; + } + + // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! + // according to datasheet, we need at least 40ms after power rises above 2.7V + // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 + delayMicroseconds(50000); + // Now we pull both RS and R/W low to begin commands + digitalWrite(_rs_pin, LOW); + digitalWrite(_enable_pin, LOW); + if (_rw_pin != 255) { + digitalWrite(_rw_pin, LOW); + } + + //put the LCD into 4 bit or 8 bit mode + if (! (_displayfunction & LCD_8BITMODE)) { + // this is according to the hitachi HD44780 datasheet + // figure 24, pg 46 + + // we start in 8bit mode, try to set 4 bit mode + write4bits(0x03); + delayMicroseconds(4500); // wait min 4.1ms + + // second try + write4bits(0x03); + delayMicroseconds(4500); // wait min 4.1ms + + // third go! + write4bits(0x03); + delayMicroseconds(150); + + // finally, set to 4-bit interface + write4bits(0x02); + } else { + // this is according to the hitachi HD44780 datasheet + // page 45 figure 23 + + // Send function set command sequence + command(LCD_FUNCTIONSET | _displayfunction); + delayMicroseconds(4500); // wait more than 4.1ms + + // second try + command(LCD_FUNCTIONSET | _displayfunction); + delayMicroseconds(150); + + // third go + command(LCD_FUNCTIONSET | _displayfunction); + } + + // finally, set # lines, font size, etc. + command(LCD_FUNCTIONSET | _displayfunction); + + // turn the display on with no cursor or blinking default + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + display(); + + // clear it off + clear(); + + // Initialize to default text direction (for romance languages) + _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; + // set the entry mode + command(LCD_ENTRYMODESET | _displaymode); + +} + +/********** high level commands, for the user! */ +void LiquidCrystal::clear() +{ + command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal::home() +{ + command(LCD_RETURNHOME); // set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal::setCursor(uint8_t col, uint8_t row) +{ + int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + if ( row >= _numlines ) { + row = _numlines-1; // we count rows starting w/0 + } + + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); +} + +// Turn the display on/off (quickly) +void LiquidCrystal::noDisplay() { + _displaycontrol &= ~LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::display() { + _displaycontrol |= LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turns the underline cursor on/off +void LiquidCrystal::noCursor() { + _displaycontrol &= ~LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::cursor() { + _displaycontrol |= LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turn on and off the blinking cursor +void LiquidCrystal::noBlink() { + _displaycontrol &= ~LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal::blink() { + _displaycontrol |= LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// These commands scroll the display without changing the RAM +void LiquidCrystal::scrollDisplayLeft(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); +} +void LiquidCrystal::scrollDisplayRight(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); +} + +// This is for text that flows Left to Right +void LiquidCrystal::leftToRight(void) { + _displaymode |= LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This is for text that flows Right to Left +void LiquidCrystal::rightToLeft(void) { + _displaymode &= ~LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'right justify' text from the cursor +void LiquidCrystal::autoscroll(void) { + _displaymode |= LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'left justify' text from the cursor +void LiquidCrystal::noAutoscroll(void) { + _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// Allows us to fill the first 8 CGRAM locations +// with custom characters +void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { + location &= 0x7; // we only have 8 locations 0-7 + command(LCD_SETCGRAMADDR | (location << 3)); + for (int i=0; i<8; i++) { + write(charmap[i]); + } +} + +/*********** mid level commands, for sending data/cmds */ + +inline void LiquidCrystal::command(uint8_t value) { + send(value, LOW); +} + +inline size_t LiquidCrystal::write(uint8_t value) { + send(value, HIGH); + return 1; // assume sucess +} + +/************ low level data pushing commands **********/ + +// write either command or data, with automatic 4/8-bit selection +void LiquidCrystal::send(uint8_t value, uint8_t mode) { + digitalWrite(_rs_pin, mode); + + // if there is a RW pin indicated, set it low to Write + if (_rw_pin != 255) { + digitalWrite(_rw_pin, LOW); + } + + if (_displayfunction & LCD_8BITMODE) { + write8bits(value); + } else { + write4bits(value>>4); + write4bits(value); + } +} + +void LiquidCrystal::pulseEnable(void) { + digitalWrite(_enable_pin, LOW); + delayMicroseconds(1); + digitalWrite(_enable_pin, HIGH); + delayMicroseconds(1); // enable pulse must be >450ns + digitalWrite(_enable_pin, LOW); + delayMicroseconds(100); // commands need > 37us to settle +} + +void LiquidCrystal::write4bits(uint8_t value) { + for (int i = 0; i < 4; i++) { + pinMode(_data_pins[i], OUTPUT); + digitalWrite(_data_pins[i], (value >> i) & 0x01); + } + + pulseEnable(); +} + +void LiquidCrystal::write8bits(uint8_t value) { + for (int i = 0; i < 8; i++) { + pinMode(_data_pins[i], OUTPUT); + digitalWrite(_data_pins[i], (value >> i) & 0x01); + } + + pulseEnable(); +} diff --git a/LiquidCrystal.h b/LiquidCrystal.h new file mode 100755 index 0000000..24ec5af --- /dev/null +++ b/LiquidCrystal.h @@ -0,0 +1,106 @@ +#ifndef LiquidCrystal_h +#define LiquidCrystal_h + +#include +#include "Print.h" + +// commands +#define LCD_CLEARDISPLAY 0x01 +#define LCD_RETURNHOME 0x02 +#define LCD_ENTRYMODESET 0x04 +#define LCD_DISPLAYCONTROL 0x08 +#define LCD_CURSORSHIFT 0x10 +#define LCD_FUNCTIONSET 0x20 +#define LCD_SETCGRAMADDR 0x40 +#define LCD_SETDDRAMADDR 0x80 + +// flags for display entry mode +#define LCD_ENTRYRIGHT 0x00 +#define LCD_ENTRYLEFT 0x02 +#define LCD_ENTRYSHIFTINCREMENT 0x01 +#define LCD_ENTRYSHIFTDECREMENT 0x00 + +// flags for display on/off control +#define LCD_DISPLAYON 0x04 +#define LCD_DISPLAYOFF 0x00 +#define LCD_CURSORON 0x02 +#define LCD_CURSOROFF 0x00 +#define LCD_BLINKON 0x01 +#define LCD_BLINKOFF 0x00 + +// flags for display/cursor shift +#define LCD_DISPLAYMOVE 0x08 +#define LCD_CURSORMOVE 0x00 +#define LCD_MOVERIGHT 0x04 +#define LCD_MOVELEFT 0x00 + +// flags for function set +#define LCD_8BITMODE 0x10 +#define LCD_4BITMODE 0x00 +#define LCD_2LINE 0x08 +#define LCD_1LINE 0x00 +#define LCD_5x10DOTS 0x04 +#define LCD_5x8DOTS 0x00 + +class LiquidCrystal : public Print { +public: + 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(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); + LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); + LiquidCrystal(uint8_t rs, uint8_t enable, + uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); + + 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); + + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); + + void clear(); + void home(); + + void noDisplay(); + void display(); + void noBlink(); + void blink(); + void noCursor(); + void cursor(); + void scrollDisplayLeft(); + void scrollDisplayRight(); + void leftToRight(); + void rightToLeft(); + void autoscroll(); + void noAutoscroll(); + + void createChar(uint8_t, uint8_t[]); + void setCursor(uint8_t, uint8_t); + virtual size_t write(uint8_t); + void command(uint8_t); + + using Print::write; +private: + void send(uint8_t, uint8_t); + void write4bits(uint8_t); + void write8bits(uint8_t); + void pulseEnable(); + + uint8_t _rs_pin; // LOW: command. HIGH: character. + uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. + uint8_t _enable_pin; // activated by a HIGH pulse. + uint8_t _data_pins[8]; + + uint8_t _displayfunction; + uint8_t _displaycontrol; + uint8_t _displaymode; + + uint8_t _initialized; + + uint8_t _numlines,_currline; +}; + +#endif diff --git a/examples/Autoscroll/Autoscroll.ino b/examples/Autoscroll/Autoscroll.ino new file mode 100644 index 0000000..1127d8f --- /dev/null +++ b/examples/Autoscroll/Autoscroll.ino @@ -0,0 +1,74 @@ +/* + LiquidCrystal Library - Autoscroll + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates the use of the autoscroll() + and noAutoscroll() functions to make new text scroll or not. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16,2); +} + +void loop() { + // set the cursor to (0,0): + lcd.setCursor(0, 0); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + + // set the cursor to (16,1): + lcd.setCursor(16,1); + // set the display to automatically scroll: + lcd.autoscroll(); + // print from 0 to 9: + for (int thisChar = 0; thisChar < 10; thisChar++) { + lcd.print(thisChar); + delay(500); + } + // turn off automatic scrolling + lcd.noAutoscroll(); + + // clear screen for the next loop: + lcd.clear(); +} + diff --git a/examples/Blink/Blink.ino b/examples/Blink/Blink.ino new file mode 100644 index 0000000..9667b5d --- /dev/null +++ b/examples/Blink/Blink.ino @@ -0,0 +1,61 @@ +/* + LiquidCrystal Library - Blink + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and makes the + cursor block blink. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalBlink + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the blinking cursor: + lcd.noBlink(); + delay(3000); + // Turn on the blinking cursor: + lcd.blink(); + delay(3000); +} + + diff --git a/examples/Cursor/Cursor.ino b/examples/Cursor/Cursor.ino new file mode 100644 index 0000000..05862a4 --- /dev/null +++ b/examples/Cursor/Cursor.ino @@ -0,0 +1,61 @@ +/* + LiquidCrystal Library - Cursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and + uses the cursor() and noCursor() methods to turn + on and off the cursor. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalCursor + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the cursor: + lcd.noCursor(); + delay(500); + // Turn on the cursor: + lcd.cursor(); + delay(500); +} + diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/CustomCharacter/CustomCharacter.ino new file mode 100644 index 0000000..d3ce479 --- /dev/null +++ b/examples/CustomCharacter/CustomCharacter.ino @@ -0,0 +1,138 @@ +/* + LiquidCrystal Library - Custom Characters + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of + them out there, and you can usually tell them by the 16-pin interface. + + This sketch prints "I Arduino!" and a little dancing man + to the LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K potentiometer: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + * 10K poterntiometer on pin A0 + + created21 Mar 2011 + by Tom Igoe + Based on Adafruit's example at + https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde + + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/LiquidCrystal + + Also useful: + http://icontexto.com/charactercreator/ + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +// make some custom characters: +byte heart[8] = { + 0b00000, + 0b01010, + 0b11111, + 0b11111, + 0b11111, + 0b01110, + 0b00100, + 0b00000 +}; + +byte smiley[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b10001, + 0b01110, + 0b00000 +}; + +byte frownie[8] = { + 0b00000, + 0b00000, + 0b01010, + 0b00000, + 0b00000, + 0b00000, + 0b01110, + 0b10001 +}; + +byte armsDown[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b00100, + 0b01110, + 0b10101, + 0b00100, + 0b01010 +}; + +byte armsUp[8] = { + 0b00100, + 0b01010, + 0b00100, + 0b10101, + 0b01110, + 0b00100, + 0b00100, + 0b01010 +}; +void setup() { + // create a new character + lcd.createChar(0, heart); + // create a new character + lcd.createChar(1, smiley); + // create a new character + lcd.createChar(2, frownie); + // create a new character + lcd.createChar(3, armsDown); + // create a new character + lcd.createChar(4, armsUp); + + // set up the lcd's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the lcd. + lcd.print("I "); + lcd.write(0); + lcd.print(" Arduino! "); + lcd.write(1); + +} + +void loop() { + // read the potentiometer on A0: + int sensorReading = analogRead(A0); + // map the result to 200 - 1000: + int delayTime = map(sensorReading, 0, 1023, 200, 1000); + // set the cursor to the bottom row, 5th position: + lcd.setCursor(4, 1); + // draw the little man, arms down: + lcd.write(3); + delay(delayTime); + lcd.setCursor(4, 1); + // draw him arms up: + lcd.write(4); + delay(delayTime); +} + + + diff --git a/examples/Display/Display.ino b/examples/Display/Display.ino new file mode 100644 index 0000000..a85effb --- /dev/null +++ b/examples/Display/Display.ino @@ -0,0 +1,61 @@ +/* + LiquidCrystal Library - display() and noDisplay() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + display() and noDisplay() functions to turn on and off + the display. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalDisplay + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // Turn off the display: + lcd.noDisplay(); + delay(500); + // Turn on the display: + lcd.display(); + delay(500); +} + diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino new file mode 100644 index 0000000..e99957d --- /dev/null +++ b/examples/HelloWorld/HelloWorld.ino @@ -0,0 +1,58 @@ +/* + LiquidCrystal Library - Hello World + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD + and shows the time. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/LiquidCrystal + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); +} + +void loop() { + // set the cursor to column 0, line 1 + // (note: line 1 is the second row, since counting begins with 0): + lcd.setCursor(0, 1); + // print the number of seconds since reset: + lcd.print(millis()/1000); +} + diff --git a/examples/Scroll/Scroll.ino b/examples/Scroll/Scroll.ino new file mode 100644 index 0000000..0d6d8dc --- /dev/null +++ b/examples/Scroll/Scroll.ino @@ -0,0 +1,86 @@ +/* + LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints "Hello World!" to the LCD and uses the + scrollDisplayLeft() and scrollDisplayRight() methods to scroll + the text. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalScroll + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // Print a message to the LCD. + lcd.print("hello, world!"); + delay(1000); +} + +void loop() { + // scroll 13 positions (string length) to the left + // to move it offscreen left: + for (int positionCounter = 0; positionCounter < 13; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // scroll 29 positions (string length + display length) to the right + // to move it offscreen right: + for (int positionCounter = 0; positionCounter < 29; positionCounter++) { + // scroll one position right: + lcd.scrollDisplayRight(); + // wait a bit: + delay(150); + } + + // scroll 16 positions (display length + string length) to the left + // to move it back to center: + for (int positionCounter = 0; positionCounter < 16; positionCounter++) { + // scroll one position left: + lcd.scrollDisplayLeft(); + // wait a bit: + delay(150); + } + + // delay at the end of the full loop: + delay(1000); + +} + diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/SerialDisplay/SerialDisplay.ino new file mode 100644 index 0000000..a6f8f40 --- /dev/null +++ b/examples/SerialDisplay/SerialDisplay.ino @@ -0,0 +1,65 @@ +/* + LiquidCrystal Library - Serial Input + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch displays text sent over the serial port + (e.g. from the Serial Monitor) on an attached LCD. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalSerial + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup(){ + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // initialize the serial communications: + Serial.begin(9600); +} + +void loop() +{ + // when characters arrive over the serial port... + if (Serial.available()) { + // wait a bit for the entire message to arrive + delay(100); + // clear the screen + lcd.clear(); + // read all the available characters + while (Serial.available() > 0) { + // display each character to the LCD + lcd.write(Serial.read()); + } + } +} diff --git a/examples/TextDirection/TextDirection.ino b/examples/TextDirection/TextDirection.ino new file mode 100644 index 0000000..cabd8ea --- /dev/null +++ b/examples/TextDirection/TextDirection.ino @@ -0,0 +1,86 @@ + /* + LiquidCrystal Library - TextDirection + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch demonstrates how to use leftToRight() and rightToLeft() + to move the cursor. + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection + + */ + +// include the library code: +#include + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +int thisChar = 'a'; + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); + // turn on the cursor: + lcd.cursor(); +} + +void loop() { + // reverse directions at 'm': + if (thisChar == 'm') { + // go right for the next letter + lcd.rightToLeft(); + } + // reverse again at 's': + if (thisChar == 's') { + // go left for the next letter + lcd.leftToRight(); + } + // reset at 'z': + if (thisChar > 'z') { + // go to (0,0): + lcd.home(); + // start again at 0 + thisChar = 'a'; + } + // print the character + lcd.write(thisChar); + // wait a second: + delay(1000); + // increment the letter: + thisChar++; +} + + + + + + + + diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino new file mode 100644 index 0000000..e45c491 --- /dev/null +++ b/examples/setCursor/setCursor.ino @@ -0,0 +1,72 @@ +/* + LiquidCrystal Library - setCursor + + Demonstrates the use a 16x2 LCD display. The LiquidCrystal + library works with all LCD displays that are compatible with the + Hitachi HD44780 driver. There are many of them out there, and you + can usually tell them by the 16-pin interface. + + This sketch prints to all the positions of the LCD using the + setCursor(0 method: + + The circuit: + * LCD RS pin to digital pin 12 + * LCD Enable pin to digital pin 11 + * LCD D4 pin to digital pin 5 + * LCD D5 pin to digital pin 4 + * LCD D6 pin to digital pin 3 + * LCD D7 pin to digital pin 2 + * LCD R/W pin to ground + * 10K resistor: + * ends to +5V and ground + * wiper to LCD VO pin (pin 3) + + Library originally added 18 Apr 2008 + by David A. Mellis + library modified 5 Jul 2009 + by Limor Fried (http://www.ladyada.net) + example added 9 Jul 2009 + by Tom Igoe + modified 22 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + + http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor + + */ + +// include the library code: +#include + +// these constants won't change. But you can change the size of +// your LCD using them: +const int numRows = 2; +const int numCols = 16; + +// initialize the library with the numbers of the interface pins +LiquidCrystal lcd(12, 11, 5, 4, 3, 2); + +void setup() { + // set up the LCD's number of columns and rows: + lcd.begin(numCols,numRows); +} + +void loop() { + // loop from ASCII 'a' to ASCII 'z': + for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { + // loop over the columns: + for (int thisCol = 0; thisCol < numRows; thisCol++) { + // loop over the rows: + for (int thisRow = 0; thisRow < numCols; thisRow++) { + // set the cursor position: + lcd.setCursor(thisRow,thisCol); + // print the letter: + lcd.write(thisLetter); + delay(200); + } + } + } +} + + diff --git a/keywords.txt b/keywords.txt new file mode 100755 index 0000000..132845c --- /dev/null +++ b/keywords.txt @@ -0,0 +1,37 @@ +####################################### +# Syntax Coloring Map For LiquidCrystal +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LiquidCrystal KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +clear KEYWORD2 +home KEYWORD2 +print KEYWORD2 +setCursor KEYWORD2 +cursor KEYWORD2 +noCursor KEYWORD2 +blink KEYWORD2 +noBlink KEYWORD2 +display KEYWORD2 +noDisplay KEYWORD2 +autoscroll KEYWORD2 +noAutoscroll KEYWORD2 +leftToRight KEYWORD2 +rightToLeft KEYWORD2 +scrollDisplayLeft KEYWORD2 +scrollDisplayRight KEYWORD2 +createChar KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + From 29ed8df7e5bfe522c9e92e3885e0242403c3dde8 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Wed, 5 Dec 2012 15:35:41 +0100 Subject: [PATCH 39/73] fixed permissions on a lot of text files. see #1116 --- LiquidCrystal.h | 0 keywords.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 LiquidCrystal.h mode change 100755 => 100644 keywords.txt diff --git a/LiquidCrystal.h b/LiquidCrystal.h old mode 100755 new mode 100644 diff --git a/keywords.txt b/keywords.txt old mode 100755 new mode 100644 From c40724514c1d72d2dabf56b26a7fca16bd90e437 Mon Sep 17 00:00:00 2001 From: Fede85 Date: Wed, 26 Jun 2013 19:13:04 +0200 Subject: [PATCH 40/73] Ethernet, SD and LiquidCrystal to the new library format --- library.properties | 10 ++++++++++ LiquidCrystal.cpp => src/LiquidCrystal.cpp | 0 LiquidCrystal.h => src/LiquidCrystal.h | 0 3 files changed, 10 insertions(+) create mode 100644 library.properties rename LiquidCrystal.cpp => src/LiquidCrystal.cpp (100%) rename LiquidCrystal.h => src/LiquidCrystal.h (100%) diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..2fc0606 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=LiquidCrystal +author= +email=info@arduino.cc +sentence=The library to write on an alphanumeric LCD display. +paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). +url=http://arduino.cc/en/Reference/LiquidCrystal +architectures=avr, sam +version=1.0 +dependencies= none +core-dependencies=arduino (>=1.5.0) diff --git a/LiquidCrystal.cpp b/src/LiquidCrystal.cpp similarity index 100% rename from LiquidCrystal.cpp rename to src/LiquidCrystal.cpp diff --git a/LiquidCrystal.h b/src/LiquidCrystal.h similarity index 100% rename from LiquidCrystal.h rename to src/LiquidCrystal.h From 998f9ce164c317fa954464b4309637ee57168360 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 8 Aug 2013 16:40:55 +0200 Subject: [PATCH 41/73] Updated libraries metadata --- library.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library.properties b/library.properties index 2fc0606..d67278b 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=LiquidCrystal author= -email=info@arduino.cc -sentence=The library to write on an alphanumeric LCD display. -paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). +email= +sentence=Write to an alphanumeric LCD display. +paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). url=http://arduino.cc/en/Reference/LiquidCrystal -architectures=avr, sam +architectures=* version=1.0 -dependencies= none +dependencies= core-dependencies=arduino (>=1.5.0) From e0a449386898d0268259b272c7d4d2651204396f Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 21 Oct 2013 09:58:40 +0200 Subject: [PATCH 42/73] Run new astyle formatter against all the examples --- examples/Autoscroll/Autoscroll.ino | 26 +++---- examples/Blink/Blink.ino | 22 +++--- examples/Cursor/Cursor.ino | 16 ++-- examples/CustomCharacter/CustomCharacter.ino | 30 +++---- examples/Display/Display.ino | 18 ++--- examples/HelloWorld/HelloWorld.ino | 16 ++-- examples/Scroll/Scroll.ino | 34 ++++---- examples/SerialDisplay/SerialDisplay.ino | 22 +++--- examples/TextDirection/TextDirection.ino | 82 ++++++++++---------- examples/setCursor/setCursor.ino | 22 +++--- 10 files changed, 144 insertions(+), 144 deletions(-) diff --git a/examples/Autoscroll/Autoscroll.ino b/examples/Autoscroll/Autoscroll.ino index 1127d8f..0acb3af 100644 --- a/examples/Autoscroll/Autoscroll.ino +++ b/examples/Autoscroll/Autoscroll.ino @@ -1,14 +1,14 @@ /* LiquidCrystal Library - Autoscroll - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - + This sketch demonstrates the use of the autoscroll() and noAutoscroll() functions to make new text scroll or not. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -20,16 +20,16 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe - + This example code is in the public domain. http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll @@ -43,8 +43,8 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16,2); + // set up the LCD's number of columns and rows: + lcd.begin(16, 2); } void loop() { @@ -52,12 +52,12 @@ void loop() { lcd.setCursor(0, 0); // print from 0 to 9: for (int thisChar = 0; thisChar < 10; thisChar++) { - lcd.print(thisChar); - delay(500); + lcd.print(thisChar); + delay(500); } // set the cursor to (16,1): - lcd.setCursor(16,1); + lcd.setCursor(16, 1); // set the display to automatically scroll: lcd.autoscroll(); // print from 0 to 9: @@ -67,7 +67,7 @@ void loop() { } // turn off automatic scrolling lcd.noAutoscroll(); - + // clear screen for the next loop: lcd.clear(); } diff --git a/examples/Blink/Blink.ino b/examples/Blink/Blink.ino index 9667b5d..856d522 100644 --- a/examples/Blink/Blink.ino +++ b/examples/Blink/Blink.ino @@ -1,14 +1,14 @@ /* LiquidCrystal Library - Blink - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD and makes the + + This sketch prints "Hello World!" to the LCD and makes the cursor block blink. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -20,20 +20,20 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe - + This example code is in the public domain. http://arduino.cc/en/Tutorial/LiquidCrystalBlink - + */ // include the library code: @@ -43,7 +43,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); @@ -53,7 +53,7 @@ void loop() { // Turn off the blinking cursor: lcd.noBlink(); delay(3000); - // Turn on the blinking cursor: + // Turn on the blinking cursor: lcd.blink(); delay(3000); } diff --git a/examples/Cursor/Cursor.ino b/examples/Cursor/Cursor.ino index 05862a4..5f68d91 100644 --- a/examples/Cursor/Cursor.ino +++ b/examples/Cursor/Cursor.ino @@ -1,15 +1,15 @@ /* LiquidCrystal Library - Cursor - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - + This sketch prints "Hello World!" to the LCD and uses the cursor() and noCursor() methods to turn on and off the cursor. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -21,13 +21,13 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe @@ -44,7 +44,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); @@ -54,7 +54,7 @@ void loop() { // Turn off the cursor: lcd.noCursor(); delay(500); - // Turn on the cursor: + // Turn on the cursor: lcd.cursor(); delay(500); } diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/CustomCharacter/CustomCharacter.ino index d3ce479..3a96488 100644 --- a/examples/CustomCharacter/CustomCharacter.ino +++ b/examples/CustomCharacter/CustomCharacter.ino @@ -1,14 +1,14 @@ /* LiquidCrystal Library - Custom Characters - - Demonstrates how to add custom characters on an LCD display. - The LiquidCrystal library works with all LCD displays that are - compatible with the Hitachi HD44780 driver. There are many of + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - + This sketch prints "I Arduino!" and a little dancing man to the LCD. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -21,18 +21,18 @@ * ends to +5V and ground * wiper to LCD VO pin (pin 3) * 10K poterntiometer on pin A0 - + created21 Mar 2011 by Tom Igoe Based on Adafruit's example at https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde - + This example code is in the public domain. http://www.arduino.cc/en/Tutorial/LiquidCrystal - + Also useful: http://icontexto.com/charactercreator/ - + */ // include the library code: @@ -104,14 +104,14 @@ void setup() { // create a new character lcd.createChar(2, frownie); // create a new character - lcd.createChar(3, armsDown); + lcd.createChar(3, armsDown); // create a new character - lcd.createChar(4, armsUp); + lcd.createChar(4, armsUp); - // set up the lcd's number of columns and rows: + // set up the lcd's number of columns and rows: lcd.begin(16, 2); // Print a message to the lcd. - lcd.print("I "); + lcd.print("I "); lcd.write(0); lcd.print(" Arduino! "); lcd.write(1); @@ -131,7 +131,7 @@ void loop() { lcd.setCursor(4, 1); // draw him arms up: lcd.write(4); - delay(delayTime); + delay(delayTime); } diff --git a/examples/Display/Display.ino b/examples/Display/Display.ino index a85effb..5c9e67c 100644 --- a/examples/Display/Display.ino +++ b/examples/Display/Display.ino @@ -1,15 +1,15 @@ /* LiquidCrystal Library - display() and noDisplay() - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD and uses the + + This sketch prints "Hello World!" to the LCD and uses the display() and noDisplay() functions to turn on and off the display. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -21,13 +21,13 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe @@ -44,7 +44,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); @@ -54,7 +54,7 @@ void loop() { // Turn off the display: lcd.noDisplay(); delay(500); - // Turn on the display: + // Turn on the display: lcd.display(); delay(500); } diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino index e99957d..ec495b3 100644 --- a/examples/HelloWorld/HelloWorld.ino +++ b/examples/HelloWorld/HelloWorld.ino @@ -1,14 +1,14 @@ /* LiquidCrystal Library - Hello World - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - + This sketch prints "Hello World!" to the LCD and shows the time. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -20,7 +20,7 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 @@ -29,7 +29,7 @@ by Tom Igoe modified 22 Nov 2010 by Tom Igoe - + This example code is in the public domain. http://www.arduino.cc/en/Tutorial/LiquidCrystal @@ -42,7 +42,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); @@ -53,6 +53,6 @@ void loop() { // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: - lcd.print(millis()/1000); + lcd.print(millis() / 1000); } diff --git a/examples/Scroll/Scroll.ino b/examples/Scroll/Scroll.ino index 0d6d8dc..3e44791 100644 --- a/examples/Scroll/Scroll.ino +++ b/examples/Scroll/Scroll.ino @@ -1,15 +1,15 @@ /* LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - + This sketch prints "Hello World!" to the LCD and uses the scrollDisplayLeft() and scrollDisplayRight() methods to scroll the text. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -21,18 +21,18 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe - + This example code is in the public domain. - + http://arduino.cc/en/Tutorial/LiquidCrystalScroll */ @@ -44,7 +44,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); @@ -52,11 +52,11 @@ void setup() { } void loop() { - // scroll 13 positions (string length) to the left + // scroll 13 positions (string length) to the left // to move it offscreen left: for (int positionCounter = 0; positionCounter < 13; positionCounter++) { // scroll one position left: - lcd.scrollDisplayLeft(); + lcd.scrollDisplayLeft(); // wait a bit: delay(150); } @@ -65,20 +65,20 @@ void loop() { // to move it offscreen right: for (int positionCounter = 0; positionCounter < 29; positionCounter++) { // scroll one position right: - lcd.scrollDisplayRight(); + lcd.scrollDisplayRight(); // wait a bit: delay(150); } - - // scroll 16 positions (display length + string length) to the left - // to move it back to center: + + // scroll 16 positions (display length + string length) to the left + // to move it back to center: for (int positionCounter = 0; positionCounter < 16; positionCounter++) { // scroll one position left: - lcd.scrollDisplayLeft(); + lcd.scrollDisplayLeft(); // wait a bit: delay(150); } - + // delay at the end of the full loop: delay(1000); diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/SerialDisplay/SerialDisplay.ino index a6f8f40..5838dc5 100644 --- a/examples/SerialDisplay/SerialDisplay.ino +++ b/examples/SerialDisplay/SerialDisplay.ino @@ -1,14 +1,14 @@ /* LiquidCrystal Library - Serial Input - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - - This sketch displays text sent over the serial port + + This sketch displays text sent over the serial port (e.g. from the Serial Monitor) on an attached LCD. - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -20,18 +20,18 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe - + This example code is in the public domain. - + http://arduino.cc/en/Tutorial/LiquidCrystalSerial */ @@ -41,8 +41,8 @@ // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); -void setup(){ - // set up the LCD's number of columns and rows: +void setup() { + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // initialize the serial communications: Serial.begin(9600); diff --git a/examples/TextDirection/TextDirection.ino b/examples/TextDirection/TextDirection.ino index cabd8ea..3bb8695 100644 --- a/examples/TextDirection/TextDirection.ino +++ b/examples/TextDirection/TextDirection.ino @@ -1,40 +1,40 @@ - /* - LiquidCrystal Library - TextDirection - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch demonstrates how to use leftToRight() and rightToLeft() - to move the cursor. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection - - */ +/* +LiquidCrystal Library - TextDirection + +Demonstrates the use a 16x2 LCD display. The LiquidCrystal +library works with all LCD displays that are compatible with the +Hitachi HD44780 driver. There are many of them out there, and you +can usually tell them by the 16-pin interface. + +This sketch demonstrates how to use leftToRight() and rightToLeft() +to move the cursor. + +The circuit: +* LCD RS pin to digital pin 12 +* LCD Enable pin to digital pin 11 +* LCD D4 pin to digital pin 5 +* LCD D5 pin to digital pin 4 +* LCD D6 pin to digital pin 3 +* LCD D7 pin to digital pin 2 +* LCD R/W pin to ground +* 10K resistor: +* ends to +5V and ground +* wiper to LCD VO pin (pin 3) + +Library originally added 18 Apr 2008 +by David A. Mellis +library modified 5 Jul 2009 +by Limor Fried (http://www.ladyada.net) +example added 9 Jul 2009 +by Tom Igoe +modified 22 Nov 2010 +by Tom Igoe + +This example code is in the public domain. + +http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection + +*/ // include the library code: #include @@ -45,7 +45,7 @@ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int thisChar = 'a'; void setup() { - // set up the LCD's number of columns and rows: + // set up the LCD's number of columns and rows: lcd.begin(16, 2); // turn on the cursor: lcd.cursor(); @@ -55,17 +55,17 @@ void loop() { // reverse directions at 'm': if (thisChar == 'm') { // go right for the next letter - lcd.rightToLeft(); + lcd.rightToLeft(); } // reverse again at 's': if (thisChar == 's') { // go left for the next letter - lcd.leftToRight(); + lcd.leftToRight(); } // reset at 'z': if (thisChar > 'z') { // go to (0,0): - lcd.home(); + lcd.home(); // start again at 0 thisChar = 'a'; } diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino index e45c491..689f329 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setCursor/setCursor.ino @@ -1,14 +1,14 @@ /* LiquidCrystal Library - setCursor - + Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the + library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. - + This sketch prints to all the positions of the LCD using the setCursor(0 method: - + The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 @@ -20,18 +20,18 @@ * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) - + Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 - by Tom Igoe + by Tom Igoe modified 22 Nov 2010 by Tom Igoe - + This example code is in the public domain. - + http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor */ @@ -48,8 +48,8 @@ const int numCols = 16; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(numCols,numRows); + // set up the LCD's number of columns and rows: + lcd.begin(numCols, numRows); } void loop() { @@ -60,7 +60,7 @@ void loop() { // loop over the rows: for (int thisRow = 0; thisRow < numCols; thisRow++) { // set the cursor position: - lcd.setCursor(thisRow,thisCol); + lcd.setCursor(thisRow, thisCol); // print the letter: lcd.write(thisLetter); delay(200); From 40fd0b306ace8da737914efdefc58ba2a8328b53 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 21 Oct 2013 13:16:51 +0200 Subject: [PATCH 43/73] Fixed compilation errors with some examples --- examples/CustomCharacter/CustomCharacter.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/CustomCharacter/CustomCharacter.ino index 3a96488..233cad1 100644 --- a/examples/CustomCharacter/CustomCharacter.ino +++ b/examples/CustomCharacter/CustomCharacter.ino @@ -112,9 +112,9 @@ void setup() { lcd.begin(16, 2); // Print a message to the lcd. lcd.print("I "); - lcd.write(0); + lcd.write((byte) 0); lcd.print(" Arduino! "); - lcd.write(1); + lcd.write((byte) 1); } From bd481b0c7bf02493d7bdf69f3bd1a0c1ff592da1 Mon Sep 17 00:00:00 2001 From: Scott Fitzgerald Date: Mon, 11 Nov 2013 16:41:12 +0400 Subject: [PATCH 44/73] Modified LCD custom character example moved lcd.begin() to the beginnng of the setup() and fixed an issue that prevented the example from compiling. When calling lcd.write() with an argument of 0, the 0 must be cast a s a byte. --- examples/CustomCharacter/CustomCharacter.ino | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/CustomCharacter/CustomCharacter.ino index d3ce479..f714a3a 100644 --- a/examples/CustomCharacter/CustomCharacter.ino +++ b/examples/CustomCharacter/CustomCharacter.ino @@ -22,8 +22,11 @@ * wiper to LCD VO pin (pin 3) * 10K poterntiometer on pin A0 - created21 Mar 2011 + created 21 Mar 2011 by Tom Igoe + modified 11 Nov 2013 + by Scott Fitzgerald + Based on Adafruit's example at https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde @@ -96,7 +99,11 @@ byte armsUp[8] = { 0b00100, 0b01010 }; + void setup() { + // initialize LCD and set up the number of columns and rows: + lcd.begin(16, 2); + // create a new character lcd.createChar(0, heart); // create a new character @@ -108,11 +115,9 @@ void setup() { // create a new character lcd.createChar(4, armsUp); - // set up the lcd's number of columns and rows: - lcd.begin(16, 2); // Print a message to the lcd. lcd.print("I "); - lcd.write(0); + lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte lcd.print(" Arduino! "); lcd.write(1); @@ -133,6 +138,3 @@ void loop() { lcd.write(4); delay(delayTime); } - - - From 138bcb17c39aa662166a74abab76e9a9023d416e Mon Sep 17 00:00:00 2001 From: Mark Sproul Date: Sun, 4 Dec 2011 16:54:32 -0500 Subject: [PATCH 45/73] Added setRowOffsets to LiquidCrystal library Original commit by Mark Sproul, but cleaned up by Matthijs Kooijman. --- src/LiquidCrystal.cpp | 15 ++++++++++++--- src/LiquidCrystal.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 0653487..5dbb830 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -79,6 +79,8 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; + setRowOffsets(0x00, 0x40, 0x14, 0x54); + begin(16, 1); } @@ -157,6 +159,14 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } +void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3) +{ + _row_offsets[0] = row0; + _row_offsets[1] = row1; + _row_offsets[2] = row2; + _row_offsets[3] = row3; +} + /********** high level commands, for the user! */ void LiquidCrystal::clear() { @@ -172,12 +182,11 @@ void LiquidCrystal::home() void LiquidCrystal::setCursor(uint8_t col, uint8_t row) { - int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; if ( row >= _numlines ) { - row = _numlines-1; // we count rows starting w/0 + row = _numlines - 1; // we count rows starting w/0 } - command(LCD_SETDDRAMADDR | (col + row_offsets[row])); + command(LCD_SETDDRAMADDR | (col + _row_offsets[row])); } // Turn the display on/off (quickly) diff --git a/src/LiquidCrystal.h b/src/LiquidCrystal.h index 24ec5af..1c0fa4f 100644 --- a/src/LiquidCrystal.h +++ b/src/LiquidCrystal.h @@ -77,6 +77,7 @@ public: void autoscroll(); void noAutoscroll(); + void setRowOffsets(int row1, int row2, int row3, int row4); void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); virtual size_t write(uint8_t); @@ -101,6 +102,7 @@ private: uint8_t _initialized; uint8_t _numlines,_currline; + int _row_offsets[4]; }; #endif From cb0c50909fcfaa39a1830d3c8f6c662cfaf22bf1 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 Dec 2013 12:37:01 +0100 Subject: [PATCH 46/73] Make the LiquidCrystal row offsets uint8_t instead of int Since these are memory addresses, there is no need to make them signed. Furthermore, the HD44780 chip supports memory addresses up to 0x67, so uint8_t shouldbe sufficient. --- src/LiquidCrystal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LiquidCrystal.h b/src/LiquidCrystal.h index 1c0fa4f..684a65f 100644 --- a/src/LiquidCrystal.h +++ b/src/LiquidCrystal.h @@ -102,7 +102,7 @@ private: uint8_t _initialized; uint8_t _numlines,_currline; - int _row_offsets[4]; + uint8_t _row_offsets[4]; }; #endif From beed8515f711ccb541642ac1f6e2f7ef4393f67b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 Dec 2013 12:34:44 +0100 Subject: [PATCH 47/73] In LiquidCrystal::setCursor(), check against length of _row_offsets as well Before, the row value was maximized against _numlines already, but the value from _numlines is not limited anywhere, so it could be longer than the length of _row_offsets. This check makes sure the array bounds is never exceeded. --- src/LiquidCrystal.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 5dbb830..27b5377 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -182,6 +182,10 @@ void LiquidCrystal::home() void LiquidCrystal::setCursor(uint8_t col, uint8_t row) { + const size_t max_lines = sizeof(_row_offsets) / sizeof(*_row_offsets); + if ( row >= max_lines ) { + row = max_lines - 1; // we count rows starting w/0 + } if ( row >= _numlines ) { row = _numlines - 1; // we count rows starting w/0 } From 596e305a4d115ee53132e99ac3d9a07ab752f837 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 Dec 2013 12:54:53 +0100 Subject: [PATCH 48/73] Support more LiquidCrystal displays out of the box Previously, the row offsets were hardcoded to the ones used for 20x4 displays (which woudl also work for all 2-line displays). Now, the number of columns given is used to calculate the offsets most likely to apply. For 2-line displays and 20x4 displays, the (used) offsets are completel unchanged. With this change, common 16x4 displays and (if they even exist) other 4-line and 3-line displays might also work (depending on the hardware configuration used, of course). See this page for some info on common LCD sizes and configurations encountered in practice: http://web.alfredstate.edu/weimandn/lcd/lcd_addressing/lcd_addressing_index.html --- src/LiquidCrystal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 27b5377..5825945 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -79,8 +79,6 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - setRowOffsets(0x00, 0x40, 0x14, 0x54); - begin(16, 1); } @@ -91,6 +89,8 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { _numlines = lines; _currline = 0; + setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); + // for some 1 line displays you can select a 10 pixel high font if ((dotsize != 0) && (lines == 1)) { _displayfunction |= LCD_5x10DOTS; From c2a0d844b605bad78fa032aa1bd2f3c635ed232a Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 Dec 2013 13:01:11 +0100 Subject: [PATCH 49/73] In LiquidCrystal::begin(), use a define instead of a hardcoded 0 --- src/LiquidCrystal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 5825945..9579c01 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -92,7 +92,7 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); // for some 1 line displays you can select a 10 pixel high font - if ((dotsize != 0) && (lines == 1)) { + if ((dotsize != LCD_5x8DOTS) && (lines == 1)) { _displayfunction |= LCD_5x10DOTS; } From dbb718a53e767737815616ab682b62794b40febb Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 Dec 2013 13:02:05 +0100 Subject: [PATCH 50/73] In LiquidCrystal, remove an unused variable --- src/LiquidCrystal.cpp | 1 - src/LiquidCrystal.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 9579c01..58120e8 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -87,7 +87,6 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { _displayfunction |= LCD_2LINE; } _numlines = lines; - _currline = 0; setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); diff --git a/src/LiquidCrystal.h b/src/LiquidCrystal.h index 684a65f..da950ce 100644 --- a/src/LiquidCrystal.h +++ b/src/LiquidCrystal.h @@ -101,7 +101,7 @@ private: uint8_t _initialized; - uint8_t _numlines,_currline; + uint8_t _numlines; uint8_t _row_offsets[4]; }; From e71db845e78fc41fc243dc5aaf3abe4ce13bbab4 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 18 Feb 2014 17:22:40 +0100 Subject: [PATCH 51/73] Updated all library.properties to 1.5 rev2 lib format --- library.properties | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library.properties b/library.properties index d67278b..039677d 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,8 @@ name=LiquidCrystal +version=1.0 author= -email= +maintainer=Arduino sentence=Write to an alphanumeric LCD display. paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). url=http://arduino.cc/en/Reference/LiquidCrystal architectures=* -version=1.0 -dependencies= -core-dependencies=arduino (>=1.5.0) From a8a2e47a3f7727696fc9810471dea2ce7dbaff9a Mon Sep 17 00:00:00 2001 From: Ankit Daftery Date: Thu, 3 Jul 2014 13:08:12 +0530 Subject: [PATCH 52/73] Update HelloWorld.ino Adding power connections, just to be thorough --- examples/HelloWorld/HelloWorld.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino index e99957d..eaf0f6f 100644 --- a/examples/HelloWorld/HelloWorld.ino +++ b/examples/HelloWorld/HelloWorld.ino @@ -17,6 +17,8 @@ * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground + * LCD VSS pin to ground + * LCD VCC pin to 5V * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) From 32c6f8c74613569f2440b077638a9428bce5c493 Mon Sep 17 00:00:00 2001 From: Fede85 Date: Fri, 18 Jul 2014 19:11:54 +0200 Subject: [PATCH 53/73] modified sentences in library.properties files --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 039677d..514b293 100644 --- a/library.properties +++ b/library.properties @@ -2,7 +2,7 @@ name=LiquidCrystal version=1.0 author= maintainer=Arduino -sentence=Write to an alphanumeric LCD display. +sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). url=http://arduino.cc/en/Reference/LiquidCrystal architectures=* From 14bda8dca4f68d24b436ff5c4d67b5fef8834add Mon Sep 17 00:00:00 2001 From: Amulya Kumar Sahoo Date: Wed, 23 Jul 2014 01:17:31 +0530 Subject: [PATCH 54/73] Fix of a spelling mistake --- LiquidCrystal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LiquidCrystal.cpp b/LiquidCrystal.cpp index 0653487..d7bd9e4 100644 --- a/LiquidCrystal.cpp +++ b/LiquidCrystal.cpp @@ -96,7 +96,7 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 + // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); From 71761686591ef06e0e076c129181e00e6b05cfdf Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 7 Nov 2014 19:24:12 +0100 Subject: [PATCH 55/73] Added missing keyword in LiquidCrystal library --- keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/keywords.txt b/keywords.txt index 132845c..4ee24d9 100644 --- a/keywords.txt +++ b/keywords.txt @@ -30,6 +30,7 @@ rightToLeft KEYWORD2 scrollDisplayLeft KEYWORD2 scrollDisplayRight KEYWORD2 createChar KEYWORD2 +setRowOffsets KEYWORD2 ####################################### # Constants (LITERAL1) From 671fcfcc5a272993e934c98b35f5bbfb4c436858 Mon Sep 17 00:00:00 2001 From: Arturo Guadalupi Date: Mon, 12 Jan 2015 14:37:50 +0100 Subject: [PATCH 56/73] Update setCursor.ino Changedfrom (thisRow, thisCol) to lcd.Setcursor(thisCol, thisRow). It was an error. --- examples/setCursor/setCursor.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino index e45c491..951c8a5 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setCursor/setCursor.ino @@ -60,7 +60,7 @@ void loop() { // loop over the rows: for (int thisRow = 0; thisRow < numCols; thisRow++) { // set the cursor position: - lcd.setCursor(thisRow,thisCol); + lcd.setCursor(thisCol,thisRow); // print the letter: lcd.write(thisLetter); delay(200); From 6d32f53cda15d3e9a76cf515a1ae6a3b5eb855fb Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 29 Aug 2014 15:16:19 +0200 Subject: [PATCH 57/73] Fixed some libraries metadata. --- library.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/library.properties b/library.properties index 514b293..05d2c9f 100644 --- a/library.properties +++ b/library.properties @@ -4,5 +4,6 @@ author= maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). +category=Display url=http://arduino.cc/en/Reference/LiquidCrystal architectures=* From c9c5d64a4523b24a9085921465f747ac4c7b93da Mon Sep 17 00:00:00 2001 From: Arturo Guadalupi Date: Fri, 16 Jan 2015 15:35:22 +0100 Subject: [PATCH 58/73] Added README.adoc for the library manager project --- README.adoc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 README.adoc diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..6f57eb1 --- /dev/null +++ b/README.adoc @@ -0,0 +1,24 @@ += Liquid Crystal Library for Arduino = + +This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. + +For more information about this library please visit us at +http://arduino.cc/en/Reference/LiquidCrystal + +== License == + +Copyright (c) Arduino LLC. All right reserved. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA From ea5de4455a8f3f8b4c022bca15d6cd424aef2159 Mon Sep 17 00:00:00 2001 From: Arturo Guadalupi Date: Mon, 12 Jan 2015 14:37:50 +0100 Subject: [PATCH 59/73] Cherry picked fix from 87865ac19df2f55e3d073cf5dc7ba08c0de4c584 --- examples/setCursor/setCursor.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino index 689f329..4790b68 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setCursor/setCursor.ino @@ -60,7 +60,7 @@ void loop() { // loop over the rows: for (int thisRow = 0; thisRow < numCols; thisRow++) { // set the cursor position: - lcd.setCursor(thisRow, thisCol); + lcd.setCursor(thisCol, thisRow); // print the letter: lcd.write(thisLetter); delay(200); From a368b24ecac3746258d576286ee9486ca34a5059 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Wed, 25 Feb 2015 11:20:40 +0100 Subject: [PATCH 60/73] Libraries: added missing properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 05d2c9f..4786c58 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=LiquidCrystal version=1.0 -author= +author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). From 9f39004e049d45420398c704d8f871e27a3be1ac Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Fri, 27 Mar 2015 15:01:49 +0100 Subject: [PATCH 61/73] Libraries: version now compliant with semver. See http://semver.org/ --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 4786c58..5ab13d1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LiquidCrystal -version=1.0 +version=1.0.0 author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. From 1f44a433292df47b0031a4196120fa50047434ed Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Thu, 23 Apr 2015 13:01:30 +0200 Subject: [PATCH 62/73] Bundled libraries update --- library.properties | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/library.properties b/library.properties index 5ab13d1..37764b2 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ -name=LiquidCrystal -version=1.0.0 -author=Arduino, Adafruit -maintainer=Arduino -sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. -paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). -category=Display -url=http://arduino.cc/en/Reference/LiquidCrystal -architectures=* +name=LiquidCrystal +version=1.0.0 +author=Arduino, Adafruit +maintainer=Arduino +sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. +paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). +category=Display +url=http://arduino.cc/en/Reference/LiquidCrystal +architectures=* From e86ca41aaa8cf6800c1638485086d662f8a44562 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Thu, 23 Apr 2015 17:19:15 +0200 Subject: [PATCH 63/73] Libraries: added help files to mitigate missing contextual reference issue --- keywords.txt | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keywords.txt b/keywords.txt index 4ee24d9..b6aa7fd 100644 --- a/keywords.txt +++ b/keywords.txt @@ -6,7 +6,7 @@ # Datatypes (KEYWORD1) ####################################### -LiquidCrystal KEYWORD1 +LiquidCrystal KEYWORD1 LiquidCrystal ####################################### # Methods and Functions (KEYWORD2) diff --git a/library.properties b/library.properties index 37764b2..f379f78 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LiquidCrystal -version=1.0.0 +version=1.0.1 author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. From c53d782f0b7b0fef86071c10fc8d4bbd6066e79a Mon Sep 17 00:00:00 2001 From: newbie15 Date: Tue, 26 Mar 2013 15:44:33 +0700 Subject: [PATCH 64/73] Added a note about non-standard row offsets in LiquidCrystal.cpp In my case I had to change it to make my 16x4 LCD work properly Fixes #1333 --- src/LiquidCrystal.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 249e0ec..9bf508b 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -158,12 +158,18 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } +/* + in some 16x4 LCD when line 3 and 4 are not placed correctly you may try: + setRowOffsets(0x00, 0x40, 0x14, 0x54) + or + setRowOffsets(0x00, 0x40, 0x10, 0x50) + */ void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3) { - _row_offsets[0] = row0; - _row_offsets[1] = row1; - _row_offsets[2] = row2; - _row_offsets[3] = row3; + _row_offsets[0] = row0; + _row_offsets[1] = row1; + _row_offsets[2] = row2; + _row_offsets[3] = row3; } /********** high level commands, for the user! */ From 472c10752a0cb9bbce155cb33138c6ff97367d61 Mon Sep 17 00:00:00 2001 From: Ish Gupta Date: Thu, 14 May 2015 18:30:17 +0530 Subject: [PATCH 65/73] Updated cursor.ino Previous commit broke the actual functionality. The code was confusing and worked until the previous commit. The changes make it logically and functionally correct. --- examples/setCursor/setCursor.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino index 4790b68..df75f7f 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setCursor/setCursor.ino @@ -7,7 +7,7 @@ can usually tell them by the 16-pin interface. This sketch prints to all the positions of the LCD using the - setCursor(0 method: + setCursor() method: The circuit: * LCD RS pin to digital pin 12 @@ -56,9 +56,9 @@ void loop() { // loop from ASCII 'a' to ASCII 'z': for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { // loop over the columns: - for (int thisCol = 0; thisCol < numRows; thisCol++) { + for (int thisRow = 0; thisRow < numRows; thisRow++) { // loop over the rows: - for (int thisRow = 0; thisRow < numCols; thisRow++) { + for (int thisCol = 0; thisCol < numCols; thisCol++) { // set the cursor position: lcd.setCursor(thisCol, thisRow); // print the letter: From c925fa611fb2992425a8dbea70e028568ed4f159 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Wed, 20 May 2015 17:10:06 +0200 Subject: [PATCH 66/73] Due to website configuration changes, every url starting with http://arduino.cc has been changed to http://www.arduino.cc. Fixes #3191 --- README.adoc | 2 +- examples/Autoscroll/Autoscroll.ino | 2 +- examples/Blink/Blink.ino | 2 +- examples/Cursor/Cursor.ino | 2 +- examples/Display/Display.ino | 2 +- examples/Scroll/Scroll.ino | 2 +- examples/SerialDisplay/SerialDisplay.ino | 2 +- examples/TextDirection/TextDirection.ino | 2 +- examples/setCursor/setCursor.ino | 2 +- library.properties | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.adoc b/README.adoc index 6f57eb1..d51cee7 100644 --- a/README.adoc +++ b/README.adoc @@ -3,7 +3,7 @@ This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. For more information about this library please visit us at -http://arduino.cc/en/Reference/LiquidCrystal +http://www.arduino.cc/en/Reference/LiquidCrystal == License == diff --git a/examples/Autoscroll/Autoscroll.ino b/examples/Autoscroll/Autoscroll.ino index 0acb3af..f70a1a7 100644 --- a/examples/Autoscroll/Autoscroll.ino +++ b/examples/Autoscroll/Autoscroll.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll + http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll */ diff --git a/examples/Blink/Blink.ino b/examples/Blink/Blink.ino index 856d522..fea13a3 100644 --- a/examples/Blink/Blink.ino +++ b/examples/Blink/Blink.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalBlink + http://www.arduino.cc/en/Tutorial/LiquidCrystalBlink */ diff --git a/examples/Cursor/Cursor.ino b/examples/Cursor/Cursor.ino index 5f68d91..8699d27 100644 --- a/examples/Cursor/Cursor.ino +++ b/examples/Cursor/Cursor.ino @@ -33,7 +33,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalCursor + http://www.arduino.cc/en/Tutorial/LiquidCrystalCursor */ diff --git a/examples/Display/Display.ino b/examples/Display/Display.ino index 5c9e67c..90b14f0 100644 --- a/examples/Display/Display.ino +++ b/examples/Display/Display.ino @@ -33,7 +33,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalDisplay + http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay */ diff --git a/examples/Scroll/Scroll.ino b/examples/Scroll/Scroll.ino index 3e44791..0a4a95f 100644 --- a/examples/Scroll/Scroll.ino +++ b/examples/Scroll/Scroll.ino @@ -33,7 +33,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalScroll + http://www.arduino.cc/en/Tutorial/LiquidCrystalScroll */ diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/SerialDisplay/SerialDisplay.ino index 5838dc5..ec46ff0 100644 --- a/examples/SerialDisplay/SerialDisplay.ino +++ b/examples/SerialDisplay/SerialDisplay.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalSerial + http://www.arduino.cc/en/Tutorial/LiquidCrystalSerial */ // include the library code: diff --git a/examples/TextDirection/TextDirection.ino b/examples/TextDirection/TextDirection.ino index 3bb8695..c838d81 100644 --- a/examples/TextDirection/TextDirection.ino +++ b/examples/TextDirection/TextDirection.ino @@ -32,7 +32,7 @@ by Tom Igoe This example code is in the public domain. -http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection +http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection */ diff --git a/examples/setCursor/setCursor.ino b/examples/setCursor/setCursor.ino index df75f7f..d2dae93 100644 --- a/examples/setCursor/setCursor.ino +++ b/examples/setCursor/setCursor.ino @@ -32,7 +32,7 @@ This example code is in the public domain. - http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor + http://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor */ diff --git a/library.properties b/library.properties index f379f78..7aa5b52 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=LiquidCrystal -version=1.0.1 +version=1.0.2 author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). category=Display -url=http://arduino.cc/en/Reference/LiquidCrystal +url=http://www.arduino.cc/en/Reference/LiquidCrystal architectures=* From e1afbd651b7ae0caba71a5ea5e07c4a3075da415 Mon Sep 17 00:00:00 2001 From: Calvin Park Date: Wed, 1 Jul 2015 14:08:47 -0700 Subject: [PATCH 67/73] LiquidCrystal Library changes for Galileo and Edison compatibility --- src/LiquidCrystal.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/LiquidCrystal.cpp b/src/LiquidCrystal.cpp index 9bf508b..8c6cdf0 100644 --- a/src/LiquidCrystal.cpp +++ b/src/LiquidCrystal.cpp @@ -67,13 +67,6 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en _data_pins[6] = d6; _data_pins[7] = d7; - pinMode(_rs_pin, OUTPUT); - // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { - pinMode(_rw_pin, OUTPUT); - } - pinMode(_enable_pin, OUTPUT); - if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; else @@ -95,6 +88,19 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { _displayfunction |= LCD_5x10DOTS; } + pinMode(_rs_pin, OUTPUT); + // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# + if (_rw_pin != 255) { + pinMode(_rw_pin, OUTPUT); + } + pinMode(_enable_pin, OUTPUT); + + // Do these once, instead of every time a character is drawn for speed reasons. + for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i) + { + pinMode(_data_pins[i], OUTPUT); + } + // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 @@ -158,12 +164,6 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } -/* - in some 16x4 LCD when line 3 and 4 are not placed correctly you may try: - setRowOffsets(0x00, 0x40, 0x14, 0x54) - or - setRowOffsets(0x00, 0x40, 0x10, 0x50) - */ void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3) { _row_offsets[0] = row0; @@ -311,7 +311,6 @@ void LiquidCrystal::pulseEnable(void) { void LiquidCrystal::write4bits(uint8_t value) { for (int i = 0; i < 4; i++) { - pinMode(_data_pins[i], OUTPUT); digitalWrite(_data_pins[i], (value >> i) & 0x01); } @@ -320,7 +319,6 @@ void LiquidCrystal::write4bits(uint8_t value) { void LiquidCrystal::write8bits(uint8_t value) { for (int i = 0; i < 8; i++) { - pinMode(_data_pins[i], OUTPUT); digitalWrite(_data_pins[i], (value >> i) & 0x01); } From 4b93f42f41cfadeab5d60bf3a6b33d660c2ff8d5 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 6 Jul 2015 15:18:33 +0200 Subject: [PATCH 68/73] Examples: mass code format. See example_formatter.conf --- examples/CustomCharacter/CustomCharacter.ino | 10 +++++----- examples/SerialDisplay/SerialDisplay.ino | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/CustomCharacter/CustomCharacter.ino b/examples/CustomCharacter/CustomCharacter.ino index e70a949..bdac95c 100644 --- a/examples/CustomCharacter/CustomCharacter.ino +++ b/examples/CustomCharacter/CustomCharacter.ino @@ -21,12 +21,12 @@ * ends to +5V and ground * wiper to LCD VO pin (pin 3) * 10K poterntiometer on pin A0 - + created 21 Mar 2011 by Tom Igoe modified 11 Nov 2013 by Scott Fitzgerald - + Based on Adafruit's example at https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde @@ -101,9 +101,9 @@ byte armsUp[8] = { }; void setup() { - // initialize LCD and set up the number of columns and rows: + // initialize LCD and set up the number of columns and rows: lcd.begin(16, 2); - + // create a new character lcd.createChar(0, heart); // create a new character @@ -116,7 +116,7 @@ void setup() { lcd.createChar(4, armsUp); // Print a message to the lcd. - lcd.print("I "); + lcd.print("I "); lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte lcd.print(" Arduino! "); lcd.write((byte) 1); diff --git a/examples/SerialDisplay/SerialDisplay.ino b/examples/SerialDisplay/SerialDisplay.ino index ec46ff0..578e11e 100644 --- a/examples/SerialDisplay/SerialDisplay.ino +++ b/examples/SerialDisplay/SerialDisplay.ino @@ -48,8 +48,7 @@ void setup() { Serial.begin(9600); } -void loop() -{ +void loop() { // when characters arrive over the serial port... if (Serial.available()) { // wait a bit for the entire message to arrive From 603d842abc7f0ad9119319eeedd11433ff6b3b73 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 9 Jul 2015 15:04:26 +0200 Subject: [PATCH 69/73] LiquidCrystal: bumb version to 1.0.3 fix compatibility with Galileo and Edison --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 7aa5b52..94f8f63 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LiquidCrystal -version=1.0.2 +version=1.0.3 author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. From 382db03650b1fc086e0f34ff9f5f6a9d348d37b7 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Fri, 25 Sep 2015 15:17:35 +0200 Subject: [PATCH 70/73] Fixed license headers. See https://github.com/arduino/Arduino/pull/3498 --- README.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index d51cee7..7ec3219 100644 --- a/README.adoc +++ b/README.adoc @@ -7,7 +7,8 @@ http://www.arduino.cc/en/Reference/LiquidCrystal == License == -Copyright (c) Arduino LLC. All right reserved. +Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. +Copyright (c) 2010 Arduino LLC. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public From f7c7f21c37b687677df91bfb52d969f8f76d38ed Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 28 Oct 2015 15:12:56 +0100 Subject: [PATCH 71/73] Upgraded LiquidCrystal version --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 94f8f63..96185d6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LiquidCrystal -version=1.0.3 +version=1.0.4 author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. From 3fbf2198b1646591f9b45194fb9a68c9625404c7 Mon Sep 17 00:00:00 2001 From: Alice Pintus Date: Tue, 1 Mar 2016 16:09:50 +0100 Subject: [PATCH 72/73] update sentences --- library.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 96185d6..8b60908 100644 --- a/library.properties +++ b/library.properties @@ -2,8 +2,8 @@ name=LiquidCrystal version=1.0.4 author=Arduino, Adafruit maintainer=Arduino -sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards. -paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). +sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). +paragraph=This library allows an Arduino/Genuino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). category=Display url=http://www.arduino.cc/en/Reference/LiquidCrystal architectures=* From 735fd8a73eaf64c232550ec2089aaa4c42eb3051 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 8 Mar 2016 15:36:36 +0100 Subject: [PATCH 73/73] LiquidCrystal: update version to 1.0.5 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 8b60908..90a7ca7 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LiquidCrystal -version=1.0.4 +version=1.0.5 author=Arduino, Adafruit maintainer=Arduino sentence=Allows communication with alphanumerical liquid crystal displays (LCDs).