Display large text files on LCD?

Hello there Arduino masters,

I am doing a project where I want to display large amounts of text on an LCD screen. Is there a simple way to do this? I notice that the LiquidCrystal library has scroll left/right functions, but is there a way to scroll up and down?

My current thought process is that I might get a large string (a text file, let's say) as input. I would print it out character by character adding a line break after each 20th character (my LCD is 20x4). But if there's no way to scroll up/down, this probably wouldn't work.

My overall vision is to design an internet connected computing platform that can grab wiki articles, save them to an SD card, and view them later. Let me know what you think of the feasibility.

Thanks guys.

The 20*4 display might be too small to do serious readings on but you can certainly try. I do similar thing except I store long messages in arduino's main ram or FLASH. With basic stuff, you just need to do what you said, cut off every 20 characters and move a pointer every time up/down is pressed.

liudr: The 20*4 display might be too small to do serious readings on but you can certainly try. I do similar thing except I store long messages in arduino's main ram or FLASH. With basic stuff, you just need to do what you said, cut off every 20 characters and move a pointer every time up/down is pressed.

Thanks for the input; I've got something along those lines working. There doesn't seem to be much in the way of bigger character LCDs and I'm not sure how well Arduino supports graphical LCDs though.

KS0108 dot matrix displays are popular choices. You could display about twice the text an 20X4 display can do. I consider these smaller displays perfect for information or simple interaction instead of for reading articles. Maybe a smartphone is a better platform for your application. BTW, have you got returns (\n) to display in your code yet?

You should be able to use something like liudr's code to read from an SD card rather than from the ram - you probably want to get rid of the scroll bar and simply process text until the file ends.

Should be easy enough to store 80 characters in 4 strings, shift each string up and create another of the next 20 characters then keep doing this until EOF.

mowcius: You should be able to use something like liudr's code to read from an SD card rather than from the ram - you probably want to get rid of the scroll bar and simply process text until the file ends.

Should be easy enough to store 80 characters in 4 strings, shift each string up and create another of the next 20 characters then keep doing this until EOF.

That's my plan. I've got something about like the second part working now. Thanks for the input.

liudr: KS0108 dot matrix displays are popular choices. You could display about twice the text an 20X4 display can do. I consider these smaller displays perfect for information or simple interaction instead of for reading articles. Maybe a smartphone is a better platform for your application. BTW, have you got returns (\n) to display in your code yet?

Right, this is just a prototype of something I would like to someday implement on a smartphone-type platform. Good call. I haven't yet played around with returns yet. Any advice on that?

The character mode LCDs were never meant to display large amounts of text, they were really designed for short terse messages like 'page jam', 'add toner', etc. You can get around this limitation with clever programming but you might better spend your time doing that programming with a graphical LCD.

Don

AegisXLII:
I haven’t yet played around with returns yet. Any advice on that?

I wrote two subroutines to specifically go to previous line or next line by counting regular characters and process returns.

Hope this helps. Just read the spirit of it, not the exact lines. The new phi_prompt library with this feature has not been released yet.

void prev_line(phi_prompt_struct* para) // Seeks previous line in a long message stored in SRAM.
{
  byte columns=para->step.c_arr[1];
  if (para->low.i<=0)
  {
    para->low.i=0;
    return;
  }
  if (para->ptr.msg[para->low.i-1]=='\n')
  { //Seek beginning of a paragraph.
    int dec=para->low.i-2;
    while(para->ptr.msg[dec]!='\n')
    {
      dec--;
      if (dec==0)
      {
        para->low.i=0;
        return;
      }
    }
    para->low.i-=((para->low.i-1-dec-1)%columns+1);
  }

  else para->low.i-=columns;
  return;
}

void next_line(phi_prompt_struct* para) // Seeks next line in a long message stored in SRAM.
{
  byte columns=para->step.c_arr[1];
  for (int i=para->low.i;i<para->low.i+columns;i++)
  {
    if (para->ptr.msg[i]=='\n')
    {
      para->low.i=i+1;
      return;
    }

    if (i==strlen(para->ptr.msg))
    {
      return;
    }
  }
  para->low.i+=columns;
}

The code does preassume you are not dynamically changing the content of the message.