Next try, plus change cppcheck defines back.

This commit is contained in:
Thomas Göttgens 2022-11-06 14:32:02 +01:00
parent 7b378d36cc
commit 631db56a44
3 changed files with 15 additions and 24 deletions

View File

@ -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]

View File

@ -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

View File

@ -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
{