Pages: [1]   Go Down
Author Topic: flickering button on 3,2" TFT  (Read 416 times)
0 Members and 1 Guest are viewing this topic.
Gr
Offline Offline
Jr. Member
**
Karma: 2
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
I have 3.2" TFT LCD connected to a mega2560 board.

When I load the sketches included in the UTFT lib that all is OK but when I try my own sketch to learn how to control the LCD I have a problem.
The below sketch prints a text on the top of the LCD and them draws a button using the UTFT buttons lib.
The problem is that the button flickers.
Why is it doing this ? Can someone help please ?

Code:
#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t Dingbats1_XL[];

// Set up UTFT...
// Set the pins to the correct ones for your development board
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
UTFT          myGLCD(ITDB32S,38,39,40,41);

// Set up UTouch...
// Set the pins to the correct ones for your development board
// Standard Arduino Mega/Due shield            : 6,5,4,3,2
UTouch        myTouch(6,5,4,3,2);

// Finally we set up UTFT_Buttons :)
UTFT_Buttons  myButtons(&myGLCD, &myTouch);

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
  // myGLCD.setFont(BigFont);

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);

  myButtons.setTextFont(BigFont);
  myButtons.setSymbolFont(Dingbats1_XL);
}

void loop()
{
  int but1;
  boolean default_colors = true;


  but1 = myButtons.addButton(10, 50, 200, 30, "Button1");
  myButtons.drawButtons();

  myGLCD.setFont(BigFont);
  myGLCD.setColor(VGA_RED);
  myGLCD.print("LIGHT CONTROLLER", CENTER, 0);


  //myGLCD.setFont(SmallFont);
  //myGLCD.setColor(VGA_BLUE);
  //myGLCD.print("this is a test", CENTER, 20);

}
« Last Edit: November 06, 2013, 01:39:19 pm by tolisn63 » Logged

Offline Offline
Sr. Member
****
Karma: 12
Posts: 380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Because you're inside a loop();

For now, add a Delay(5000); at the end of your loop and the flickering will stop.

The correct way to fix this is to add code at the end of the loop that does something like this:

    while (1)
        wait for keypress
        handle keypress
   
Logged

Do not IM me. I will not respond. Ask questions in the forum.

Gr
Offline Offline
Jr. Member
**
Karma: 2
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I figured it out.
I knew it was something simple

Thanks for taking the time to help.
Logged

Pages: [1]   Go Up
Jump to: