How to reset part of a 2.8 TFT shield uno

Hi,

Is it possible to reset a part of this screen?TFT Shield specs

I have made it work but the time and date become after a while white bloks.
This is because the screen does not refresh and the pixels get white voor number 1 and then the pixels for number 3 get also white .. and so on. Is there a solution for this?

This is my code:

   //////////////////////////////////////////////
  //        2.8" TOUCH SCREEN DEMO            //
 //                                          //
//           http://www.educ8s.tv           //
/////////////////////////////////////////////

#include <Adafruit_TFTLCD.h> 
#include <Adafruit_GFX.h>    
#include <TouchScreen.h>
#include "pitches.h"
#include <Wire.h> //include Wire.h library
#include "RTClib.h" //include Adafruit RTC library


#define LCD_CS A3 
#define LCD_CD A2 
#define LCD_WR A1 
#define LCD_RD A0 
#define LCD_RESET A4 

#define TS_MINX 117
#define TS_MINY 109
#define TS_MAXX 945
#define TS_MAXY 915

#define YP A2  // must be an analog pin, use "An" notation!
#define XM A3  // must be an analog pin, use "An" notation!
#define YM 8   // can be a digital pin
#define XP 9   // can be a digital pin

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

boolean buttonEnabled = true;

RTC_DS3231 rtc; //Make a RTC DS3231 object
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup() {
  Serial.begin(115200);
  //Serial.print("Starting...");
  
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  
    if (rtc.lostPower()) {
    //Sets the code compilation time to RTC DS3231
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  
  
  tft.reset();
  tft.begin(0x9341);
  tft.setRotation(3);
  
  tft.fillScreen(BLACK);

  //Draw white frame
  tft.drawRect(0,0,319,240,WHITE);
  
  //Print "Welkom" Text
  tft.setCursor(45,50);
  tft.setTextColor(WHITE);
  tft.setTextSize(4);
  tft.print("Welkom bij");
  
  tft.setCursor(45,100);
  tft.setTextColor(CYAN);
  tft.setTextSize(4);
  tft.print("STYLEMATHOT");
  
  //Create Red Button
  tft.fillRect(40,180,240,50, GREEN);
  tft.drawRect(40,180,240,50,WHITE);
  tft.setCursor(135,188);
  tft.setTextColor(WHITE);
  tft.setTextSize(4);
  tft.print("BEL");

}

void loop() 
{
  DateTime now = rtc.now();
  tft.setCursor(5,15);
  tft.setTextColor(WHITE);
   tft.setTextSize(2);
   
  //Print RTC time
  tft.print(now.year(), DEC);
  tft.print('/');
  tft.print(now.month(), DEC);
  tft.print('/');
  tft.print(now.day(), DEC);
  tft.print(" (");
  tft.print(daysOfTheWeek[now.dayOfTheWeek()]);
  tft.print(") ");
  tft.print(now.hour(), DEC);
  tft.print(':');
  tft.print(now.minute(), DEC);
  tft.print(':');
  tft.println(now.second(), DEC);
  
  TSPoint p = ts.getPoint();  //Get touch point
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //if (p.z > ts.pressureThreshhold) {

   //Serial.print("X = "); Serial.print(p.x);
   //Serial.print("\tY = "); Serial.print(p.y);
   //Serial.print("\n");
   
   p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
   p.y = map(p.y, TS_MAXY, TS_MINY, 0, 240);
       
   if(p.x>40 && p.x<240 && p.y>180 && p.y<240 && buttonEnabled)// The user has pressed inside the red rectangle
   {
    buttonEnabled = false; //Disable button
        
    //This is important, because the libraries are sharing pins
   pinMode(XM, OUTPUT);
   pinMode(YP, OUTPUT);
    
    //Erase the screen
    tft.fillScreen(BLACK);
    
    //Draw frame
    tft.drawRect(0,0,319,240,WHITE);
    
    tft.setCursor(15,70);
    tft.setTextColor(WHITE);
    tft.setTextSize(2);
    tft.print("U wordt spoedig geholpen.");
    
    tft.setCursor(25,120);
    tft.setTextColor(WHITE);
    tft.setTextSize(2);
    tft.print("Bedankt voor uw bezoek.");
    
// hier bel laten afgaan draadloos
    delay(3000);
    software_Reset() ;
    
   }

  //}

}
void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile ("  jmp 0");  
}

Code online link

(deleted)

Of course .. Thanx man.

Only issue is now it's flikkering/flashing.. The clock speed is't that fast and i don't know why?
Is this because of the I2C connection with the RTC_DS3231 (real time clock)?

Can i make it go faster?

(deleted)

oh sry for the "man" :-[

I think i understand what you meen but i have no idea where to begin to accomplish that.

What i do know is that i probably have to use millis i.s.o. delay otherwize the "BEL" button cannot be read. :disappointed_relieved: :confused: ??

What do you exactly meen by "previous time in black!"?

sry i'm not that experienced yet

Hi there,

Another issue that i want to adres is the "0" ZERO in front of the time numbers.

At this moment with the code above whens its 5 hours and 5 minutes and 6 sec on the display it reads
5:5:6. If it is possible i would like to make it like: 05:05:06 so with zeros in front.

Is this possible?

Any comment / remark is helpfull

Tnx

P.S. Fixed the flickering by drawing ractangle over the hour and minute and updating it every time a minute is passed. The same with seconds :-)... done this by my own brain. (what i'm not used too) :slight_smile:

just found an awser: [RTC] [Solved] How to add the leading 0(zero) to the RTC datas - Programming Questions - Arduino Forum