0

Horizontal Scrolling On 3.5" TFT using HX8357
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Horizontal Scrolling On 3.5" TFT using HX8357

by RedDragon76 on Sat Dec 02, 2017 10:36 pm

Hello!

I am attempting a horizontal auto scroll on the 3.5" TFT.

The issue I am having is that I can move text across the screen by starting at the 480 pixel point and then decrementing it. Once I hit 0 though, I cannot scroll the message any further. Is there a way to get the message to then scroll off of the screen?

Example Code:
Code: Select all | TOGGLE FULL SIZE
void lcd_victory(){
  tft.fillScreen(HX8357_BLACK);
  tft.setCursor(0,0);
  String welcome_text = "GREAT JOB! ";
  String welcome_text2 = " YOU DID IT! ";
  const int width = 12;
  int set_across = 480;
  tft.setRotation(3);
  tft.fillScreen(HX8357_BLACK);
  tft.setTextColor(HX8357_CYAN, HX8357_BLACK);
  tft.setTextWrap(false);
 
  for (int offset = 0; offset < set_across; offset++){
    set_across = set_across - offset;
    tft.setTextSize(8);
    tft.setCursor(set_across,80);
    tft.println(welcome_text);
    tft.setTextSize(6);
    tft.setCursor(set_across,160);
    tft.println(welcome_text2);
    delay(250);
  }
Last edited by adafruit_support_carter on Wed Sep 12, 2018 1:57 pm, edited 1 time in total.
Reason: added [code] tags

RedDragon76
 
Posts: 1
Joined: Sat Dec 02, 2017 10:21 pm

Re: Horizontal Scrolling On 3.5" TFT using HX8357

by ProtoPix on Wed Sep 12, 2018 7:11 am

I don't know if you ever found a solution to your scrolling issue but the following code works:
Code: Select all | TOGGLE FULL SIZE
void lcd_victory2()
{
    tft.fillScreen(HX8357_BLACK);
    tft.setCursor(0,0);
    String welcome_text = "GREAT JOB! ";
    String welcome_text2 = " YOU DID IT! ";
    const int width = 12;
    int set_across = 480;
    tft.setRotation(3);
    tft.fillScreen(HX8357_BLACK);
    tft.setTextColor(HX8357_CYAN, HX8357_BLACK);
    tft.setTextWrap(false);

    int xCursor = 0;
    for (int offset = 0; offset < 2*set_across; offset+=16)
    {
        xCursor = set_across - offset;
        tft.setTextSize(8);
        tft.setCursor(xCursor,80);
        tft.println(welcome_text);
        tft.setTextSize(6);
        tft.setCursor(xCursor,160);
        tft.println(welcome_text2);
        delay(250);
    }
}
Last edited by adafruit_support_carter on Wed Sep 12, 2018 1:58 pm, edited 1 time in total.
Reason: added [code] tags

ProtoPix
 
Posts: 42
Joined: Sun Sep 11, 2016 6:49 pm

Re: Horizontal Scrolling On 3.5" TFT using HX8357

by adafruit_support_carter on Wed Sep 12, 2018 2:00 pm

You can use negative values in setCursor to make it start off screen. I think that's the missing piece you need to get this to work.

adafruit_support_carter
 
Posts: 7669
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.