Skip to content

Commit b4323a3

Browse files
authored
Fixes for ES8311 auto level control
1 parent d58cb49 commit b4323a3

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

usermods/audioreactive/audio_source.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ class ES8311Source : public I2SSource {
677677

678678
void _es8311InitAdc() {
679679
//
680-
// Currently only tested with the ESP32-P4 EV board with the onboard mic.
680+
// Currently only tested with the ESP32-P4 boards with the onboard mic.
681681
// Datasheet with I2C commands: https://dl.xkwy2018.com/downloads/RK3588/01_Official%20Release/04_Product%20Line%20Branch_NVR/02_Key%20Device%20Specifications/ES8311%20DS.pdf
682682
//
683683
_es8311I2cBegin();
@@ -693,26 +693,23 @@ class ES8311Source : public I2SSource {
693693
_es8311I2cWrite(0x08, 0b11111111); // 22050hz calculated
694694
_es8311I2cWrite(0x06, 0b11100011); // 22050hz calculated
695695

696-
_es8311I2cWrite(0x16, 0b00100000); // ADC was 0b00000011 trying 0b00100100 now
696+
_es8311I2cWrite(0x16, 0b00100100); // ADC was 0b00000011 trying 0b00100100 was good
697697
_es8311I2cWrite(0x0B, 0b00000000); // SYSTEM at default
698698
_es8311I2cWrite(0x0C, 0b00100000); // SYSTEM was 0b00001111 trying 0b00100000
699699
_es8311I2cWrite(0x10, 0b00010011); // SYSTEM was 0b00011111 trying 0b00010011
700700
_es8311I2cWrite(0x11, 0b01111100); // SYSTEM was 0b01111111 trying 0b01111100
701701
_es8311I2cWrite(0x00, 0b11000000); // *** RESET (again - seems important?)
702-
_es8311I2cWrite(0x01, 0b00111010); // CLOCK MANAGER was 0b00111111 trying 0b00111010 (again??)
703-
_es8311I2cWrite(0x14, 0b00010000); // *** SYSTEM was 0b00011010 trying 0b00010000 (or 0b01111010) (PGA gain)
704-
_es8311I2cWrite(0x12, 0b00000000); // SYSTEM - DAC, likely don't care
705-
_es8311I2cWrite(0x13, 0b00010000); // SYSTEM - output, likely don't cate
706-
_es8311I2cWrite(0x09, 0b00001000); // SDP IN (likely don't care) was 0b00001100 (16-bit) - changed to 0b00001000 (I2S 32-bit)
702+
_es8311I2cWrite(0x01, 0b00111010); // *** CLOCK MANAGER was 0b00111111 trying 0b00111010 (again?? seems important)
703+
_es8311I2cWrite(0x14, 0b00010000); // *** SYSTEM was 0b00011010 trying 0b00010000 (PGA gain)
707704
_es8311I2cWrite(0x0A, 0b00001000); // *** SDP OUT, was 0b00001100 trying 0b00001000 (I2S 32-bit)
708-
_es8311I2cWrite(0x0E, 0b00000010); // *** SYSTEM was 0b00000010 trying 0b00011010 (seems best so far!) (or 0b00000010)
705+
_es8311I2cWrite(0x0E, 0b00000010); // *** SYSTEM was 0b00000010 trying 0b00000010
709706
_es8311I2cWrite(0x0F, 0b01000100); // SYSTEM was 0b01000100
710-
_es8311I2cWrite(0x15, 0b00000000); // ADC soft ramp (disabled)
707+
_es8311I2cWrite(0x15, 0b00010000); // ADC soft ramp (disabled 0000xxxx)
711708
_es8311I2cWrite(0x1B, 0b00000101); // ADC soft-mute was 0b00000101
712-
_es8311I2cWrite(0x1C, 0b01100101); // ADC EQ and offset freeze was 0b01100101 (bad at 0b00101100)
713-
_es8311I2cWrite(0x17, 0b10111111); // ADC volume was 0b11111111 trying ADC volume 0b10111111 = 0db (maxgain) 0x16
714-
_es8311I2cWrite(0x44, 0b00000000); // 0b10000000 - loopback test. on: 0x88; off: 0x00; mic--" speak
715-
709+
_es8311I2cWrite(0x1C, 0b01100101); // ADC EQ and offset freeze at 0b01100101 (bad at 0b00101100)
710+
_es8311I2cWrite(0x17, 0b10111111); // ADC volume was 0b11111111 trying ADC volume 0b10111111 = 0db (maxgain)
711+
_es8311I2cWrite(0x18, 0b10000001); // ADC ALC enabled and AutoMute disabled.
712+
// _es8311I2cWrite(0x19, 0b11110100); // ADC ALC max and min - not sure how best to use this, default seems fine
716713
}
717714

718715
public:

0 commit comments

Comments
 (0)