 #endif
 
 void setup()   {
+  bool mile = true;
   Serial.begin(9600);
 
   // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)

WiFiClient client1;
  const int httpPort = 80;

  while (true)
  {  
  if (!client1.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  // We now create a URI for the request
  String url = "/data.php?key=speed";
  Serial.print("Requesting URL: ");
  Serial.println(url);
  
  // This will send the request to the server
  client1.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");
  delay(500);
  
  String thing = "";

    thing = thing + line;
    Serial.print(line);
  }
  if (thing == "")
  {
  if (!client1.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  }
  else
  {
  int thespeed = thing.substring(thing.indexOf("<s>") + 3, thing.lastIndexOf("</s>")).toInt();
  int thespeedlimit = thing.substring(thing.indexOf("<l>") + 3, thing.lastIndexOf("</l>")).toInt();
  String engineState = thing.substring(thing.indexOf("<e>") + 3, thing.lastIndexOf("</e>"));
  bool IsOverLimit = (thespeed > thespeedlimit);
  
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Speed:");
  if (engineState=="0")
  {
  display.print("Engine off");
  }
  else
  {
  display.setTextSize(2);
  if (IsOverLimit)
  {
  display.setTextColor(BLACK, WHITE);
  }
  display.print(thespeed);
  display.setTextSize(1);
  if (mile)
  {
  display.print("mph");
  }
  else
  {
  display.print("km/h");
  }
  if (IsOverLimit)
  {
  display.setTextColor(WHITE, BLACK);
  }
  }
  display.setTextSize(2);
  display.println("");
  display.setTextSize(1);
  display.println("Limit: ");
  display.setTextSize(2);
  display.print(thespeedlimit);
  display.setTextSize(1);
  if (mile)
  {
  display.print("mph");
  }
  else
  {
  display.print("km/h");
  }
  display.display();
  //delay(250);
  }
  }
}

