Skip to content

Commit d456530

Browse files
committed
input: use init_adc in unmute handler
And move the es7210_adc_set_gain call to init_adc so we can drop the es7210.h header from input.c.
1 parent 28f9417 commit d456530

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

main/audio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ esp_err_t volume_set(int volume)
10081008
return audio_hal_set_volume(hdl_ahc, volume);
10091009
}
10101010

1011-
static void init_adc(void)
1011+
void init_adc(void)
10121012
{
10131013
if (hdl_aha != NULL) {
10141014
hdl_aha->audio_codec_deinitialize();
@@ -1023,6 +1023,7 @@ static void init_adc(void)
10231023
};
10241024

10251025
hdl_aha->audio_codec_config_iface(AUDIO_HAL_CODEC_MODE_ENCODE, &cfg_i2s);
1026+
es7210_adc_set_gain(ES7210_MIC_SELECT, config_get_int("mic_gain", DEFAULT_MIC_GAIN));
10261027
}
10271028

10281029
esp_err_t init_audio(void)
@@ -1044,7 +1045,6 @@ esp_err_t init_audio(void)
10441045
init_adc();
10451046
}
10461047

1047-
10481048
init_audio_response();
10491049
init_session_timer();
10501050
if (strcmp(speech_rec_mode, "WIS") == 0) {

main/audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern QueueHandle_t q_rec;
2222
extern struct willow_audio_response war;
2323

2424
void deinit_audio(void);
25+
void init_adc(void);
2526
esp_err_t init_audio(void);
2627
void play_audio_ok(void *data);
2728
esp_err_t volume_set(int volume);

main/input.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include "es7210.h"
21
#include "esp_err.h"
32
#include "esp_log.h"
43
#include "esp_peripherals.h"
54
#include "input_key_service.h"
65
#include "periph_button.h"
76

7+
#include "audio.h"
88
#include "config.h"
99
#include "shared.h"
1010
#include "system.h"
@@ -20,20 +20,7 @@ static esp_err_t cb_iks(periph_service_handle_t hdl, periph_service_event_t *ev,
2020
if (key == INPUT_KEY_USER_ID_MUTE) {
2121
if (ev->type == INPUT_KEY_SERVICE_ACTION_PRESS_RELEASE) {
2222
ESP_LOGI(TAG, "unmute");
23-
audio_hal_codec_config_t cfg_ahc = {
24-
.adc_input = AUDIO_HAL_ADC_INPUT_LINE1,
25-
.dac_output = AUDIO_HAL_DAC_OUTPUT_ALL,
26-
.codec_mode = AUDIO_HAL_CODEC_MODE_BOTH,
27-
.i2s_iface = {
28-
.mode = AUDIO_HAL_MODE_SLAVE,
29-
.fmt = AUDIO_HAL_I2S_NORMAL,
30-
.samples = AUDIO_HAL_16K_SAMPLES,
31-
.bits = AUDIO_HAL_BIT_LENGTH_32BITS,
32-
},
33-
};
34-
35-
es7210_adc_init(&cfg_ahc);
36-
es7210_adc_set_gain(ES7210_MIC_SELECT, config_get_int("mic_gain", DEFAULT_MIC_GAIN));
23+
init_adc();
3724
}
3825
}
3926

0 commit comments

Comments
 (0)