From 631db56a4467cc5186e39ba7e3f0d7c9c15d24ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 6 Nov 2022 14:32:02 +0100 Subject: [PATCH] Next try, plus change cppcheck defines back. --- platformio.ini | 4 ++-- src/modules/esp32/AudioModule.cpp | 23 +++++++---------------- src/modules/esp32/AudioModule.h | 12 ++++++------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/platformio.ini b/platformio.ini index 7c1ba6851..0021350dd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,8 +59,8 @@ lib_deps = check_tool = cppcheck check_skip_packages = yes check_flags = - --common-flag - cppcheck: --enable=--inline-suppr + -DAPP_VERSION=1.0.0 + --suppressions-list=suppressions.txt ; Common settings for conventional (non Portduino) Arduino targets [arduino_base] diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp index 9328bdd81..7147db43c 100644 --- a/src/modules/esp32/AudioModule.cpp +++ b/src/modules/esp32/AudioModule.cpp @@ -42,11 +42,11 @@ #define AUDIO_MODULE_MODE 7 // 700B #define AUDIO_MODULE_ACK 1 +#if defined(ARCH_ESP32) && defined(USE_SX1280) + AudioModule *audioModule; -#if defined(ARCH_ESP32) && defined(USE_SX1280) ButterworthFilter hp_filter(240, 8000, ButterworthFilter::ButterworthFilter::Highpass, 1); -#endif //int16_t 1KHz sine test tone int16_t Sine1KHz[8] = { -21210 , -30000, -21210, 0 , 21210 , 30000 , 21210, 0 }; @@ -54,11 +54,12 @@ int Sine1KHz_index = 0; uint8_t rx_raw_audio_value = 127; -AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") {} +AudioModule::AudioModule() : SinglePortModule("AudioModule", PortNum_AUDIO_APP), concurrency::OSThread("AudioModule") { + audio_fifo.init(); +} void AudioModule::run_codec2() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) if (state == State::tx) { for (int i = 0; i < ADC_BUFFER_SIZE; i++) @@ -91,7 +92,6 @@ void AudioModule::run_codec2() } } state = State::standby; -#endif } void AudioModule::handleInterrupt() @@ -101,7 +101,6 @@ void AudioModule::handleInterrupt() void AudioModule::onTimer() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) if (state == State::tx) { adc_buffer[adc_buffer_index++] = (16 * adc1_get_raw(mic_chan)) - 32768; @@ -129,13 +128,10 @@ void AudioModule::onTimer() //Play dacWrite(moduleConfig.audio.amp_pin ? moduleConfig.audio.amp_pin : AAMP, rx_raw_audio_value); } -#endif } int32_t AudioModule::runOnce() { -#if defined(ARCH_ESP32) && defined(USE_SX1280) - if (moduleConfig.audio.codec2_enabled) { if (firstTime) { @@ -198,9 +194,6 @@ int32_t AudioModule::runOnce() return INT32_MAX; } -#else - return INT32_MAX; -#endif } MeshPacket *AudioModule::allocReply() @@ -227,8 +220,6 @@ void AudioModule::sendPayload(NodeNum dest, bool wantReplies) ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) { -#if defined(ARCH_ESP32) && defined(USE_SX1280) - if (moduleConfig.audio.codec2_enabled) { auto &p = mp.decoded; if (getFrom(&mp) != nodeDB.getNodeNum()) { @@ -243,7 +234,7 @@ ProcessMessage AudioModule::handleReceived(const MeshPacket &mp) } } -#endif - return ProcessMessage::CONTINUE; } + +#endif \ No newline at end of file diff --git a/src/modules/esp32/AudioModule.h b/src/modules/esp32/AudioModule.h index b67f83c8b..d82af4d43 100644 --- a/src/modules/esp32/AudioModule.h +++ b/src/modules/esp32/AudioModule.h @@ -21,16 +21,16 @@ class AudioModule : public SinglePortModule, private concurrency::OSThread #if defined(ARCH_ESP32) && defined(USE_SX1280) bool firstTime = 1; hw_timer_t* adcTimer = NULL; - uint16_t adc_buffer[ADC_BUFFER_SIZE]; - int16_t speech[ADC_BUFFER_SIZE]; - int16_t output_buffer[ADC_BUFFER_SIZE]; - unsigned char rx_encode_frame[ENCODE_FRAME_SIZE]; - unsigned char tx_encode_frame[ENCODE_FRAME_SIZE]; + uint16_t adc_buffer[ADC_BUFFER_SIZE] = {}; + int16_t speech[ADC_BUFFER_SIZE] = {}; + int16_t output_buffer[ADC_BUFFER_SIZE] = {}; + unsigned char rx_encode_frame[ENCODE_FRAME_SIZE] = {}; + unsigned char tx_encode_frame[ENCODE_FRAME_SIZE] = {}; int tx_encode_frame_index = 0; FastAudioFIFO audio_fifo; uint16_t adc_buffer_index = 0; adc1_channel_t mic_chan = (adc1_channel_t)0; - struct CODEC2* codec2_state; + struct CODEC2* codec2_state = NULL; enum State {