找回密码
 立即注册

微信扫码登录

搜索
查看: 441|回复: 0

[硬件DIY] 经验分享】esphome大屏幕上墙,阶段进展四,音频修复&自动化总控页面

[复制链接]

60

主题

333

回帖

3361

积分

元老级技术达人

积分
3361
金钱
2953
HASS币
100
发表于 2026-4-17 11:43:25 | 显示全部楼层 |阅读模式
上一篇:【经验分享】esphome大屏幕上墙,阶段进展三,电力&设备统计页面 - 『HomeAssistant』综合讨论区 - 『瀚思彼岸』» 智能家居技术论坛 - Powered by Discuz!



esphome大屏幕上墙,阶段进展四
音频修复&自动化控制页面


页面预览:
ScreenShot_2026-04-17_110628_292.png ScreenShot_2026-04-17_110555_273.png ScreenShot_2026-04-17_110539_557.png
基本就是一些button组织,为了防止乱动,设置了一个锁,解锁后才允许改动开关
ScreenShot_2026-04-17_111015_804.png
动态演示:


此阶段的主要工作:
  • 修复音频破音等问题,现在勉强可用
  • 修复与esphome 2026.4.0 lvgl9的兼容性
  • 更新了几个自用的外部组件,适配lvgl9,包括这个屏的mipi_dsi驱动,和一个截屏工具
  • 写完了自动化的总控页面

1、修复音频问题
官方的i2s_audio组件,对一些编解码器和 D 类放大器组合,如我这款P4上的 ES8311 + NS4150B,音频重新开始播放时每次都会初始化i2s通道,会导致噼啪/咔哒的瞬态噪声。
翻找PR,发现了一个还没合并的修复:https://github.com/esphome/esphome/pull/15565

该PR确实有效,不过鉴于我这个开发板附带的喇叭过于辣鸡,只能用来做下提示音,提示音也不是每种都可以,需要有一定长度,短的音频直接就成了蜂鸣器。
而且音量有效区间也窄的可伶,不是没声就是破音
音频配置参考:
external_components:
  - source:
      type: local
      path: external_components
    components: [ i2s_audio]

switch:
  - platform: gpio
    id: sound_enable_sw
    pin: GPIO53
    restore_mode: ALWAYS_ON
    internal: true

  - platform: lvgl
    id: touch_sound_sw
    widget: lvgl_touch_sound_sw
    name: "Touch Sound"
    icon: "mdi:playlist-music"
    entity_category: "config"
    restore_mode: RESTORE_DEFAULT_ON


i2s_audio:
  - id: i2s_out
    i2s_lrclk_pin: GPIO10
    i2s_bclk_pin: GPIO12
    i2s_mclk_pin: GPIO13

  

audio_dac:
  - platform: es8311
    id: ex_es8311
    i2c_id: i2c_bus_1
    bits_per_sample: 16bit
    sample_rate: 48000

speaker:
  - platform: i2s_audio
    id: main_speaker
    dac_type: external
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIO9
    audio_dac: ex_es8311
    keep_alive: true
    channel: mono          # 单声道
    sample_rate: 48000
    bits_per_sample: 16bit
    buffer_duration: 1000ms

media_player:
  - platform: speaker
    id: audio_media_player
    task_stack_in_psram: true
    internal: true
    volume_increment: 2%
    volume_initial: 0.7
    volume_min: 0.6
    volume_max: 0.8
    announcement_pipeline:
      speaker: main_speaker
      format: FLAC          # FLAC 解码开销低
      num_channels: 1       # mono
      sample_rate: 48000
    files:
      - id: click_sound
        file: src/sound/click_v3.flac


2、与LVGL 9的兼容性修复
esphome 2026.4.0从旧版的lvgl 8.4更新到了lvgl 9.5,性能提升没感觉到,兼容性问题却不少
主要的一个,就是对image图片的新渲染方法。
导致的问题:
  • 默认8KB的loop_task_stack_size过小,会导致一些存在深层嵌套图片的页面加载时直接崩溃重启,需要配置:
esp32:
    advanced:
      loop_task_stack_size: 32768   #直接拉到最大32Kb
  • apng动图编译失败,放弃了这个方案,退回到animimg组件代替,不过需要写一大堆图片序列,然后用include引用,比较繁琐
- animimg:
                src: !include ../../../../src/pic/device_page/fan_animimg/animate_id.yaml
                align: LEFT_MID
                height: 30
                width: 30
                duration: 2000ms

3、更新了自用的外部组件库
external_components:
  - source:
      type: git
      url: https://github.com/gasment/esphome_mipi_dsi_patch_for_jd9365_10_1_dsi_touch_a
      ref: main
    components: [ mipi_dsi ]
    refresh: 24h

  - source:
      type: git
      url: https://github.com/gasment/esphome-lvgl-screenshot
      ref: main
    components: [lvgl_screenshot]
    refresh: 24h

lvgl_screenshot:
  port: 8080

以上,未完待续

评分

参与人数 2金钱 +32 收起 理由
DDDear + 12 膜拜大神!
sorrypqa + 20 感谢楼主分享!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2026-5-13 01:57 , Processed in 0.059837 second(s), 5 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表