Go Down

Topic: LiquidCrystal's setCursor bugs (Read 547 times) previous topic - next topic

cptProton

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?

Digger450

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

cptProton

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

Grumpy_Mike


cptProton

No, the function is defined as:

[font=Courier New]void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);[/font]

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

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

[font=Courier New]command(LCD_SETDDRAMADDR | (col + row_offsets[row]));[/font]

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.

thegeekway

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy