Go Down

Topic: LiquidCrystal: problem with one init function (Read 388 times) previous topic - next topic

Emyr_Lydaw

Aug 03, 2009, 10:41 am Last Edit: Aug 03, 2009, 12:58 pm by Emyr_Lydaw Reason: 1
Hi

I had problems with my LCD using this function to initialize:
Code: [Select]
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:
Code: [Select]
 init(1, rs, -1, enable, d0, d1, d2, d3, 0, 0, 0, 0);
and this along the source code:
Code: [Select]
  if (_rw_pin != -1) {
   yap,yap,yap,......
 }


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 ;)

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.

Saludos!

Go Up