   //degreesC = (voltage - 0.5) * 100.0;
   //degreesF = degreesC * (9.0/5.0) + 32.0;
   // subtract the last reading:
-  total = total - readings[index];
-  // read from the sensor:
-  readings[index] = temp;
-  // add the reading to the total:
-  total = total + readings[index];
-  // advance to the next position in the array:
-  index = index + 1;
-  // if we're at the end of the array...
-  if (index >= numReadings)
-    // ...wrap around to the beginning:
-    index = 0;
-  // calculate the average:
+  total = total - readings[index];              // read from the sensor:
+  readings[index] = temp;                       // add the reading to the total:
+  total = total + readings[index];              // advance to the next position in the array:
+  index = index + 1;                            // if we're at the end of the array...
+  if (index >= numReadings)                     // ...wrap around to the beginning:
+    index = 0;                                  // calculate the average:
   average = total / numReadings;
 
 fuelGage();

void setup()
{
  dayLightVal = analogRead(A10);
  //Serial.println(dayLightVal);
  //backlightPerc = (0.0000003*(dayLightVal*dayLightVal*dayLightVal))-(0.0006*(dayLightVal*dayLightVal))+(0.397*dayLightVal);
  //Serial.println(backlightPerc);
  backlightValue = 0.2138*dayLightVal + 20.5;
  //Serial.println(backlightValue);
  //backlightValue = ((backlightPercent*backlightPercent*backlightPercent)/3937) + 1.5;
  //backlightValue = (127 * backlightPercent) / 50 + 1;
  analogWrite(backlightPin, backlightValue);
  //Serial.println(backlightValue);

  Tft.TFTinit();                                        // init TFT library

  pinMode(24, OUTPUT);					// needed to set digital pin to high at 5v for switching MOSFET
  pinMode(26, OUTPUT);					// needed to set digital pin to high at 5v for switching MOSFET

  Serial.begin(9600);

  //Tft.fillRectangle(0, 0, 239, 319, WHITE);

  Tft.drawRectangle(10, 20, 220, 280, GREEN); 	    // (X-coord start, Y-coord start, X length, y length, color)
  Tft.drawString("OIL", 73, 38, 5, GREEN);
  Tft.drawString("OIL", 75, 40, 5, BLUE);
  delay(500);

int tempSetPointAddress = 2;
int brightnessAddress = 3;

int fuelLevel;                            // value from 0 to 100 equating to the fuel level
float fuelLevelVal;                       // analog value from 728 to 254, read from the fuel level voltage divider;
int xLength;                              // length of bar in fuel level bar graph
int oldxLength;
int fuelLevelPin = A15;                   // pin that is reading the voltage of the voltage divider for the fuel sender

int readingP[numReadings];                // the readings from the analog input
int indexP = 0;                           // the index of the current reading
int sumP = 0;                             // the running total
int psi = 0;
int pressure = 0;                         // current fuel pressure
int oldpressure = 0;                      // old fuel pressure
int pressurePin = A14;                    // analog pressure pin
double pressureVoltage;

TouchScreen ts = TouchScreen(XP, YP, XM, YM);	        // values for coordinate system inputs on touchscreen.
