Pages: [1]   Go Down
Author Topic: LiquidCrystal's setCursor bugs  (Read 482 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With Arduino 0017 version of LiquidCrystal, when I do lcd.setCursor(0,0); it in fact does lcd.setCursor(8,0). setCursor(1,0) does setCursor(9,0) and so on. I'm using an 16x2 chr lcd.

Function void LiquidCrystal::setCursor(int col, int row) in the old version has been changed to void LiquidCrystal::setCursor(uint8_t col, uint8_t row).

When I also change the first row, the pick-up-table int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; type from int to uint8_t, the function starts to work as expected.

But why? Obviosly it should work either way. Is this a GCC bug?
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you remember to put lcd.begin(16,2); in your setup?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. begin(16, 2); doesn't help.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 620
Posts: 33992
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just try:-

 lcd.begin(2,16);
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, the function is defined as:

void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);

so begin(16,2) is the correct form.

If the table row_offsets[] is defined as ints, code bugs at this line:

command(LCD_SETDDRAMADDR | (col + row_offsets[row]));

Of course it shouldn't matter if you add either an int or uint8_t to an uint8_t. Int uses slightly more memory, but the result should be the same. So this is a compiler bug?

Additional info:

- I'm using a Mac, if this affects anything here.

- If I remember correctly, the 0017 version worked fine in some version of my "sketch". So when I change something elsewhere in the application, this setCursor() behavior changes even it should not.
Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 262
bluesmokelabs.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I also use lcd.begin(16,2); and it works spot on.
Logged

Pages: [1]   Go Up
Jump to: