 double rmsValue = 0.0;
 double peakValue = 0.0;
 
+#define NUMMEASURE 24
+double twoMinuteMeasurements[NUMMEASURE];
+double twoMinuteAverage = 0.0;
+double twoMinuteSum = 0.0;
+unsigned int MeasurementCounter = 0;
+bool enoughMeasurements = false;
+bool calibrated = false;
+
+unsigned int globalState = 0;
+
 unsigned int debounceInterval = 200;
 unsigned int lastJoystick = 0;
 bool triggeredJoystick = false;

    /* display->drawString(0 + x, 10 + y, "Arial 10"); */

    display->setFont(ArialMT_Plain_16);
    display->drawString(0 + x, 17 + y, "Digits: " + String( ads.readADC_SingleEnded(1) ) );
    display->drawString(0 + x, 28 + y, "Volts:  " + String( Volts(ads.readADC_SingleEnded(1)) ) );
    display->drawString(0 + x, 39 + y, "Amps:   " + String( rmsValue ) + " " + String(peakValue) );

    /* display->setFont(ArialMT_Plain_24); */
    /* display->drawString(0 + x, 34 + y, "Arial 24"); */

#define OFFSET 8820
#define SCALE (1.65/OFFSET)
#define VTOA (22.0/1.65)

#define TENTHOUSAND 10000.0
double calibrationOffset = 3.867123;

double Volts(int digits)
{
