Go Down

Topic: New LiquidCrystal library - LCD library (Read 26 times) previous topic - next topic

dweston

Thanks fm, bperrybap and others for developing this library.

I've installed it and in preparation to begin working my way through its capabilities I tested my IDE 1.0 installation of the new Library with a number of the original LiquidCrystal examples. All worked fine until I struck an odd overload compile error with the Custom Characters sketch.

Code: [Select]
/*
  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 <heart> 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 <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// 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() {
  // set the cursor to the bottom row, 5th position:
  lcd.setCursor(4, 1);
  // draw the little man, arms down:
  lcd.write(3);
  delay(500);
  lcd.setCursor(4, 1);
  // draw him arms up:
  lcd.write(4);
  delay(500);
}


I get the following compile error which I do not have the Arduino knowledge to resolve:
Quote
CustomCharacter.cpp: In function 'void setup()':
CustomCharacter:114: error: call of overloaded 'write(int)' is ambiguous
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LCD.h:479: note: candidates are: virtual size_t LCD::write(uint8_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note:                 size_t Print::write(const char*)

fm

Umm, everything is possible with SW, but that is a bit odd.
   

fm

@dweston -  did you remove the old library, not just moving it somewhere else. There is an example in the New LiquidCrystal library that uses the creation of custom characters, helloworld_4bit. Give that a shot.
   

fm

@dweston - the other thing you can do is to change the byte declaration of the character creation variable by int8_t. This should fix it by not having ambiguities in the call.
   

dweston

@fm I followed your advice at Reply #80 "simply copy the contents of the zip file into the LiquidCrystal library folder of the Arduino IDE." The library folder I presumed you mean is the one within the Arduino.app contents package (I'm using MacOSX) i.e. [/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/].

Pardon the embarrassment of my naivety but I don't know how to apply your suggested "change the byte declaration of the character creation variable by int8_t"?

The example "helloworld_4bit" works fine, although I noted a spelling error in line 8:
Quote
LiquidCrystal lcd(8, 9, 4, 5, 6, 7, BACKLIGH_PIN, POSITIVE );


should read:
Quote
LiquidCrystal lcd(8, 9, 4, 5, 6, 7, BACKLIGHT_PIN, POSITIVE );


The pin number changes reflect the DFRobot-007 LCD Keypad shield I'm using.

Go Up