TFT DIsplay not responsible as it should be.

Hello there, i am wondering if someone have time to look at my code. I am building a project for school called, house alarm. This is my first time wokring with TFT display so do not go hard on me :slight_smile:

Hardware used:

  • Arduino MEGA 2560 R3
  • 2.8" TFT Touch Shield for Arduino ( ILI9341 and STMPE 610 SPI )

What my problem is?

  • Switching between menus are slow.
  • Drawing pages is slow.
  • Blinking twice when switching from menu to menu.
  • Sometimes i can’t get correct readings from tuch screen ( it sends wrong number ).

Alarm.ino (15.4 KB)

 if(((millis()) - oldkeystate) > loppratekeypad)
 oldkeystate = millis();

I can not imagine a relationship between the state of a key and time. That variable is horribly mis-named.

        oldmilis = millis();

The millis() function does NOT return an int.

int okno1 = 0;
int okno2 = 0;
int okno3 = 0;
int okno4 = 0;
int okno5 = 0;
int okno6 = 0;
int okno7 = 0;
int okno8 = 0;
int okno9 = 0;
int okno10 = 0;

for(byte b=0; b<10; b++)
// Have you ever hear of arrays?

    tft.setTextColor(RED,BLACK);  tft.setTextSize(2);

What other choices are there? The screen is locked or else it isn’t.

void menutext(int m)
      case 0:
        tft.setCursor(5,45 );
        tft.setTextColor(ILI9341_WHITE,BLACK);  tft.setTextSize(2);
        tft.println("INFO MENU          ");
        return 1;

1 is NOT nothing. Your function promises to return nothing, NOT an int. Fix ALL the useless return statements, and read about switch/case statements and the break statement.

void drawmenu(int x)
  if(x == oldmenu)
    return 1;

Another incorrect return statement.