Screen Saver effect with 2.8" TFT Shield Arduino

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
KippyG
 
Posts: 9
Joined: Mon Nov 04, 2013 10:03 am

Screen Saver effect with 2.8" TFT Shield Arduino

Post by KippyG »

Hi all,

I'm looking for some guidance.

I've been able to easily cycle trough bmps with Adafruit's TFT Shield for the Arduino, and easily draw geomtric shapes.

I'd like to cycle through bmps but if the screen is pressed, instantly shift to another bmp (like a menu screen).

Right now, I'm cycling through 5 bmps after each bmp is display I delay for about 2 seconds. The only time I detect a screen press is after that 2 second delay. I'd like to have some kind of interrupt that ignores the delay and instantly goes to the menu.

Any guidance is appreciated.

Thanks,

User avatar
John_Rickey
 
Posts: 2
Joined: Tue May 21, 2013 2:45 pm

Re: Screen Saver effect with 2.8" TFT Shield Arduino

Post by John_Rickey »

Are you using a delay(2000) statement to create the 2 second delay? If so, try replacing that with something like:

Code: Select all

unsigned long timeUpdated

void UpdateScreen() {
  ...  // get and draw the bitmap
  timeUpdated = millis()   // on the line following the screen update
}

loop() {
  ....
  if (millis() - timeUpdated) >= 2000) UpdateScreen();
  ...
}
That should continue cycling through the loop, enabling you to poll the touchscreen on every loop.

KippyG
 
Posts: 9
Joined: Mon Nov 04, 2013 10:03 am

Re: Screen Saver effect with 2.8" TFT Shield Arduino

Post by KippyG »

John,

Thanks for the guidance, since I was using

Code: Select all

delay (2000);
I implemented a solution close to your recommendation.

The

Code: Select all

timeUpdated
vairable updates every time the

Code: Select all

UpdateScreen
is called so I was not getting past the first image.

I ended up setting timeUpdate at the exit of the setup function for each if structure of the images I used something similar to:

Code: Select all

if ((millis() - timeUpdated) >= 2000 && (millis() - timeUpdated) <= 4000){
      bmpDraw("image1.bmp", 0, 0);
    }
I would change the 2000 and 4000 for each image to an appropriate time.

At the end of cycling through the 5 images I would change

Code: Select all

timeUpdated
to the current

Code: Select all

millis()
Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”