Go Down

Topic: TFT display line wrap scrolling problem (Read 51 times) previous topic - next topic

SeaWalker

Hello,
I am trying to create a twitter reading screen using a 3" TFT display (red ones), however I find it difficult to implement line wrap scrolling. New text is printed on the same lines of the wrapped text.
Stream is the string containing a single tweet, being a livestream text should flow continuously.
Thank you

Code: [Select]

    int16_t ht = 16, top = 1, line, lines = 15, scroll;
...
    if (++scroll >= lines)
    {
      scroll = 0;
      tft.fillScreen(BLACK);
    }
    tft.setCursor(10, (scroll + top) * ht);
    tft.vertScroll(top * ht, lines * ht, (scroll) * ht);
    if(stream.length()>18)
    {
      for(int i = 0; i < stream.length(); i+=18)
      {
        tft.println(stream.substring(i,i+18));
        line++;
      }
    }
    else
    {
      tft.println(stream);
      line++;
    }

david_prentice

#1
Jul 14, 2018, 01:35 pm Last Edit: Jul 14, 2018, 02:10 pm by david_prentice
Wrap is  on by default with any GFX style library.  A long string will wrap to the next line.

Note that vertical scroll does not alter the position in GRAM.  It will update its idea of where cursorX and cursorY has moved e.g. newline.
It only affects the way  that a "band" is displayed.

Please post a minimal example that shows your problem.   From memory you can read the cursor position.

David.

Edit.  Sure enough.   Adafruit_GFX.h has:
Code: [Select]
  // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y)
  int16_t getCursorX(void) const;
  int16_t getCursorY(void) const;

If you want the Band to appear to scroll indefinitely,  you must constrain the cursor position to lie within the Band e.g. with setCursor().

I suggest that you draw a "screen" on a piece of paper.    Then cut out another piece of paper that can represent the band.    This will help you to understand how the screen is displayed.

Go Up