Jump to content
43oh

Error with Liquid Crystal library...


Recommended Posts

I am attempting to run the example sketch in the Liquid Crystal library that comes with Energia and am getting a compile error:

 

sketch_sep19a.cpp: In function 'void setup()':
sketch_sep19a.cpp:18:14: error: call of overloaded 'write(int)' is ambiguous
sketch_sep19a.cpp:18:14: note: candidates are:
C:\energia-0101E0008\hardware\msp430\libraries\LiquidCrystal/LiquidCrystal.h:82:18: note: virtual size_t LiquidCrystal::write(uint8_t)
C:\energia-0101E0008\hardware\msp430\cores\msp430/Print.h:56:12: note: size_t Print::write(const char*)

 

Here's the code:

#include 

LiquidCrystal lcd(P2_0,P2_1,P2_2,P2_3,P2_4,P2_5);

byte smiley[8] = {
 B00000,
 B10001,
 B00000,
 B00000,
 B10001,
 B01110,
 B00000,
};

void setup() {
 lcd.createChar(0, smiley);
 lcd.begin(16, 2);  
 lcd.write(0);
}

void loop() {}

Link to post
Share on other sites

Apparently the problem is with the numbering in the createChar() function of the Liquid Crystal library

 

The Liquid Crystal library documentation states:

Create a custom character (gylph) for use on the LCD. Up to eight characters of 5x8 pixels are supported (numbered 0 to 7). The appearance of each custom character is specified by an array of eight bytes, one for each row. The five least significant bits of each byte determine the pixels in that row. To display a custom character on the screen, write() its number.

 

I was able to resolve this issue by changing

lcd.createChar(0,smiley);
lcd.write(0);

to

lcd.createChar(1,smiley);
lcd.write(1);

 

I also confirmed that using 1-8 works for createChar(). Maybe the doc should be changed for the Liquid Crystal library that is included with Energia?

Link to post
Share on other sites

I had not tested the write modes. Thanks for testing and confirming that they work.

 

I looked at the code for createChar() and 0 should have worked. 8 however should not have worked. I am planning a little project that uses an LCD and will look at it in more detail then.

 

What is the make / model of your LCD?

 

Robert

Link to post
Share on other sites
  • 2 weeks later...

Hi,

 

I am just jumping in this thread.

I am new to LCD display (and new to almost everything in embedded computing I must say).

I just received a 16x2 LCD and was trying it with my Arduino because the Launchpad is currently used for something else.

While searching for a way to display bargraphs for another project (some kind of spectrum analyzer using FFT) I found this library :

https://bitbucket.org/fmalpartida/new-l ... /wiki/Home

Hardware abstraction seems better than the original one so perhaps porting it to Energia could be easier...

It is also faster and allows for using a shift register saving pins...

 

I will soon try it with the LaunchPad but I am busy until friday at least...

 

Regards,

Yan.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...