From 002503259cbe4af4192036472345a8e0c1d68fbf Mon Sep 17 00:00:00 2001 From: uncarvedblock <1+uncarvedblock@git.franklin57.com> Date: Sat, 31 Oct 2026 15:11:15 -0400 Subject: [PATCH] Update components/es8388/es8388.cpp --- components/es8388/es8388.cpp | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/components/es8388/es8388.cpp b/components/es8388/es8388.cpp index d761875..ccb3d25 100644 --- a/components/es8388/es8388.cpp +++ b/components/es8388/es8388.cpp @@ -42,8 +42,8 @@ void ES8388::setup() { // sample freq 256 // DACFsMode,SINGLE SPEED; DACFsRatio,256 ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL2, 0x02)); - // 0x00 audio on LIN1&RIN1, 0x09 LIN2&RIN2 - ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL16, 0x00)); + // 0x00 audio on LIN1&RIN1, 0x09 LIN2&RIN2, 0x1B LADCIN&RADCIN + ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL16, 0x1B)); // only left DAC to left mixer enable 0db ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL17, 0x90)); // only right DAC to right mixer enable 0db @@ -52,42 +52,42 @@ void ES8388::setup() { ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL21, 0x80)); // vroi=0 - 1.5k VREF to analog output resistance (default) ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL23, 0x00)); + // DAC left volume control 0dB + ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL4, 0x00)); + // DAC right volume control 0dB + ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL5, 0x00)); // power down adc and line in ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCPOWER, 0xFF)); + // ADC mic amp PGA gain + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL1, 0x88)); // +24dB - //@nightdav - ES8388_ERROR_FAILED( - this->write_byte(ES8388_ADCCONTROL1, 0x00)); // +21dB : recommended value for ALC & voice recording - - // set to Mono Right - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL3, 0x02)); - - // I2S 16 Bits length and I2S serial audio data format - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL4, 0x0d)); - // ADCFsMode,singel SPEED,RATIO=256 + // set to L-R differential + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL2, 0xF0)); + // set to Stereo LIN2+RIN2, tri-state + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL3, 0x80)); + // I2S 16 Bits length and right justified I2S serial audio data format + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL4, 0x0E)); + // ADCFsMode,single SPEED,RATIO=256 ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL5, 0x02)); // ADC Volume - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL8, 0x00)); - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL9, 0x00)); + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL8, 0x20)); + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL9, 0x20)); - //@nightDav // ALC Config (as recommended by ES8388 user guide for voice recording) - - // Reg 0x12 = 0xe2 (ALC enable, PGA Max. Gain=23.5dB, Min. Gain=0dB) - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL10, 0xe2)); - - // Reg 0x13 = 0xa0 (ALC Target=-1.5dB, ALC Hold time =0 mS) - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL11, 0xa0)); - // Reg 0x14 = 0x12(Decay time =820uS , Attack time = 416 uS) + // ADC mic amp PGA gain + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL1, 0x77)); // +21dB + // Reg 0x12 = 0xEA (ALC stereo, PGA Max. Gain=23.5dB, Min. Gain=0dB) + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL10, 0xEA)); + // Reg 0x13 = 0x80 (ALC Target=-4.5dB, ALC Hold time =0 mS) + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL11, 0x80)); + // Reg 0x14 = 0x12 (Decay time =820uS , Attack time = 416 uS) ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL12, 0x12)); - - // Reg 0x15 = 0x06(ALC mode) + // Reg 0x15 = 0x06 (ALC mode, no zero cross detection, 96 sample window size) ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL13, 0x06)); - - // Reg 0x16 = 0xc3(nose gate = -40.5dB, NGG = 0x01(mute ADC)) - ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL14, 0xc3)); + // Reg 0x16 = 0xC3(nose gate = -40.5dB, NGG = 0x01(mute ADC)) + ES8388_ERROR_FAILED(this->write_byte(ES8388_ADCCONTROL14, 0xC3)); // Power on ADC ES8388_ERROR_FAILED(this->write_byte(ES8388_DACCONTROL21, 0x80));