 void loop(void) {
 
   //service the potentiometer...if enough time has passed
-  servicePotentiometer(millis());
+  servicePotentiometer(millis(),100); //update every 100msec
+
+  //update the memory and CPU usage...if enough time has passed
+  myTympan.printCPUandMemory(millis(),3000); //print every 3000 msec
 
 };
 
 
 //servicePotentiometer: listens to the blue potentiometer and sends the new pot value
 //  to the audio processing algorithm as a control parameter
-void servicePotentiometer(unsigned long curTime_millis) {
-  static unsigned long updatePeriod_millis = 100; //how many milliseconds between updating the potentiometer reading?
+void servicePotentiometer(unsigned long curTime_millis,unsigned long updatePeriod_millis) {
   static unsigned long lastUpdate_millis = 0;
   static float prev_val = -1.0;
 

#include <Tympan_Library.h>


// GUItool: begin automatically generated code
Tympan						audioHardware(TympanRev::D);  //TympanRev::D or TympanRev::C
AudioInputI2S_F32        i2sAudioIn1;    //xy=136,112
AudioFilterBiquad_F32       iir1;           //xy=233,172
AudioEffectCompWDRC_F32  compWDRC1;      //xy=427,172
AudioOutputI2S_F32       i2sAudioOut1;   //xy=630,174
AudioConnection_F32         patchCord1(i2sAudioIn1, 0, iir1, 0);
AudioConnection_F32         patchCord2(iir1, compWDRC1);
AudioConnection_F32         patchCord3(compWDRC1, 0, i2sAudioOut1, 0);
AudioConnection_F32         patchCord4(compWDRC1, 0, i2sAudioOut1, 1);
// GUItool: end automatically generated code

//I have a potentiometer on the Teensy Audio Board
#define POT_PIN A20  //potentiometer is tied to this pin

//define a function to setup the Teensy Audio Board how I like it
void setupMyAudioBoard(void) {
  // Setup the Tympan audio hardware
  audioHardware.enable(); // activate AIC

  // Choose the desired input
  audioHardware.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones // default
  //  audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V
  //  audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF
  //  audioHardware.inputSelect(TYMPAN_INPUT_LINE_IN); // use the line in pads on the TYMPAN board - defaults to mic bias OFF

  //Adjust the MIC bias, if using TYMPAN_INPUT_JACK_AS_MIC
  //  audioHardware.setMicBias(TYMPAN_MIC_BIAS_OFF); // Turn mic bias off
  audioHardware.setMicBias(TYMPAN_MIC_BIAS_2_5); // set mic bias to 2.5 // default

  // VOLUMES
  audioHardware.volume_dB(0);  // -63.6 to +24 dB in 0.5dB steps.  uses float
  audioHardware.setInputGain_dB(10); // set MICPGA volume, 0-47.5dB in 0.5dB setps
}

//The setup function is called once when the system starts up
void setup(void) {
  //Start the USB serial link (to enable debugging)
  Serial.begin(115200); delay(500);
  Serial.println("Setup starting...");

  //Allocate dynamically shuffled memory for the audio subsystem
  AudioMemory(10);  AudioMemory_F32(10);

  //setup high-pass IIR...[b,a]=butter(2,750/(44100/2),'high')
  float32_t hp_b[]={ 0.927221242739230,  -1.854442485478460,   0.927221242739230};

  iir1.setFilterCoeff_Matlab(hp_b, hp_a); //one stage of N=2 IIR

  // Enable the audio shield, select input, and enable output
  setupTympanHardware();

  //End of setup
  myTympan.println("Setup complete.");
};


