Loop for calibration

This commit is contained in:
Mikael Degerfält 2019-03-02 11:56:44 +01:00
parent 347b6e5c71
commit e448ba427c

View file

@ -493,25 +493,21 @@ void setup() {
initDisplay(); //Start up display and show logo initDisplay(); //Start up display and show logo
//auto-calibrate the vibrato threshold while showing splash screen //auto-calibrate the vibrato threshold while showing splash screen
int cv1=touchRead(vibratoPin); vibZero = breathCalZero = 0;
int bc1=analogRead(breathSensorPin); const int sampleCount = 4;
digitalWrite(statusLedPin,HIGH); for(int i =0 ; i < sampleCount; ++i) {
delay(250); vibZero += touchRead(vibratoPin);
int cv2=touchRead(vibratoPin); breathCalZero += analogRead(breathSensorPin);
int bc2=analogRead(breathSensorPin); digitalWrite( statusLedPin, 1-(i&1) );
digitalWrite(statusLedPin,LOW); delay(250);
delay(250); }
int cv3=touchRead(vibratoPin); vibZero /= sampleCount;
int bc3=analogRead(breathSensorPin); breathCalZero /= sampleCount;
digitalWrite(statusLedPin,HIGH);
delay(250); vibThr = vibZero - vibSquelch;
digitalWrite(statusLedPin,LOW); vibThrLo = vibZero + vibSquelch;
int cv4=touchRead(vibratoPin);
int bc4=analogRead(breathSensorPin); digitalWrite(statusLedPin, LOW);
vibZero=(cv1+cv2+cv3+cv4)/4;
vibThr=vibZero-vibSquelch;
vibThrLo=vibZero+vibSquelch;
breathCalZero=(bc1+bc2+bc3+bc4)/4;
delay(250); delay(250);
digitalWrite(statusLedPin,HIGH); digitalWrite(statusLedPin,HIGH);
delay(250); delay(250);