   }
 }
 
+//ScreenDisplays
+void loginDisplay(){
+
+  switch(screen_drawn) {
+  case 0: // Initialise
+    tft.fillScreen(ILI9341_BLACK);
+    tft.setTextSize(2);
+    tft.setCursor(126,113); // centred text
+    tft.println("bleepr");
+
+    screen_drawn = 1;
+    animation_time = millis();
+    break;
+  case 1: //Animate Red circle
+    if(millis() - animation_time >= 0) {
+      //colorWipe(strip.Color(255, 0, 0), 1);
+      tft.drawCircle(160,120,60,ILI9341_RED);  
+      screen_drawn = 2;
+    }  
+    break;
+
+  case 2: //Animate black circle clear
+    if(millis() - animation_time >= 200){
+      tft.drawCircle(160,120,60,ILI9341_BLACK);
+      screen_drawn = 3;
+    }  
+    break;
+
+  case 3: //Animate yellow circle
+    if(millis() - animation_time >= 240){
+      //  colorWipe(strip.Color(255, 255, 0), 1);
+      tft.drawCircle(160,120,80,ILI9341_YELLOW); 
+      screen_drawn = 4;
+    }  
+    break;
+
+  case 4: //Animate black circle clear
+    if(millis() - animation_time >= 440){
+      tft.drawCircle(160,120,80,ILI9341_BLACK); 
+      screen_drawn = 5;
+    }  
+    break;
+
+  case 5: //Animate green circle
+    if(millis() - animation_time >= 480){
+      // colorWipe(strip.Color(0, 255, 0), 1);
+      tft.drawCircle(160,120,100,ILI9341_GREEN); 
+      screen_drawn = 6;
+    }  
+    break;
+  case 6: //Animate (Currently janky and NEEDS to be fixed)
+    if(millis() - animation_time >= 680){
+      tft.drawCircle(160,120,100,ILI9341_BLACK); 
+      screen_drawn = 7;
+    }  
+    break;
+
+  case 7: //Resets
+    if(millis() - animation_time >= 740){
+      animation_time = millis();
+      screen_drawn = 1;
+    }
+    break;
+
+
+
+  case 8: //Please wait
+    tft.setCursor(126,200); // centred text
+    tft.println("Please wait");
+    screen_drawn = 1;
+    break;
+  }
+}
+
+void homeDisplay(){
+  switch(screen_drawn) {
+  case 0: //Setup
+
+    //LEDs blue
+    colorWipe(strip.Color(0, 0, 255), 10);
+
+
+    tft.fillRect(0,0,160,120,ILI9341_LIGHTGREY);
+    tft.fillRect(160,0,160,120,ILI9341_DARKGREY);
+    tft.fillRect(0,120,160,120,ILI9341_DARKGREY);
+    tft.fillRect(160,120,160,120,ILI9341_LIGHTGREY);
+    tft.setTextSize(2);
+    tft.setCursor(5,60);
+    tft.println("Call waiter");
+    tft.setCursor(165,60);
+    tft.println("Ask for bill");
+    tft.setCursor(5,180);
+    tft.println("Food status");
+    tft.setCursor(165,180);
+    tft.println("Leave table");
+
+    screen_drawn = 1;
+    break;
+
+  case 1: //Loop
+    break;
+
+  default:
+    break;
+
+  }
+}
+
+
+void billDisplay(){
+  switch(screen_drawn) {
+  case 0: //Setup
+
+    //LEDs yellow
+    colorWipe(strip.Color(255, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_RED);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Calling bill");
+
+    bluetooth.print("request_bill");
+
+    screen_drawn = 1;
+    break;
+
+  case 1: //Loop
+    if(available_bt) {
+      if( read_bt() == "ok") {
+        screen_drawn = 2;
+      }
+    }
+    break;
+
+  case 2: //Exit state
+    colorWipe(strip.Color(0, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_GREEN);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Bill on way");
+
+    delay(2000);
+    screen_drawn = 0;
+    display_state = 1; //Main menu
+    break;
+
+  default:
+    break;
+
+  }
+}
+
+void waiterDisplay(){
+  switch(screen_drawn) {
+  case 0: //Setup
+
+    //LEDs yellow
+    colorWipe(strip.Color(255, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_RED);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Calling bill");
+
+    bluetooth.print("request_bill");
+
+    screen_drawn = 1;
+    break;
+
+  case 1: //Loop
+    if(available_bt) {
+      if( read_bt() == "ok") {
+        screen_drawn = 2;
+      }
+    }
+    break;
+
+  case 2: //Exit state
+    colorWipe(strip.Color(0, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_GREEN);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Bill on way");
+
+    delay(2000);
+    screen_drawn = 0;
+    display_state = 1; //Main menu
+    break;
+
+  default:
+    break;
+
+  }
+}
+
+void leaveDisplay(){
+  switch(screen_drawn) {
+  case 0: //Setup
+
+    //LEDs yellow
+    colorWipe(strip.Color(255, 255, 0), 10);
+
+    tft.fillRect(160,120,160,120,ILI9341_RED);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Hang on!");
+
+    bluetooth.print("leave_table");
+
+    screen_drawn = 1;
+    break;
+
+  case 1: //Loop
+    if(available_bt) {
+      if( read_bt() == "ok") {
+        screen_drawn = 2;
+      }
+    }
+    break;
+
+  case 2: //Exit state
+    colorWipe(strip.Color(0, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_GREEN);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Bill on way");
+
+    delay(2000);
+    screen_drawn = 0;
+    display_state = 1; //Main menu
+    break;
+
+  default:
+    break;
+
+  }
+}
+
+void foodDisplay(){
+  switch(screen_drawn) {
+  case 0: //Setup
+
+    //LEDs yellow
+    colorWipe(strip.Color(255, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_RED);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Calling bill");
+
+    bluetooth.print("request_bill");
+
+    screen_drawn = 1;
+    break;
+
+  case 1: //Loop
+    if(available_bt) {
+      if( read_bt() == "ok") {
+        screen_drawn = 2;
+      }
+    }
+    break;
+
+  case 2: //Exit state
+    colorWipe(strip.Color(0, 255, 0), 10);
+
+    tft.fillRect(160,0,160,120,ILI9341_GREEN);
+
+    tft.setTextSize(2);
+    tft.setCursor(165,60);
+    tft.println("Bill on way");
+
+    delay(2000);
+    screen_drawn = 0;
+    display_state = 1; //Main menu
+    break;
+
+  default:
+    break;
+
+  }
+
+}
+
+
+


void setup(){

    Serial.begin(9600);               // starts serial monitor at 9600bps
    SPI.begin();                      // starts SPI
    rfid.init();                      // initialises RFID library
    bluetooth.begin(115200);          // starts bluetooth at 115200
    delay(100);                       // wait for bluetooth module to sed back command
    bluetooth.println("U,9600,N");    // temporarily change the bps to 9600, no parity
    bluetooth.begin(9600);            // starts bluetooth at 9600bps
    tft.begin();                      // starts TFT screen
    tft.setRotation(3);               // sets screen orientation to landscape with pins on left
    tft.setTextSize(2);
    loginDisplay();
    
    //LED strip initialise
    strip.begin();
    strip.show();
    
    colorWipe(strip.Color(0, 0, 100), 10); //Blue init
    

    pinMode(speaker, OUTPUT);
    tone(speaker,1000);
    delay(100);
    noTone(speaker);

}

void loop(){

    //Display switch
    switch(display_state) {
      case 0:
      
      loginDisplay();
      
      
        if(scanned_card) {
          if(available_bt) {
            
            //screen_drawn = 2; //Icky, will keep printing please wait until card is recieved from server
            //We can fix this later
            
            scanned_card = false;
            if (read_bt() == "access1") { //Card is good
              display_state = 1;
              screen_drawn = 0;
            }
            else {
              tft.println("Sorry, no access");
              delay(1000);
              screen_drawn = 0;
            }
          }
        }
        break;
        
      case 1: //Main Display
          homeDisplay();
          
          //If buttons pressed move to corresponding screen
        break;
        
      default:
        break;
    }
              

    // Read bluetooth text and print it to screen
    
    if(bluetooth.available())  // If the bluetooth sent any characters
    {
      char char_in = (char)bluetooth.read();
      if(char_in != '\0'){ // Before end char
        
        bt_buffer = bt_buffer + char_in;
      } else { // Print to screen at end char
        last_bt = bt_buffer;
        available_bt = true;
        bt_buffer = "";
      }
      
    }
    

    // Read buttons and send to bluetooth
//    if(digitalRead(BTN0)==HIGH){
//      bluetooth.print("BTN0");
//    } else if(digitalRead(BTN1)==HIGH) {//      bluetooth.print("BTN1");
//    } else if(digitalRead(BTN2)==HIGH) {
//      bluetooth.print("BTN2");
//    } else if(digitalRead(BTN3)==HIGH) {
//      bluetooth.print("BTN3");
//    }

    // RFID reading
    if(rfid.isCard() && !scanned_card){
        if(rfid.readCardSerial()){
            String serNumStr = "";
            for(int i=0; i<5; i++){
              serNumStr = serNumStr + String(rfid.serNum[i]) + " ";              
            }
            bluetooth.print(serNumStr);
            
            scanned_card = true;
            
            screen_drawn = 2;
            
            tone(speaker, 800);
            delay(120);
            tone(speaker, 1000);
            delay(40);
            noTone(speaker);
                      
        }

//       if(access){
//          tft.setCursor(0, 75);
//          tft.setTextColor(ILI9341_WHITE);
//          tft.setTextSize(4);
//          Serial.println("Welcome TEST!");
//          tft.println("Hey TEST!");
//          colorWipe(strip.Color(0, 100, 0), 10);
//          access = false;
//          homeDisplay();
//        } else {
//           Serial.println("Not allowed!");
//           tft.println("ACCESS DENIED.");
//           colorWipe(strip.Color(255, 0, 0), 10);
//           tone(speaker, 400);
//           delay(150);
//           noTone(speaker);
//           delay(100);
//           tone(speaker, 400);
//           delay(150);
//           noTone(speaker);
//           delay(100);
//           tone(speaker, 400);
//           delay(150);
//           noTone(speaker);
//           delay(100);
//           colorWipe(strip.Color(0, 0, 100), 10);
//           loginDisplay();
//       }        
    }
    
    
    
    rfid.halt();

}

void loginDisplay(){
 
  switch(screen_drawn) {
    case 0: // Initialise
      tft.fillScreen(ILI9341_BLACK);
      tft.setTextSize(2);
      tft.setCursor(126,113); // centred text
      tft.println("bleepr");
      tft.drawCircle(160,120,60,ILI9341_RED); 
      
      screen_drawn = 1;
      animation_time = millis();
      break;
     case 1: //Animate (Currently janky and NEEDS to be fixed)
//      if(millis() - animation_time >= 20) {
//        tft.drawCircle(160,120,60,ILI9341_RED);  
//      }  
//      if(millis() - animation_time >= 200){
//        tft.drawCircle(160,120,60,ILI9341_BLACK);
//      }
//      if(millis() - animation_time >= 240){
//        tft.drawCircle(160,120,80,ILI9341_YELLOW);
//      }
//      if(millis() - animation_time >= 440){
//        tft.drawCircle(160,120,80,ILI9341_BLACK);
//      }
//      if(millis() - animation_time >= 460){
//        tft.drawCircle(160,120,100,ILI9341_GREEN);
//      }
//      if(millis() - animation_time >= 660){
//        tft.drawCircle(160,120,100,ILI9341_GREEN);
//      }
//      if(millis() - animation_time >= 700){
//        tft.drawCircle(160,120,100,ILI9341_BLACK);
//      }
//      if(millis() - animation_time >= 740){
//        animation_time = millis();
//      }
       
       break;
     case 2: //Please wait
       tft.setCursor(126,200); // centred text
       tft.println("Please wait");
       screen_drawn = 1;
  }
}


//Needs to be converted for new steup
void homeDisplay(){
  switch(screen_drawn) {
    case 0: //Setup
      tft.fillRect(0,0,160,120,ILI9341_LIGHTGREY);
      tft.fillRect(160,0,160,120,ILI9341_DARKGREY);
      tft.fillRect(0,120,160,120,ILI9341_DARKGREY);
      tft.fillRect(160,120,160,120,ILI9341_LIGHTGREY);
      tft.setTextSize(2);
      tft.setCursor(5,60);
      tft.println("Call waiter");
      tft.setCursor(165,60);
      tft.println("Ask for bill");
      tft.setCursor(5,180);
      tft.println("Food status");
      tft.setCursor(165,180);
      tft.println("Leave table");
      
      screen_drawn = 1;
      break;
      
     case 1: //Loop
       break;
     
     default:
       break;
     
  }
  
  
  
}

//BT Functions
String read_bt() {
 if(available_bt) {
   available_bt = false;
   return last_bt;
 } else {
   return "";
 }
}




int serNum[5];
int test[][5] = {
  {
    131,222,128,0,221      }
};

bool access = false;
