 
 /*
 * Read a card using a mfrc522 reader on your SPI interface
-* Pin layout should be as follows (on Arduino Uno):
-* MOSI: Pin 11 / ICSP-4
-* MISO: Pin 12 / ICSP-1
-* SCK: Pin 13 / ISCP-3
-* SS/SDA: Pin 10
-* RST: Pin 9
-*/
+ * Pin layout should be as follows (on Arduino Uno):
+ * MOSI: Pin 11 / ICSP-4
+ * MISO: Pin 12 / ICSP-1
+ * SCK: Pin 13 / ISCP-3
+ * SS/SDA: Pin 10
+ * RST: Pin 9
+ */
 
 #include <SPI.h>
 #include <RFID.h>

unsigned long animation_time = millis();

//LEDs setup
Adafruit_NeoPixel strip = Adafruit_NeoPixel(30, LEDStrip, NEO_GRB + NEO_KHZ800);


//RFID variables

  }
}

//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;

  }

}



