Skip to content
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] Add es8311 dac component #7693

Merged
merged 4 commits into from
Oct 30, 2024
Merged

[es8311] Add es8311 dac component #7693

merged 4 commits into from
Oct 30, 2024

Conversation

kahrendt
Copy link
Contributor

What does this implement/fix?

Adds support for the ES8311 codec chip as an audio_dac component. The S3 Box 3 uses this for handling audio output. It supports volume and mute control in hardware.

I built this from the unmerged #4861, and so I listed @kroimon as a codeowner. If you would prefer not to be included, please let me know. I adapted that code to the audio_dac platform and exposed more yaml configuration options.

Note that this only handles audio out on the S3 box, not audio in. So it only removes the requirement for the esp_adf component's speaker. I haven't tested pairing this component with the esp_adf microphone in a voice assistant, so that may not work!

Requires the already merged #7664 to handle volume control with the speaker component.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

Pull request in esphome-docs with documentation (if applicable):

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

# Example config.yaml

# Sets up the S3 Box 3's speaker

external_components:
  - source: github://pr#7672
    components:
      - audio
      - speaker
      - i2s_audio
    refresh: 0s

audio_dac:
  - platform: es8311
    id: es8311_dac
    bits_per_sample: 16bit
    sample_rate: 16000

i2s_audio:
  - id: i2s_output
    i2s_lrclk_pin: GPIO45
    i2s_bclk_pin: GPIO17
    i2s_mclk_pin: GPIO23

speaker:
  - platform: i2s_audio
    i2s_audio_id: i2s_output
    id: speaker_id
    i2s_dout_pin: GPIO15
    dac_type: external
    sample_rate: 16000
    bits_per_sample: 16bit
    channel: stereo
    audio_dac: es8311_dac

switch:
  - platform: gpio
    name: "Speaker Enable"
    pin: GPIO46
    restore_mode: RESTORE_DEFAULT_ON

number:
  - platform: template
    name: "Speaker Volume"
    optimistic: true
    min_value: 0.0
    max_value: 1.0
    step: 0.05
    on_value:
      speaker.volume_set: !lambda "return x;"

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.99%. Comparing base (4d8b5ed) to head (6cde4b5).
Report is 1542 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #7693      +/-   ##
==========================================
+ Coverage   53.70%   53.99%   +0.28%     
==========================================
  Files          50       50              
  Lines        9408     9766     +358     
  Branches     1654     1344     -310     
==========================================
+ Hits         5053     5273     +220     
- Misses       4056     4167     +111     
- Partials      299      326      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kahrendt kahrendt marked this pull request as ready for review October 29, 2024 14:58
@kahrendt kahrendt requested review from jesserockz and a team as code owners October 29, 2024 14:58
@probot-esphome
Copy link

Hey there @jesserockz, mind taking a look at this pull request as it has been labeled with an integration (i2s_audio) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

esphome/components/es8311/es8311.cpp Outdated Show resolved Hide resolved
esphome/components/es8311/es8311.cpp Outdated Show resolved Hide resolved
@esphome esphome bot marked this pull request as draft October 30, 2024 01:29
@esphome
Copy link

esphome bot commented Oct 30, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@kahrendt kahrendt marked this pull request as ready for review October 30, 2024 12:57
@esphome esphome bot requested a review from jesserockz October 30, 2024 12:57
@jesserockz jesserockz merged commit 765579d into esphome:dev Oct 30, 2024
26 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
@kahrendt kahrendt deleted the es8311 branch January 1, 2025 11:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants