Como fazer rectangle fill piscar (blink)? Using TFT Display

Como fazer um retângulo piscar usando TFT com Adafruit, fiz um retângulo:

tft.fillRect(posx,posy, largura, altura, cor);
 tft.drawRect(posx,posy, largura, altura,WHITE);   
tft.setCursor(posx+8,posy+4);

Eu preciso que quando esse botão seja construído ele fique "piscando" para que ele seja meio que uma opção atual selecionada pelo usuário, e a medida que o usuário for apertar um botão outro retângulo comece a piscar, tentei fazê-lo piscar usando o while(1){} mas ele fica piscando o retângulo e não reproduz o restante do código (restante da tela).

I have TFT Display with AdaFruit library, i need to make my fill rectangle stay blinking while user don't press a physical button, in a LCD the function is "lcd.blink()", but, in TFT, i do not know if this exists.

You can make a blink yourself. Here is an example that runs on an ILI9481 3.5 inch TFT Uno shield. Youi can check with Serial Monitor.

// TFTT_blink.ino
//
// 3.5 inch TFT screen ILI 9481 320 x 480 pixels landscape
// 3.5 inch TFT Uno shield
// TFT control via pins A0-A4 and pins D2 thru D9 
// uses  mcufriend_kbv library

// this sketch paints your screen black 
// displays a filled rectangle, color black 
// waits 500 millis
// displays the same filled rectangle, color black
// waits 500 millis
// and on and on and on...... 
// by Floris Wouterlood - have fun

   #include <Adafruit_GFX.h>                                                                              
   #include <MCUFRIEND_kbv.h>                                                  
  
   MCUFRIEND_kbv tft;
  
   #define LCD_CS A3 
   #define LCD_CD A2 
   #define LCD_WR A1 
   #define LCD_RD A0 
   #define LCD_RESET A4 
   #define BLACK 0x0000
   #define BLUE  0x001F
                                            

void setup() {

// TFT controller detection
   uint16_t ID;
   ID = tft.readID ();                                                         
   Serial.begin (9600);
   Serial.println ("starting TFT display");
   Serial.print  ("controller ID = 0x");
   Serial.println (ID,HEX); 
   Serial.println ();
   Serial.println ("drawing black square");

// static elements to be continuously displayed 
   tft.reset ();                                                               
   tft.begin (ID);  
   tft.setRotation (0);                                                        
   tft.fillScreen (BLACK);                                          
}

void loop() {

    tft.fillRect (50,50,100,100,BLACK);    
    delay(500); 
    Serial.println ("drawing blue square");   
 
    tft.fillRect (50,50,100,100,BLUE);
    delay(500);           
    Serial.println ("drawing black square"); 
}

Topics merged

photoncatcher:
You can make a blink yourself. Here is an example that runs on an ILI9481 3.5 inch TFT Uno shield. Youi can check with Serial Monitor.

// TFTT_blink.ino

//
// 3.5 inch TFT screen ILI 9481 320 x 480 pixels landscape
// 3.5 inch TFT Uno shield
// TFT control via pins A0-A4 and pins D2 thru D9
// uses  mcufriend_kbv library

// this sketch paints your screen black
// displays a filled rectangle, color black
// waits 500 millis
// displays the same filled rectangle, color black
// waits 500 millis
// and on and on and on......
// by Floris Wouterlood - have fun

#include <Adafruit_GFX.h>                                                                             
  #include <MCUFRIEND_kbv.h>                                                 
 
  MCUFRIEND_kbv tft;
 
  #define LCD_CS A3
  #define LCD_CD A2
  #define LCD_WR A1
  #define LCD_RD A0
  #define LCD_RESET A4
  #define BLACK 0x0000
  #define BLUE  0x001F

void setup() {

// TFT controller detection
  uint16_t ID;
  ID = tft.readID ();                                                       
  Serial.begin (9600);
  Serial.println ("starting TFT display");
  Serial.print  ("controller ID = 0x");
  Serial.println (ID,HEX);
  Serial.println ();
  Serial.println ("drawing black square");

// static elements to be continuously displayed
  tft.reset ();                                                             
  tft.begin (ID); 
  tft.setRotation (0);                                                       
  tft.fillScreen (BLACK);                                         
}

void loop() {

tft.fillRect (50,50,100,100,BLACK);   
    delay(500);
    Serial.println ("drawing blue square");

tft.fillRect (50,50,100,100,BLUE);
    delay(500);         
    Serial.println ("drawing black square");
}

This solution is good, but only if we are not going to use physical buttons, otherwise the delay disrupts the buttons, but thanks, it worked

Have you looked at Using millis() for timing. A beginners guide and Several things at the same time ?.

UKHeliBob:
Have you looked at Using millis() for timing. A beginners guide and Several things at the same time ?.

I do not know"Use millis() for timing", thanks for subject, i'll read now to learn.