Go Down

Topic: BigCrystal LCD Scrolling? (Read 2144 times) previous topic - next topic

dizzwold

#30
Nov 10, 2017, 08:18 pm Last Edit: Nov 10, 2017, 08:27 pm by dizzwold
Hi UKHeliBob,
Quote
which column does that print in ?
Point taken, I'll have a play with it in a few moments.

 Sorry for the delay in trying your sketch, but I'd been watching the F1, then some computer issues.

 Your sketch above in post #24, works straight-out-the-box, with display size settings changed with normal sized text. I'll also see if I can get it working with the bigCrystal library.

 Here's the sketch for other for the 20,4 display;
Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
char * message = "Dizzy's Warm Section";

void setup()
{
  lcd.begin(20, 4);
}

void scrollOn()
{
  byte messageLength = strlen(message);
  for (int printStart = 19; printStart >= 0; printStart--)
  {
    byte currentLetter = 0;
    lcd.setCursor(printStart, 0);
    while ( (currentLetter < messageLength) && (currentLetter + printStart < 20) )  //don't stray beyond the message or LCD width
    {
      lcd.print(message[currentLetter]);
      currentLetter++;
    }
    if (printStart < 20 - messageLength)
    {
      lcd.print(" ");
    }
    delay(500);
  }
}

void scrollOff()
{
  byte messageLength = strlen(message);
  for (int startLetter = 1; startLetter <= messageLength; startLetter++)  //no need to display first character again
  {
    lcd.setCursor(0, 0);
    for (int currentLetter = startLetter; currentLetter < messageLength; currentLetter++)
    {
      lcd.print(message[currentLetter]);
    }
    lcd.print(" ");
    delay(500);
  }
  lcd.setCursor(0, 0);
  lcd.print(" ");
}

void loop()
{
  scrollOn();
  scrollOff();
}



 Thank you for the sketch, I'm now spoilt for choice.

 Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

dizzwold

Sorry for those that just read the above, I copied the wrong sketch. Now corrected.

Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

dizzwold

#32
Nov 10, 2017, 09:05 pm Last Edit: Nov 11, 2017, 07:52 pm by dizzwold
Going back to the sketch in post #25 I've changed the;
Code: [Select]
bigCrystal.printBig(" ",message,1);

 To;
Code: [Select]
bigCrystal.printBig(" ",printStart,1);

 And to;
Code: [Select]
bigCrystal.printBig(" ",19,1);

 Both show less rubbish on screen, but still unreadable.

 My novice thinking would say that the following should have been correct;
Code: [Select]
bigCrystal.printBig(" ",printStart,1);

 I'm either incorrect or this is not possible with the bigCrysatl library?



 Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

dizzwold

Here is the latest sketch, but still not correct.
Code: [Select]
#include <BigCrystal.h>
#include <LiquidCrystal.h>

// Set up according to your LCD pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
BigCrystal bigCrystal(&lcd);
char * message = "Dizzy's Warm Section";

void setup()
{
  bigCrystal.begin(20, 4);
}
void loop()
{
  for (int printStart = 19; printStart >= 0; printStart--)  //scroll on from right
  {
    showLetters(printStart, 0);
  }

  for (int letter = 1; letter <= strlen(message); letter++)  //scroll off to left
  {
    showLetters(0, letter);
  }
}

void showLetters(int printStart, int startLetter)
{
  bigCrystal.setCursor(printStart, 1);
  for (int currentLetter = startLetter; currentLetter < strlen(message); currentLetter++)
  {
    bigCrystal.printBig(message[currentLetter],printStart,1);
  }
  bigCrystal.printBig(" ",printStart,1);
  lcd.setCursor(0, 3);
  lcd.print("                    ");
  delay(250);
}


 Is the following line correct;
Code: [Select]
bigCrystal.printBig(" ",printStart,1);

 Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

UKHeliBob

The whole of the showLetters() function has problems when used with the bigCrystal library because it incorporates the column and row numbers in the printBig() function unlike the normal LCD print() function.

When used with the normal library you can set the LCD cursor, print a letter and when you print the next one it will be alongside the first one because the cursor position is automatically updated unlike the printBig() function, or so it seems.

So you need to think where the cursor needs to be positioned before each character is printed.  In general you need to print in column (printStart + currentLetter) but that will not work for both scrolling on and scrolling off so you need 2 different functions to print the right range of letter in the right place.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

dizzwold

Hi UKHeliBob,

 So I need a function to reposition the cursor, as the normal lcd library uses 1 segment for 1 character, but the bigCrystal library uses 3 segments for 1 character?

 Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

UKHeliBob

No need for a function to position the cursor as that is part of the printBig() function.

Take a piece of paper and on the first line write down the index number of the first character to output when scrolling on and the column number it should go in.  These form 2 of the parameters for the printBig() function.  The actual character needs to be referred to by its index in the character array.  The third parameter is the row number, which is fixed.

Do the same on line 2 for the second character/column, then the third character/column and so on

You will see a pattern emerge showing that you can derive the character index from the column number or vice versa.  Use a for loop to produce one of the numbers and simple maths to calculate the second.  This is how the current program works if you look.

Now you can use the character to be printed, column number and row number in the printBig() function inside the for loop to put the correct character in the correct column.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up