LiquidCrystal library documentation: scrollDisplayLeft and scrollDisplayRight


having spent lot of time figuring out, think online library documentation (eg here http://arduino.cc/en/reference/liquidcrystalscrolldisplayleft) more following:

when using scrolldisplayleft() , scrolldisplayright() functions, library moves cursor , indexing system it. ran problems following bit of code displaying list of dummy 'tweets' on top line of 2 line display, 1 after other,  appearing aligned top left, scrolling off left:

code: [select]

// include library code:
#include <liquidcrystal.h>

// initialize library numbers of interface pins
liquidcrystal lcd(12, 11, 5, 4, 3, 2);

//creates string array containing 'tweets'
string tweets[] = {
  "1 tweet",
  "2 tweet",
  "3 tweet",
  "4 tweet",
  "5 tweet",
  "6 tweet",
  "7 tweet",
  "8 tweet",
  "9 tweet",
  "10 tweet"
};


void setup() {
  // set lcd's number of columns , rows:
  lcd.begin(16, 1);
}

void loop() {

  // sets loop cycling through each tweet in string array called 'tweets' - position in array
  (int = 0; < 10; i++) {
    // prints out tweet in position of array
    lcd.print(tweets[i]);
    // gets length in characters of particular tweet displayed
    int length = tweets[i].length();
    //waits half second
    delay(500);
    // scroll 'length' positions (tweet length) left
    // move offscreen left:
    (int positioncounter = 0; positioncounter < length; positioncounter++) {
      // scroll 1 position left:
      lcd.scrolldisplayleft();
      // wait bit:
      delay(150);
    }
    lcd.clear();
    lcd.setcursor(0,1);
  }
}



that code didn't work expected - each subsequent message display off screen left, despite lcd.setcursor(0,1) function.  :(

my workaround insert dummy bit of scrolling right with
code: [select]
    (int = 0; < length; i++){
      lcd.scrolldisplayright();
}

which brings (including cursor indexing system, or whatever want call it) starting position.
so:

code: [select]
// include library code:
#include <liquidcrystal.h>

// initialize library numbers of interface pins
liquidcrystal lcd(12, 11, 5, 4, 3, 2);

//creates string array containing 'tweets'
string tweets[] = {
  "1 tweet",
  "2 tweet",
  "3 tweet",
  "4 tweet",
  "5 tweet",
  "6 tweet",
  "7 tweet",
  "8 tweet",
  "9 tweet",
  "10 tweet"
};


void setup() {
  // set lcd's number of columns , rows:
  lcd.begin(16, 1);
}

void loop() {

  // sets loop cycling through each tweet in string array called 'tweets' - position in array
  (int = 0; < 10; i++) {
    // prints out tweet in position of array
    lcd.print(tweets[i]);
    // gets length in characters of particular tweet displayed
    int length = tweets[i].length();
    //waits half second
    delay(500);
    // scroll 'length' positions (tweet length) left
    // move offscreen left:
    (int positioncounter = 0; positioncounter < length; positioncounter++) {
      // scroll 1 position left:
      lcd.scrolldisplayleft();
      // wait bit:
      delay(150);
    }
    lcd.clear();
    lcd.setcursor(0,1);
    (int = 0; < length; i++){
      lcd.scrolldisplayright();
    }
  }
}


successfully positions each new message in top left of screen. :)

it not clear documentation how scrolldisplayleft() , scrolldisplayright() functions work. can improved?



Arduino Forum > Using Arduino > Programming Questions > LiquidCrystal library documentation: scrollDisplayLeft and scrollDisplayRight


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support