diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/Pyr0_Piezo_Sensor_V2.x.x.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/Pyr0_Piezo_Sensor_V2.x.x.cpp index af37f29..26bddca 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/Pyr0_Piezo_Sensor_V2.x.x.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/Pyr0_Piezo_Sensor_V2.x.x.cpp @@ -156,8 +156,8 @@ void loop() { // Check voltage of first and second stages and compare against thresholds readVin(); - VComp = analogRead(VCOMP_SENSE_PIN); - VFol = analogRead(V_FOLLOW_PIN); + VComp = analogReadFast(VCOMP_SENSE_PIN); + VFol = analogReadFast(V_FOLLOW_PIN); VLast = VOld - Vin; if (VLast > Hyst || VLast < -Hyst) { diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h index fdf588f..4395428 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h @@ -12,6 +12,14 @@ void digitalWriteFast(uint8_t pin, uint8_t x) { } } +int inline analogReadFast(byte ADCpin) +{ byte ADCSRAoriginal = ADCSRA; + ADCSRA = (ADCSRA & B11111000) | 4; + int adc = analogRead(ADCpin); + ADCSRA = ADCSRAoriginal; + return adc; +} + /*------------------------------------------------*/ void pulse() {