Pages: [1]   Go Down
Author Topic: Error in setCursor example (LiquidCrystal library)  (Read 309 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The setCursor example is confusing and therefore wrong (examples are there to clarify things, not to confuse  smiley-wink )

In the example (both on the website and in the v0017 download) the setCursor is used as:
Code:
lcd.setCursor(thisRow,thisCol);
The Reference says the syntax of setCursor is:
Code:
lcd.setCursor(col, row)
So the example uses different order for column and row parameters :-/

Also the for-next loops are confusing, thisCol counts from 0 to numRows:
Code:
for (int thisCol = 0; thisCol < numRows; thisCol++) {

and thisRow counts from 0 to numCols:
Code:
for (int this[b]Row[/b] = 0; thisRow < numCols; thisRow++) {


To clear up things I would suggest the following changes:
Code:
    // loop over the rows:
     for (int thisRow= 0; thisRow < numRows; thisRow++) {
       // loop over the columns:
       for (int thisCol = 0; thisCol < numCols; thisCol++) {
         // set the cursor position:
         lcd.setCursor(thisCol,thisRow);
Logged

New York, NY, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Howdy. I don't check PMs often, so email me!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

An oversight, we changed the order of the parameters, but not the naming, I'll get that cleaned up for the next version
Logged

Pages: [1]   Go Up
Jump to: