From bee406c2d4b3c18b38a6d55843bd6575ccd3d05d Mon Sep 17 00:00:00 2001 From: Phil Schatzmann Date: Mon, 13 Nov 2023 16:27:39 +0100 Subject: [PATCH] AnalogDriverESP32V1 release calibration only when necessary --- src/AudioAnalog/AnalogAudioESP32V1.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AudioAnalog/AnalogAudioESP32V1.h b/src/AudioAnalog/AnalogAudioESP32V1.h index 8849a0c648..306b3377c2 100644 --- a/src/AudioAnalog/AnalogAudioESP32V1.h +++ b/src/AudioAnalog/AnalogAudioESP32V1.h @@ -71,11 +71,14 @@ class AnalogDriverESP32V1 : public AnalogDriverBase { if (active_rx) { adc_continuous_stop(adc_handle); adc_continuous_deinit(adc_handle); + // free up resources from calibration + if (cfg.adc_calibration_active) { #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED - adc_cali_delete_scheme_curve_fitting(adc_cali_handle); + adc_cali_delete_scheme_curve_fitting(adc_cali_handle); #elif !defined(CONFIG_IDF_TARGET_ESP32H2) - adc_cali_delete_scheme_line_fitting(adc_cali_handle); + adc_cali_delete_scheme_line_fitting(adc_cali_handle); #endif + } } converter.end(); active_tx = false; @@ -100,8 +103,8 @@ class AnalogDriverESP32V1 : public AnalogDriverBase { int available() override { return active_rx ? DEFAULT_BUFFER_SIZE : 0; } protected: - adc_continuous_handle_t adc_handle; - adc_cali_handle_t adc_cali_handle; + adc_continuous_handle_t adc_handle = nullptr; + adc_cali_handle_t adc_cali_handle = nullptr; AnalogConfigESP32V1 cfg; bool active = false; bool active_tx = false;