Skip to content

Commit

Permalink
rename to Adafruit_LiquidCrystal to avoid collisions with default Liq…
Browse files Browse the repository at this point in the history
…uidCrystal
  • Loading branch information
ladyada committed Jan 21, 2016
1 parent 4d59d6e commit 38834a9
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 67 deletions.
72 changes: 36 additions & 36 deletions LiquidCrystal.cpp → Adafruit_LiquidCrystal.cpp
@@ -1,5 +1,5 @@
#include "Arduino.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
Expand Down Expand Up @@ -27,35 +27,35 @@
//
// 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).
// Adafruit_LiquidCrystal constructor is called).

LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
Adafruit_LiquidCrystal::Adafruit_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,
Adafruit_LiquidCrystal::Adafruit_LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
{
init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7);
}

LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
Adafruit_LiquidCrystal::Adafruit_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,
Adafruit_LiquidCrystal::Adafruit_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);
}

LiquidCrystal::LiquidCrystal(uint8_t i2caddr) {
Adafruit_LiquidCrystal::Adafruit_LiquidCrystal(uint8_t i2caddr) {
_i2cAddr = i2caddr;

_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
Expand All @@ -73,7 +73,7 @@ LiquidCrystal::LiquidCrystal(uint8_t i2caddr) {
}


LiquidCrystal::LiquidCrystal(uint8_t data, uint8_t clock, uint8_t latch ) {
Adafruit_LiquidCrystal::Adafruit_LiquidCrystal(uint8_t data, uint8_t clock, uint8_t latch ) {
_i2cAddr = 255;

_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
Expand All @@ -97,7 +97,7 @@ LiquidCrystal::LiquidCrystal(uint8_t data, uint8_t clock, uint8_t latch ) {
}


void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
void Adafruit_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)
{
Expand All @@ -123,7 +123,7 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
}

void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
void Adafruit_LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
// check if i2c
if (_i2cAddr != 255) {
_i2c.begin(_i2cAddr);
Expand Down Expand Up @@ -228,19 +228,19 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
}

/********** high level commands, for the user! */
void LiquidCrystal::clear()
void Adafruit_LiquidCrystal::clear()
{
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}

void LiquidCrystal::home()
void Adafruit_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)
void Adafruit_LiquidCrystal::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row > _numlines ) {
Expand All @@ -251,70 +251,70 @@ void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
}

// Turn the display on/off (quickly)
void LiquidCrystal::noDisplay() {
void Adafruit_LiquidCrystal::noDisplay() {
_displaycontrol &= ~LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::display() {
void Adafruit_LiquidCrystal::display() {
_displaycontrol |= LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}

// Turns the underline cursor on/off
void LiquidCrystal::noCursor() {
void Adafruit_LiquidCrystal::noCursor() {
_displaycontrol &= ~LCD_CURSORON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::cursor() {
void Adafruit_LiquidCrystal::cursor() {
_displaycontrol |= LCD_CURSORON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}

// Turn on and off the blinking cursor
void LiquidCrystal::noBlink() {
void Adafruit_LiquidCrystal::noBlink() {
_displaycontrol &= ~LCD_BLINKON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::blink() {
void Adafruit_LiquidCrystal::blink() {
_displaycontrol |= LCD_BLINKON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}

// These commands scroll the display without changing the RAM
void LiquidCrystal::scrollDisplayLeft(void) {
void Adafruit_LiquidCrystal::scrollDisplayLeft(void) {
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void LiquidCrystal::scrollDisplayRight(void) {
void Adafruit_LiquidCrystal::scrollDisplayRight(void) {
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}

// This is for text that flows Left to Right
void LiquidCrystal::leftToRight(void) {
void Adafruit_LiquidCrystal::leftToRight(void) {
_displaymode |= LCD_ENTRYLEFT;
command(LCD_ENTRYMODESET | _displaymode);
}

// This is for text that flows Right to Left
void LiquidCrystal::rightToLeft(void) {
void Adafruit_LiquidCrystal::rightToLeft(void) {
_displaymode &= ~LCD_ENTRYLEFT;
command(LCD_ENTRYMODESET | _displaymode);
}

// This will 'right justify' text from the cursor
void LiquidCrystal::autoscroll(void) {
void Adafruit_LiquidCrystal::autoscroll(void) {
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
command(LCD_ENTRYMODESET | _displaymode);
}

// This will 'left justify' text from the cursor
void LiquidCrystal::noAutoscroll(void) {
void Adafruit_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[]) {
void Adafruit_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++) {
Expand All @@ -324,25 +324,25 @@ void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) {

/*********** mid level commands, for sending data/cmds */

inline void LiquidCrystal::command(uint8_t value) {
inline void Adafruit_LiquidCrystal::command(uint8_t value) {
send(value, LOW);
}

#if ARDUINO >= 100
inline size_t LiquidCrystal::write(uint8_t value) {
inline size_t Adafruit_LiquidCrystal::write(uint8_t value) {
send(value, HIGH);
return 1;
}
#else
inline void LiquidCrystal::write(uint8_t value) {
inline void Adafruit_LiquidCrystal::write(uint8_t value) {
send(value, HIGH);
}
#endif

/************ low level data pushing commands **********/

// little wrapper for i/o writes
void LiquidCrystal::_digitalWrite(uint8_t p, uint8_t d) {
void Adafruit_LiquidCrystal::_digitalWrite(uint8_t p, uint8_t d) {
if (_i2cAddr != 255) {
// an i2c command
_i2c.digitalWrite(p, d);
Expand All @@ -362,15 +362,15 @@ void LiquidCrystal::_digitalWrite(uint8_t p, uint8_t d) {
}

// Allows to set the backlight, if the LCD backpack is used
void LiquidCrystal::setBacklight(uint8_t status) {
void Adafruit_LiquidCrystal::setBacklight(uint8_t status) {
// check if i2c or SPI
if ((_i2cAddr != 255) || (_SPIclock != 255)) {
_digitalWrite(7, status); // backlight is on pin 7
}
}

// little wrapper for i/o directions
void LiquidCrystal::_pinMode(uint8_t p, uint8_t d) {
void Adafruit_LiquidCrystal::_pinMode(uint8_t p, uint8_t d) {
if (_i2cAddr != 255) {
// an i2c command
_i2c.pinMode(p, d);
Expand All @@ -383,7 +383,7 @@ void LiquidCrystal::_pinMode(uint8_t p, uint8_t d) {
}

// write either command or data, with automatic 4/8-bit selection
void LiquidCrystal::send(uint8_t value, boolean mode) {
void Adafruit_LiquidCrystal::send(uint8_t value, boolean mode) {
_digitalWrite(_rs_pin, mode);

// if there is a RW pin indicated, set it low to Write
Expand All @@ -399,7 +399,7 @@ void LiquidCrystal::send(uint8_t value, boolean mode) {
}
}

void LiquidCrystal::pulseEnable(void) {
void Adafruit_LiquidCrystal::pulseEnable(void) {
_digitalWrite(_enable_pin, LOW);
delayMicroseconds(1);
_digitalWrite(_enable_pin, HIGH);
Expand All @@ -408,7 +408,7 @@ void LiquidCrystal::pulseEnable(void) {
delayMicroseconds(100); // commands need > 37us to settle
}

void LiquidCrystal::write4bits(uint8_t value) {
void Adafruit_LiquidCrystal::write4bits(uint8_t value) {
if (_i2cAddr != 255) {
uint8_t out = 0;

Expand Down Expand Up @@ -443,7 +443,7 @@ void LiquidCrystal::write4bits(uint8_t value) {
}
}

void LiquidCrystal::write8bits(uint8_t value) {
void Adafruit_LiquidCrystal::write8bits(uint8_t value) {
for (int i = 0; i < 8; i++) {
_pinMode(_data_pins[i], OUTPUT);
_digitalWrite(_data_pins[i], (value >> i) & 0x01);
Expand Down
18 changes: 9 additions & 9 deletions LiquidCrystal.h → Adafruit_LiquidCrystal.h
@@ -1,5 +1,5 @@
#ifndef LiquidCrystal_h
#define LiquidCrystal_h
#ifndef Adafruit_LiquidCrystal_h
#define Adafruit_LiquidCrystal_h

#include "Arduino.h"
#include <inttypes.h>
Expand Down Expand Up @@ -44,21 +44,21 @@
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00

class LiquidCrystal : public Print {
class Adafruit_LiquidCrystal : public Print {
public:
LiquidCrystal(uint8_t rs, uint8_t enable,
Adafruit_LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
Adafruit_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,
Adafruit_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,
Adafruit_LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);

LiquidCrystal(uint8_t i2cAddr);
LiquidCrystal(uint8_t data, uint8_t clock, uint8_t latch);
Adafruit_LiquidCrystal(uint8_t i2cAddr);
Adafruit_LiquidCrystal(uint8_t data, uint8_t clock, uint8_t latch);

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,
Expand Down
5 changes: 4 additions & 1 deletion README.md
@@ -1,4 +1,7 @@
# LiquidCrystal
# Adafruit_LiquidCrystal

This library has been renamed Adafruit_LiquidCrystal so as not to conflict with LiquidCrystal. Also, it now works with tiny85's if you have Adafruit AVR board pkg 1.4.3+

<!-- START COMPATIBILITY TABLE -->

## Compatibility
Expand Down
4 changes: 2 additions & 2 deletions examples/Blink/Blink.pde
Expand Up @@ -35,10 +35,10 @@

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Adafruit_LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of rows and columns:
Expand Down
4 changes: 2 additions & 2 deletions examples/Cursor/Cursor.pde
Expand Up @@ -36,10 +36,10 @@

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Adafruit_LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of rows and columns:
Expand Down
4 changes: 2 additions & 2 deletions examples/Display/Display.pde
Expand Up @@ -36,10 +36,10 @@

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Adafruit_LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of rows and columns:
Expand Down
4 changes: 2 additions & 2 deletions examples/HelloWorld/HelloWorld.pde
Expand Up @@ -35,10 +35,10 @@

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Adafruit_LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of rows and columns:
Expand Down
4 changes: 2 additions & 2 deletions examples/HelloWorld_SPI/HelloWorld_SPI.pde
Expand Up @@ -17,10 +17,10 @@

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"

// Connect via SPI. Data pin is #3, Clock is #2 and Latch is #4
LiquidCrystal lcd(3, 2, 4);
Adafruit_LiquidCrystal lcd(3, 2, 4);

void setup() {
// set up the LCD's number of rows and columns:
Expand Down
4 changes: 2 additions & 2 deletions examples/HelloWorld_i2c/HelloWorld_i2c.pde
Expand Up @@ -15,10 +15,10 @@

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
#include "Adafruit_LiquidCrystal.h"

// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);
Adafruit_LiquidCrystal lcd(0);

void setup() {
// set up the LCD's number of rows and columns:
Expand Down

4 comments on commit 38834a9

@pfeerick
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice move ladyada... is there any chance of renaming the github repo to match? Especially as there is a library properties file there now to make the library a bit more Arduino 1.5 friendly.

@ladyada
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will try now

@ladyada
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whew github does auto redirects 👍 done!

@pfeerick
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great... thanks for that!

Please sign in to comment.