-
-
Notifications
You must be signed in to change notification settings - Fork 120
ES8311 Init Fix #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES8311 Init Fix #257
Conversation
ES8311 Fix - works 100% of the time now. Thanks ESPHome for the hint!
WalkthroughThe initialization sequence for the ES8311Source I2S microphone driver was updated. Register writes in the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
usermods/audioreactive/audio_source.h (3)
682-682: Good reliability note; consider surfacing at runtime when init fails.The “fully power off the board” comment is helpful. Consider adding a one-time WARN log or retry hint when ES8311 init fails so users see this tip without reading code.
688-688: Clarify CLOCK MANAGER bitfields and replace magic value.0x01 = 0b00111010 is critical. Please document exact bits (MCLK enable, dividers, sources) per ES8311 datasheet, or use named bit masks to improve maintainability.
697-714: Validate final-reset behavior, align word-length with I2S config, and add small delays.
- Final reset (Line 714): If 0x00=0x80 performs a full reset, it may wipe prior config. If it’s a “start/apply” reset (per ESPHome hint), it’s fine. Please read back one or two registers (e.g., 0x0A, 0x17) after this write to confirm settings persist.
- Word length (Line 705): You force 32-bit on ES8311, but the driver sometimes runs 16-bit when HUB75 is enabled. Mismatch can break the bus. Ensure 0x0A is set to match I2S_SAMPLE_RESOLUTION or enforce 32-bit on the I2S side for this codec.
- Duplicate 0x01 write (Lines 688 and 703): If not required by sequencing, drop one to reduce churn.
- Timing: Add short delays around reset/power transitions to increase bring-up reliability.
Minimal diff to add a safety delay before the final reset:
_es8311I2cWrite(0x19, 0b11110000); // ADC ALC max (-6dB) and min (-30dB) +delay(2); // Give time for internal state machines before issuing reset _es8311I2cWrite(0x00, 0b10000000); // *** RESET (This is very required! Thanks to ESPHome for the hint!)Also, please verify:
- 0x1B “soft-mute enabled” doesn’t mute the path unintentionally in steady state.
- 0x17 value really corresponds to the intended 0 dB gain to avoid clipping.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
usermods/audioreactive/audio_source.h(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: DedeHai
PR: MoonModules/WLED-MM#253
File: usermods/audioreactive/audio_source.h:1256-1261
Timestamp: 2025-07-12T04:20:14.546Z
Learning: In WLED AudioReactive usermod, DC offset removal optimization in DMAadcSource::getSamples() should be implemented after PR #248 merges, which will change the sample buffer from float to int16. This eliminates the need for temporary integer buffers and allows direct integer arithmetic on the native buffer type for better memory efficiency on resource-constrained MCUs like C3 and S2.
📚 Learning: 2025-07-12T04:20:14.546Z
Learnt from: DedeHai
PR: MoonModules/WLED-MM#253
File: usermods/audioreactive/audio_source.h:1256-1261
Timestamp: 2025-07-12T04:20:14.546Z
Learning: In WLED AudioReactive usermod, DC offset removal optimization in DMAadcSource::getSamples() should be implemented after PR #248 merges, which will change the sample buffer from float to int16. This eliminates the need for temporary integer buffers and allows direct integer arithmetic on the native buffer type for better memory efficiency on resource-constrained MCUs like C3 and S2.
Applied to files:
usermods/audioreactive/audio_source.h
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: Builds (esp8266pro_16MB_M)
- GitHub Check: Builds (esp8266_4MB_M)
- GitHub Check: Builds (esp8266_4MB_S)
- GitHub Check: Builds (esp01_1MB_S)
- GitHub Check: Builds (esp32S3_4MB_PSRAM_S)
- GitHub Check: Builds (esp32S3_16MB_PSRAM_M_HUB75)
- GitHub Check: Builds (adafruit_matrixportal_esp32s3_tinyUF2)
- GitHub Check: Builds (esp32s2_PSRAM_M)
- GitHub Check: Builds (esp32S3_WROOM-2_M)
- GitHub Check: Builds (esp32c3dev_2MB_M)
- GitHub Check: Builds (esp32S3_4MB_PSRAM_M)
- GitHub Check: Builds (esp32c3mini_dio_4MB_M)
- GitHub Check: Builds (esp8266_2MB_S)
- GitHub Check: Builds (esp32S3_8MB_M)
- GitHub Check: Builds (esp32S3_4MB_S)
- GitHub Check: Builds (esp32S3_8MB_S)
- GitHub Check: Builds (esp32_16MB_V4_M)
- GitHub Check: Builds (esp32_4MB_V4_S)
- GitHub Check: Builds (esp32_16MB_V4_S)
- GitHub Check: Builds (esp32_4MB_V4_HUB75_forum)
ES8311 Fix - works 100% of the time now. Thanks ESPHome for the hint!
Summary by CodeRabbit
Documentation
Refactor