import peakutils

RR = 0
WINDOW_SIZE = 10
FS = 5
DATA = []

def power_on_sound():
    pass

def init_LCD(init_RR):
    pass

def update_LCD():
    pass

def check_alarm_conditions():
    pass

def init_data():
    pass

def sample_data():
    pass

def calc_RR():
    pass

def main():
    # initialize
    power_on_sound()
    init_data() # every x seconds, acquire sample until a window is full
    init_LCD(calc_RR())

    # main loop
    while True:
        # every x seconds, sample resistance
        sample_data()
        # update RR estimate
        calc_RR()
        # check for alarm conditions
        check_alarm_conditions()
        # update LCD
        update_LCD()

if __name__ == "__main__":
    main()

@@ -14,39 +14,609 @@
 ils%0A
-%0ARR = 0%0AWINDOW_SIZE = 10%0AFS = 5
+import RPi.GPIO as GPIO%0Aimport time%0Aimport Adafruit_ADS1x15%0A%0A# initialize ADC%0Aadc = Adafruit_ADS1x15.ADS1115()%0AGAIN = 1%0AADC_IN = 0%0A%0A# initialize piezo%0APIN = 18                                # Use GPIO pin 18 as output%0AGPIO.setmode(GPIO.BCM)%0AGPIO.setup(PIN, GPIO.OUT)%0A%0A# alarm conditions%0ALL = 10                                 # lower limit: 10 breaths per minute%0AUL = 70                                 # upper limit: 70 breaths per minute%0A%0ARR = 0%0AWINDOW_SIZE = 10                        # Determined RR from a 10-second window%0AFS = 100                                # Sample at 100 Hz%0ADELAY = 1/FS
 %0ADAT

set up global variables