Pages: [1]   Go Down
Author Topic: LiquidCrystal: problem with one init function  (Read 368 times)
0 Members and 1 Guest are viewing this topic.
León - Spain
Offline Offline
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I had problems with my LCD using this function to initialize:
LiquidCrystal(rs,enable, d0, d1, d2, d3)

I used this to save one pin, the rw, that was conected to GND.

In the source code I found this at line 50:
 init(1, rs, -1, enable, d0, d1, d2, d3, 0, 0, 0, 0);
and this along the source code:
  if (_rw_pin != -1) {

I think that putting -1 into an unsigned value could be a problem (_rw_pin is uint_8), because then it's compared with -1 and I think the comparision it's made converting the unsigned value to an integer with sign and then compare 255 with -1 under an integer context.

i make a test, changin the library adding NOT_RW constant to .h with this value:
#define NOT_RW (uint8_t)-1
And using this "special -1" (maybe 255), everything works well. using 255 as an special value it's not a problem. Nobody have 255 inputs/outpus in Arduino. I think smiley-wink

The new library has this fixed? I get my library from the arduino website 2 days ago, and i think that it's the newer version.

« Last Edit: August 03, 2009, 05:58:36 am by Emyr_Lydaw » Logged

Pages: [1]   Go Up
Jump to: