 // - If no serial data is detected audio tone turns off and LED1 is off
 // - MUTE_AUDIO_UNDER_IAS define is used to only activate audio tones if above a given airspeed
 // 
-// 7/9/2018 - 1.5.1 fix for tone PPS between solid tones.  was not calucating the right ratio for the PPS changes.
-// 9/2/2018 - 1.5.2 Atempts to fix hang up issues with skyview data.  Changed start up tones.  added more comments. fix min PPS for low tone.
-// 9/28/2018- 1.6.0 Fixed Skyview lockup issue.
-
-//#define SETUP_DYNON_D100             // if this is defined then use settings (dynon D10 or D100)
-#define SETUP_DYNON_SKYVIEW            // if defined then use settings for dynon skyview
+// 7/9/2018   - 1.5.1 fix for tone PPS between solid tones.  was not calucating the right ratio for the PPS changes.
+// 9/2/2018   - 1.5.2 Atempts to fix hang up issues with skyview data.  Changed start up tones.  added more comments. fix min PPS for low tone.
+// 9/28/2018  - 1.6.0 Fixed Skyview lockup issue.
+// 9/28/2018  - 1.6.1 allow for automatic efis dectection d100 or skyview.
 
 #include <DueTimer.h>         // timer lib functions for using DUE timers and callbacks.
 #include <stdint.h>

  }
  
  // check AOA value and set tone and pauses between tones according to 
  if(AOA >= HIGH_TONE_AOA_STALL) {
    // play 20 pps HIGH tone
    highTone = true;
    setPPSTone(HIGH_TONE_STALL_PPS);
    toneMode = PULSE_TONE;
  } else if(AOA >= HIGH_TONE_AOA_START) {
    // play HIGH tone at Pulse Rate 1.5 PPS to 6.2 PPS (depending on AOA value)
    highTone = true;
    OldValue = AOA-(HIGH_TONE_AOA_START-1);
    toneMode = PULSE_TONE;
    // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
    OldRange = HIGH_TONE_AOA_STALL - HIGH_TONE_AOA_START; //20 - 1;  //(OldMax - OldMin)  
    NewRange = HIGH_TONE_PPS_MAX - HIGH_TONE_PPS_MIN; // (NewMax - NewMin)  
    NewValue = (((OldValue - 1) * NewRange) / OldRange) + HIGH_TONE_PPS_MIN; //(((OldValue - OldMin) * NewRange) / OldRange) + NewMin
    setPPSTone(NewValue);
  } else if(AOA >= LOW_TONE_AOA_SOLID) {
    // play a steady LOW tone
    highTone = false;
    toneMode = SOLID_TONE;
  } else if(AOA > LOW_TONE_AOA_START) {
    toneMode = PULSE_TONE;
    highTone = false;
    // play LOW tone at Pulse Rate 1.5 PPS to 8.2 PPS (depending on AOA value)
    // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
    OldValue = AOA-LOW_TONE_AOA_START;
    OldRange = LOW_TONE_AOA_SOLID - LOW_TONE_AOA_START; //40 - 1;  //(OldMax - OldMin)  
    NewRange = LOW_TONE_PPS_MAX - LOW_TONE_PPS_MIN; // (NewMax - NewMin)  
    NewValue = (((OldValue - 1) * NewRange) / OldRange) + LOW_TONE_PPS_MIN; //(((OldValue - OldMin) * NewRange) / OldRange) + NewMin
    setPPSTone(NewValue);

unsigned int ALT = 0;                 // hold ALT (only used for debuging)
int ASI = 0;                          // live Air Speed Indicated
unsigned int cyclesWOSerialData = 0;  // keep track if not serial data is recieved.
//unsigned char efisTypeDetected = 0;   // auto detect which efis is being used. 0 no detection. 1 = D series, 2 = Skyview
GaussianAverage myAverageAOA = GaussianAverage(AOA_HISTORY_MAX);
static Tc *chTC = TC0;
static uint32_t chNo = 0;
