 int biasSP02Max = 0;
 int biasSP02Min = 0;
 int i = 0;
+
+// Keep track of screen inversion and alarm state
+int inverted = 0;
+int activeAlarm = 0;
 
 Adafruit_ILI9341 tft = Adafruit_ILI9341(CS_SCREEN, DC);
 Adafruit_STMPE610 ts = Adafruit_STMPE610(CS_TOUCH);

   return p;
}

IntervalTimer myTimer;

void setup(void){
  gui_setup();
  product_title();  
  ECG_setup();
  //sp02_setup();
  //temperature_setup();
  //settings_setup();
  alarm_button_setup();
  ecg.read();
  myTimer.begin(isr, 150);
  myTimer.priority(128);
}

void isr(void) {
	//clearScreen(ILI9341_BLUE);
    ecg.read();
	return;
}

int display_count = 0;

				tft.setTextColor(ILI9341_GREENYELLOW);
  				tft.setTextSize(2);
  				tft.println(s_hr);
                /*
                if ((hr < DEFAULT_ECG_MIN + biasECGMin) || (hr > DEFAULT_ECG_MAX + biasSP02Max)){
                    if (!activeAlarm) {
                        throwAlarm();
                    }
                }
                else {
                    if (activeAlarm) {
                        stopAlarm(); 
                    }
    		    } */ 
  		}
        else { hr_counter += 1; }
        }
  		else { display_count += 1;} 

	  if (ts.bufferEmpty()) {
		continue;
	  }
