Pages: [1]   Go Down
Author Topic: createChar  (Read 1882 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this page:
http://arduino.cc/en/Reference/LiquidCrystalCreateChar
is missing the 8th line in the example code:

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

should be:

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

for two reasons:
1. the LiquidChristal library is always writing 8 lines
2. theres a overnumerous comma at the end (im surprised that the compiler is ignoring it)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The example code for LiquidCrystal::createChar() does not compile as written.
The call to lcd.write throws an error.
See: http://arduino.cc/en/Reference/LiquidCrystalCreateChar

I'm using Arduino environment v1.0, with avr-gcc-4.3.2.

Compile fails on lcd.write(0).
This is called after defining a custom character and loading it into the LCD with createChar(0,smiley).

Error is: "call of overloaded 'write(int)' is ambiguous".

Looking at the code in LiquidCrystal.cpp, I see the definition is LiquidCrystal::write(uint8_t value).

The call to lcd.write can be made to work with an explicit typecast: lcd.write( (uint8_t)0 );

Curiously, if I define a variable, and use it in the call, the example compiles happily:
   int zero = 0;  //or unsigned int zero = 0;  //OR even float zero = 0.0f;
   lcd.write(zero);

Calling with a float or double argument compiles as well: lcd.write(0.0); or lcd.write(0.0f); .

Curiouser, while calling lcd.write(0.0f); compiles, the two of these do NOT compile: lcd.write( (int)0 ); and lcd.write( (unsigned int)0 );.

And, thanks to the previous poster, TimeWaster, for pointing out the missing 8th line in the example character definition.  I completely overlooked the omission, myself.  But, somehow, that part of the code managed to compile and run smoothly...
Logged

Offline Offline
Faraday Member
**
Karma: 57
Posts: 2753
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just ran into this problem with the compilation failing,   your solution solved it, great.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4243
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good morning, Mr. TimeWaster. Your mission, should you choose to accept it, involves convincing the infallible that they have made a mistake. 

Actually it is not really impossible but in the process you will most likely think so.  You will probably find that your decision to pick that particular username will be reinforced.

Don
Logged

Pages: [1]   Go Up
Jump to: