esphome 2024.12.4__py3-none-any.whl → 2025.2.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/__main__.py +16 -3
- esphome/components/adc/__init__.py +17 -11
- esphome/components/adc/adc_sensor.h +17 -0
- esphome/components/adc/adc_sensor_common.cpp +55 -0
- esphome/components/adc/adc_sensor_esp32.cpp +8 -5
- esphome/components/adc/adc_sensor_esp8266.cpp +10 -6
- esphome/components/adc/adc_sensor_libretiny.cpp +11 -6
- esphome/components/adc/adc_sensor_rp2040.cpp +13 -10
- esphome/components/adc/sensor.py +9 -3
- esphome/components/ads1115/ads1115.cpp +56 -7
- esphome/components/ads1115/ads1115.h +13 -1
- esphome/components/ads1115/sensor/__init__.py +16 -0
- esphome/components/ads1115/sensor/ads1115_sensor.cpp +2 -1
- esphome/components/ads1115/sensor/ads1115_sensor.h +2 -0
- esphome/components/animation/__init__.py +23 -261
- esphome/components/animation/animation.cpp +2 -2
- esphome/components/animation/animation.h +2 -1
- esphome/components/api/api_pb2.cpp +14 -0
- esphome/components/api/api_pb2.h +1 -0
- esphome/components/audio/__init__.py +112 -0
- esphome/components/audio/audio.cpp +67 -0
- esphome/components/audio/audio.h +125 -7
- esphome/components/audio/audio_decoder.cpp +361 -0
- esphome/components/audio/audio_decoder.h +135 -0
- esphome/components/audio/audio_reader.cpp +308 -0
- esphome/components/audio/audio_reader.h +85 -0
- esphome/components/audio/audio_resampler.cpp +159 -0
- esphome/components/audio/audio_resampler.h +101 -0
- esphome/components/audio/audio_transfer_buffer.cpp +165 -0
- esphome/components/audio/audio_transfer_buffer.h +139 -0
- esphome/components/audio_adc/__init__.py +41 -0
- esphome/components/audio_adc/audio_adc.h +17 -0
- esphome/components/audio_adc/automation.h +23 -0
- esphome/components/bk72xx/__init__.py +1 -0
- esphome/components/ble_client/ble_client.cpp +1 -2
- esphome/components/ble_client/sensor/__init__.py +1 -1
- esphome/components/ble_client/text_sensor/__init__.py +1 -1
- esphome/components/bluetooth_proxy/bluetooth_connection.cpp +5 -0
- esphome/components/bluetooth_proxy/bluetooth_connection.h +1 -0
- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
- esphome/components/ch422g/ch422g.h +2 -0
- esphome/components/climate/__init__.py +1 -1
- esphome/components/climate_ir/climate_ir.cpp +2 -1
- esphome/components/coolix/coolix.cpp +2 -1
- esphome/components/custom/__init__.py +0 -3
- esphome/components/custom/binary_sensor/__init__.py +2 -28
- esphome/components/custom/climate/__init__.py +2 -27
- esphome/components/custom/cover/__init__.py +2 -27
- esphome/components/custom/light/__init__.py +2 -27
- esphome/components/custom/output/__init__.py +2 -58
- esphome/components/custom/sensor/__init__.py +2 -24
- esphome/components/custom/switch/__init__.py +2 -24
- esphome/components/custom/text_sensor/__init__.py +2 -29
- esphome/components/custom_component/__init__.py +3 -27
- esphome/components/daly_bms/daly_bms.cpp +6 -0
- esphome/components/daly_bms/daly_bms.h +2 -0
- esphome/components/daly_bms/sensor.py +6 -0
- esphome/components/debug/debug_component.cpp +4 -0
- esphome/components/debug/debug_component.h +14 -0
- esphome/components/debug/debug_esp32.cpp +154 -74
- esphome/components/dfplayer/dfplayer.cpp +15 -2
- esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp +2 -1
- esphome/components/dht/dht.cpp +2 -1
- esphome/components/display/__init__.py +18 -5
- esphome/components/display/display.cpp +2 -1
- esphome/components/display/rect.cpp +2 -1
- esphome/components/es7210/__init__.py +0 -0
- esphome/components/es7210/audio_adc.py +51 -0
- esphome/components/es7210/es7210.cpp +228 -0
- esphome/components/es7210/es7210.h +62 -0
- esphome/components/es7210/es7210_const.h +129 -0
- esphome/components/es7243e/__init__.py +0 -0
- esphome/components/es7243e/audio_adc.py +34 -0
- esphome/components/es7243e/es7243e.cpp +125 -0
- esphome/components/es7243e/es7243e.h +37 -0
- esphome/components/es7243e/es7243e_const.h +54 -0
- esphome/components/es8156/__init__.py +0 -0
- esphome/components/es8156/audio_dac.py +27 -0
- esphome/components/es8156/es8156.cpp +87 -0
- esphome/components/es8156/es8156.h +51 -0
- esphome/components/es8156/es8156_const.h +68 -0
- esphome/components/es8311/audio_dac.py +1 -2
- esphome/components/esp32/__init__.py +1 -0
- esphome/components/esp32/core.cpp +5 -1
- esphome/components/esp32/gpio.h +2 -0
- esphome/components/esp32_ble/__init__.py +39 -0
- esphome/components/esp32_ble/queue.h +4 -4
- esphome/components/esp32_ble_client/ble_client_base.cpp +46 -0
- esphome/components/esp32_ble_client/ble_client_base.h +2 -0
- esphome/components/esp32_ble_server/__init__.py +582 -12
- esphome/components/esp32_ble_server/ble_characteristic.cpp +48 -60
- esphome/components/esp32_ble_server/ble_characteristic.h +24 -17
- esphome/components/esp32_ble_server/ble_descriptor.cpp +21 -9
- esphome/components/esp32_ble_server/ble_descriptor.h +17 -6
- esphome/components/esp32_ble_server/ble_server.cpp +62 -67
- esphome/components/esp32_ble_server/ble_server.h +28 -32
- esphome/components/esp32_ble_server/ble_server_automations.cpp +77 -0
- esphome/components/esp32_ble_server/ble_server_automations.h +115 -0
- esphome/components/esp32_ble_server/ble_service.cpp +17 -15
- esphome/components/esp32_ble_server/ble_service.h +10 -14
- esphome/components/esp32_ble_tracker/__init__.py +6 -39
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +33 -10
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +8 -4
- esphome/components/esp32_improv/__init__.py +2 -8
- esphome/components/esp32_improv/esp32_improv_component.cpp +21 -20
- esphome/components/esp32_improv/esp32_improv_component.h +3 -4
- esphome/components/esp32_rmt/__init__.py +28 -3
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +73 -6
- esphome/components/esp32_rmt_led_strip/led_strip.h +21 -3
- esphome/components/esp32_rmt_led_strip/light.py +72 -7
- esphome/components/esp32_touch/esp32_touch.cpp +5 -0
- esphome/components/esp8266/__init__.py +1 -0
- esphome/components/esp8266/gpio.h +1 -0
- esphome/components/ethernet/__init__.py +10 -10
- esphome/components/event/event.cpp +4 -2
- esphome/components/event/event.h +2 -0
- esphome/components/event_emitter/__init__.py +5 -0
- esphome/components/event_emitter/event_emitter.cpp +14 -0
- esphome/components/event_emitter/event_emitter.h +63 -0
- esphome/components/gcja5/gcja5.cpp +2 -1
- esphome/components/haier/haier_base.cpp +2 -1
- esphome/components/haier/hon_climate.cpp +2 -1
- esphome/components/heatpumpir/heatpumpir.cpp +2 -1
- esphome/components/host/__init__.py +1 -0
- esphome/components/host/gpio.h +1 -0
- esphome/components/http_request/http_request.h +2 -2
- esphome/components/http_request/http_request_arduino.cpp +1 -1
- esphome/components/http_request/http_request_idf.cpp +1 -1
- esphome/components/i2c/i2c_bus_esp_idf.cpp +4 -0
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +7 -5
- esphome/components/i2s_audio/speaker/__init__.py +53 -6
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +92 -46
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -0
- esphome/components/ili9xxx/display.py +29 -11
- esphome/components/ili9xxx/ili9xxx_display.cpp +2 -5
- esphome/components/ili9xxx/ili9xxx_display.h +2 -1
- esphome/components/image/__init__.py +443 -255
- esphome/components/image/image.cpp +115 -61
- esphome/components/image/image.h +15 -24
- esphome/components/json/json_util.cpp +8 -34
- esphome/components/libretiny/__init__.py +1 -0
- esphome/components/libretiny/gpio_arduino.h +1 -0
- esphome/components/light/light_color_values.h +1 -1
- esphome/components/logger/__init__.py +43 -7
- esphome/components/logger/logger.cpp +16 -11
- esphome/components/logger/logger.h +11 -7
- esphome/components/logger/select/__init__.py +29 -0
- esphome/components/logger/select/logger_level_select.cpp +27 -0
- esphome/components/logger/select/logger_level_select.h +15 -0
- esphome/components/lvgl/__init__.py +96 -73
- esphome/components/lvgl/automation.py +39 -7
- esphome/components/lvgl/defines.py +8 -2
- esphome/components/lvgl/lvgl_esphome.cpp +8 -15
- esphome/components/lvgl/lvgl_esphome.h +20 -5
- esphome/components/lvgl/schemas.py +25 -14
- esphome/components/lvgl/trigger.py +27 -3
- esphome/components/lvgl/widgets/dropdown.py +1 -1
- esphome/components/lvgl/widgets/keyboard.py +8 -1
- esphome/components/lvgl/widgets/meter.py +2 -1
- esphome/components/lvgl/widgets/msgbox.py +1 -1
- esphome/components/lvgl/widgets/obj.py +1 -12
- esphome/components/lvgl/widgets/page.py +37 -2
- esphome/components/lvgl/widgets/tabview.py +1 -1
- esphome/components/max6956/max6956.h +2 -0
- esphome/components/mcp23016/mcp23016.h +2 -0
- esphome/components/mcp23xxx_base/mcp23xxx_base.h +2 -0
- esphome/components/mdns/__init__.py +1 -1
- esphome/components/media_player/__init__.py +37 -8
- esphome/components/media_player/automation.h +11 -2
- esphome/components/media_player/media_player.cpp +8 -0
- esphome/components/media_player/media_player.h +8 -4
- esphome/components/micronova/switch/micronova_switch.cpp +4 -2
- esphome/components/midea/ac_automations.h +3 -1
- esphome/components/midea/air_conditioner.cpp +7 -5
- esphome/components/midea/air_conditioner.h +1 -1
- esphome/components/midea/climate.py +4 -2
- esphome/components/midea/ir_transmitter.h +36 -5
- esphome/components/mixer/__init__.py +0 -0
- esphome/components/mixer/speaker/__init__.py +172 -0
- esphome/components/mixer/speaker/automation.h +19 -0
- esphome/components/mixer/speaker/mixer_speaker.cpp +624 -0
- esphome/components/mixer/speaker/mixer_speaker.h +207 -0
- esphome/components/mpr121/mpr121.h +2 -0
- esphome/components/mqtt/__init__.py +1 -1
- esphome/components/mqtt/mqtt_client.cpp +7 -1
- esphome/components/mqtt/mqtt_client.h +1 -1
- esphome/components/mqtt/mqtt_climate.cpp +2 -2
- esphome/components/network/ip_address.h +2 -0
- esphome/components/nextion/automation.h +17 -0
- esphome/components/nextion/display.py +42 -17
- esphome/components/nextion/nextion.cpp +4 -10
- esphome/components/nextion/nextion.h +89 -82
- esphome/components/nextion/nextion_commands.cpp +10 -10
- esphome/components/ntc/sensor.py +2 -4
- esphome/components/online_image/__init__.py +98 -46
- esphome/components/online_image/bmp_image.cpp +101 -0
- esphome/components/online_image/bmp_image.h +40 -0
- esphome/components/online_image/image_decoder.cpp +28 -2
- esphome/components/online_image/image_decoder.h +24 -15
- esphome/components/online_image/jpeg_image.cpp +90 -0
- esphome/components/online_image/jpeg_image.h +34 -0
- esphome/components/online_image/online_image.cpp +112 -53
- esphome/components/online_image/online_image.h +24 -7
- esphome/components/online_image/png_image.cpp +7 -3
- esphome/components/online_image/png_image.h +2 -1
- esphome/components/opentherm/__init__.py +73 -7
- esphome/components/opentherm/automation.h +25 -0
- esphome/components/opentherm/const.py +1 -0
- esphome/components/opentherm/generate.py +39 -6
- esphome/components/opentherm/hub.cpp +117 -79
- esphome/components/opentherm/hub.h +31 -15
- esphome/components/opentherm/opentherm.cpp +47 -23
- esphome/components/opentherm/opentherm.h +27 -6
- esphome/components/opentherm/opentherm_macros.h +11 -0
- esphome/components/opentherm/schema.py +78 -1
- esphome/components/opentherm/validate.py +7 -2
- esphome/components/pca6416a/pca6416a.h +2 -0
- esphome/components/pca9554/pca9554.h +2 -0
- esphome/components/pcf8574/pcf8574.h +2 -0
- esphome/components/preferences/__init__.py +2 -4
- esphome/components/preferences/syncer.h +10 -3
- esphome/components/prometheus/prometheus_handler.cpp +313 -0
- esphome/components/prometheus/prometheus_handler.h +48 -7
- esphome/components/psram/psram.cpp +8 -1
- esphome/components/pulse_counter/pulse_counter_sensor.cpp +14 -9
- esphome/components/pulse_counter/pulse_counter_sensor.h +4 -4
- esphome/components/pulse_meter/pulse_meter_sensor.cpp +2 -0
- esphome/components/qspi_dbi/__init__.py +3 -0
- esphome/components/qspi_dbi/display.py +74 -47
- esphome/components/qspi_dbi/models.py +245 -2
- esphome/components/qspi_dbi/qspi_dbi.cpp +9 -16
- esphome/components/qspi_dbi/qspi_dbi.h +2 -2
- esphome/components/remote_base/__init__.py +77 -25
- esphome/components/remote_base/remote_base.cpp +1 -1
- esphome/components/remote_base/remote_base.h +20 -2
- esphome/components/remote_base/toto_protocol.cpp +100 -0
- esphome/components/remote_base/toto_protocol.h +45 -0
- esphome/components/remote_receiver/__init__.py +55 -10
- esphome/components/remote_receiver/remote_receiver.h +36 -3
- esphome/components/remote_receiver/remote_receiver_esp32.cpp +145 -6
- esphome/components/remote_transmitter/__init__.py +62 -4
- esphome/components/remote_transmitter/remote_transmitter.h +21 -2
- esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +140 -4
- esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +3 -3
- esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +3 -3
- esphome/components/resampler/__init__.py +0 -0
- esphome/components/resampler/speaker/__init__.py +103 -0
- esphome/components/resampler/speaker/resampler_speaker.cpp +318 -0
- esphome/components/resampler/speaker/resampler_speaker.h +107 -0
- esphome/components/resistance/resistance_sensor.h +2 -3
- esphome/components/resistance/sensor.py +2 -9
- esphome/components/rotary_encoder/rotary_encoder.cpp +8 -4
- esphome/components/rp2040/__init__.py +1 -0
- esphome/components/rp2040/gpio.h +1 -0
- esphome/components/rtl87xx/__init__.py +2 -0
- esphome/components/sdl/binary_sensor.py +270 -0
- esphome/components/sdl/sdl_esphome.cpp +16 -0
- esphome/components/sdl/sdl_esphome.h +9 -0
- esphome/components/seeed_mr60bha2/binary_sensor.py +25 -0
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +26 -2
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +9 -20
- esphome/components/seeed_mr60bha2/sensor.py +9 -1
- esphome/components/sn74hc165/sn74hc165.h +3 -0
- esphome/components/sn74hc595/sn74hc595.h +3 -0
- esphome/components/speaker/__init__.py +5 -4
- esphome/components/speaker/media_player/__init__.py +458 -0
- esphome/components/speaker/media_player/audio_pipeline.cpp +568 -0
- esphome/components/speaker/media_player/audio_pipeline.h +159 -0
- esphome/components/speaker/media_player/automation.h +26 -0
- esphome/components/speaker/media_player/speaker_media_player.cpp +577 -0
- esphome/components/speaker/media_player/speaker_media_player.h +160 -0
- esphome/components/speaker/speaker.h +20 -0
- esphome/components/spi/__init__.py +1 -5
- esphome/components/spi/spi.cpp +7 -1
- esphome/components/spi/spi.h +21 -2
- esphome/components/spi_led_strip/light.py +3 -5
- esphome/components/spi_led_strip/spi_led_strip.cpp +67 -0
- esphome/components/spi_led_strip/spi_led_strip.h +8 -60
- esphome/components/sprinkler/sprinkler.cpp +3 -1
- esphome/components/sx1509/sx1509_gpio_pin.h +2 -0
- esphome/components/tca9555/tca9555.h +2 -0
- esphome/components/toshiba/toshiba.cpp +2 -1
- esphome/components/tuya/light/tuya_light.cpp +4 -2
- esphome/components/uart/uart_component_esp32_arduino.cpp +2 -2
- esphome/components/uart/uart_component_esp_idf.cpp +2 -2
- esphome/components/udp/__init__.py +8 -2
- esphome/components/udp/udp_component.cpp +25 -56
- esphome/components/udp/udp_component.h +3 -0
- esphome/components/uponor_smatrix/sensor/__init__.py +14 -4
- esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp +5 -0
- esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h +1 -0
- esphome/components/uptime/text_sensor/__init__.py +19 -0
- esphome/components/uptime/text_sensor/uptime_text_sensor.cpp +63 -0
- esphome/components/uptime/text_sensor/uptime_text_sensor.h +25 -0
- esphome/components/voice_assistant/voice_assistant.cpp +24 -14
- esphome/components/voice_assistant/voice_assistant.h +8 -0
- esphome/components/waveshare_epaper/display.py +22 -1
- esphome/components/waveshare_epaper/waveshare_213v3.cpp +9 -3
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +1155 -44
- esphome/components/waveshare_epaper/waveshare_epaper.h +208 -7
- esphome/components/web_server/web_server.cpp +28 -6
- esphome/components/weikai/weikai.h +2 -0
- esphome/components/wifi/__init__.py +6 -6
- esphome/components/wifi/wifi_component.cpp +1 -1
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +30 -1
- esphome/components/wireguard/__init__.py +2 -2
- esphome/components/xl9535/xl9535.h +2 -0
- esphome/components/xxtea/__init__.py +3 -0
- esphome/components/xxtea/xxtea.cpp +46 -0
- esphome/components/xxtea/xxtea.h +26 -0
- esphome/components/yashima/yashima.cpp +2 -1
- esphome/config.py +9 -5
- esphome/config_validation.py +55 -17
- esphome/const.py +7 -10
- esphome/core/__init__.py +6 -13
- esphome/core/base_automation.h +1 -0
- esphome/core/config.py +57 -72
- esphome/core/defines.h +9 -1
- esphome/core/gpio.h +7 -0
- esphome/core/helpers.cpp +19 -15
- esphome/core/helpers.h +57 -8
- esphome/core/log.h +9 -7
- esphome/cpp_generator.py +2 -2
- esphome/espota2.py +3 -2
- esphome/loader.py +12 -4
- esphome/log.py +5 -7
- esphome/yaml_util.py +2 -2
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/METADATA +12 -7
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/RECORD +338 -289
- esphome/components/custom/binary_sensor/custom_binary_sensor.cpp +0 -16
- esphome/components/custom/binary_sensor/custom_binary_sensor.h +0 -26
- esphome/components/custom/climate/custom_climate.h +0 -22
- esphome/components/custom/cover/custom_cover.h +0 -21
- esphome/components/custom/light/custom_light_output.h +0 -24
- esphome/components/custom/output/custom_output.h +0 -37
- esphome/components/custom/sensor/custom_sensor.cpp +0 -16
- esphome/components/custom/sensor/custom_sensor.h +0 -24
- esphome/components/custom/switch/custom_switch.cpp +0 -16
- esphome/components/custom/switch/custom_switch.h +0 -24
- esphome/components/custom/text_sensor/custom_text_sensor.cpp +0 -16
- esphome/components/custom/text_sensor/custom_text_sensor.h +0 -26
- esphome/components/custom_component/custom_component.h +0 -28
- esphome/components/esp32_ble_server/ble_2901.cpp +0 -18
- esphome/components/esp32_ble_server/ble_2901.h +0 -19
- esphome/components/resistance_sampler/__init__.py +0 -6
- esphome/components/resistance_sampler/resistance_sampler.h +0 -10
- esphome/components/uptime/{sensor.py → sensor/__init__.py} +3 -3
- /esphome/components/uptime/{uptime_seconds_sensor.cpp → sensor/uptime_seconds_sensor.cpp} +0 -0
- /esphome/components/uptime/{uptime_seconds_sensor.h → sensor/uptime_seconds_sensor.h} +0 -0
- /esphome/components/uptime/{uptime_timestamp_sensor.cpp → sensor/uptime_timestamp_sensor.cpp} +0 -0
- /esphome/components/uptime/{uptime_timestamp_sensor.h → sensor/uptime_timestamp_sensor.h} +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/LICENSE +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/WHEEL +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/entry_points.txt +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/top_level.txt +0 -0
@@ -39,6 +39,7 @@ DisplayOnPageChangeTrigger = display_ns.class_(
|
|
39
39
|
|
40
40
|
CONF_ON_PAGE_CHANGE = "on_page_change"
|
41
41
|
CONF_SHOW_TEST_CARD = "show_test_card"
|
42
|
+
CONF_UNSPECIFIED = "unspecified"
|
42
43
|
|
43
44
|
DISPLAY_ROTATIONS = {
|
44
45
|
0: display_ns.DISPLAY_ROTATION_0_DEGREES,
|
@@ -55,16 +56,22 @@ def validate_rotation(value):
|
|
55
56
|
return cv.enum(DISPLAY_ROTATIONS, int=True)(value)
|
56
57
|
|
57
58
|
|
59
|
+
def validate_auto_clear(value):
|
60
|
+
if value == CONF_UNSPECIFIED:
|
61
|
+
return value
|
62
|
+
return cv.boolean(value)
|
63
|
+
|
64
|
+
|
58
65
|
BASIC_DISPLAY_SCHEMA = cv.Schema(
|
59
66
|
{
|
60
|
-
cv.
|
67
|
+
cv.Exclusive(CONF_LAMBDA, CONF_LAMBDA): cv.lambda_,
|
61
68
|
}
|
62
69
|
).extend(cv.polling_component_schema("1s"))
|
63
70
|
|
64
71
|
FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend(
|
65
72
|
{
|
66
73
|
cv.Optional(CONF_ROTATION): validate_rotation,
|
67
|
-
cv.
|
74
|
+
cv.Exclusive(CONF_PAGES, CONF_LAMBDA): cv.All(
|
68
75
|
cv.ensure_list(
|
69
76
|
{
|
70
77
|
cv.GenerateID(): cv.declare_id(DisplayPage),
|
@@ -82,7 +89,9 @@ FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend(
|
|
82
89
|
cv.Optional(CONF_TO): cv.use_id(DisplayPage),
|
83
90
|
}
|
84
91
|
),
|
85
|
-
cv.Optional(
|
92
|
+
cv.Optional(
|
93
|
+
CONF_AUTO_CLEAR_ENABLED, default=CONF_UNSPECIFIED
|
94
|
+
): validate_auto_clear,
|
86
95
|
cv.Optional(CONF_SHOW_TEST_CARD): cv.boolean,
|
87
96
|
}
|
88
97
|
)
|
@@ -92,8 +101,12 @@ async def setup_display_core_(var, config):
|
|
92
101
|
if CONF_ROTATION in config:
|
93
102
|
cg.add(var.set_rotation(DISPLAY_ROTATIONS[config[CONF_ROTATION]]))
|
94
103
|
|
95
|
-
if CONF_AUTO_CLEAR_ENABLED
|
96
|
-
|
104
|
+
if (auto_clear := config.get(CONF_AUTO_CLEAR_ENABLED)) is not None:
|
105
|
+
# Default to true if pages or lambda is specified. Ideally this would be done during validation, but
|
106
|
+
# the possible schemas are too complex to do this easily.
|
107
|
+
if auto_clear == CONF_UNSPECIFIED:
|
108
|
+
auto_clear = CONF_LAMBDA in config or CONF_PAGES in config
|
109
|
+
cg.add(var.set_auto_clear(auto_clear))
|
97
110
|
|
98
111
|
if CONF_PAGES in config:
|
99
112
|
pages = []
|
@@ -266,8 +266,9 @@ void Display::filled_gauge(int center_x, int center_y, int radius1, int radius2,
|
|
266
266
|
if (dymax < float(-dxmax) * tan_a) {
|
267
267
|
upd_dxmax = ceil(float(dymax) / tan_a);
|
268
268
|
hline_width = -dxmax - upd_dxmax + 1;
|
269
|
-
} else
|
269
|
+
} else {
|
270
270
|
hline_width = 0;
|
271
|
+
}
|
271
272
|
}
|
272
273
|
if (hline_width > 0)
|
273
274
|
this->horizontal_line(center_x + dxmax, center_y - dymax, hline_width, color);
|
@@ -90,8 +90,9 @@ void Rect::info(const std::string &prefix) {
|
|
90
90
|
if (this->is_set()) {
|
91
91
|
ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d] (%3d,%3d)", prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(),
|
92
92
|
this->y2());
|
93
|
-
} else
|
93
|
+
} else {
|
94
94
|
ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str());
|
95
|
+
}
|
95
96
|
}
|
96
97
|
|
97
98
|
} // namespace display
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import i2c
|
3
|
+
from esphome.components.audio_adc import AudioAdc
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE
|
6
|
+
|
7
|
+
CODEOWNERS = ["@kahrendt"]
|
8
|
+
DEPENDENCIES = ["i2c"]
|
9
|
+
|
10
|
+
es7210_ns = cg.esphome_ns.namespace("es7210")
|
11
|
+
ES7210 = es7210_ns.class_("ES7210", AudioAdc, cg.Component, i2c.I2CDevice)
|
12
|
+
|
13
|
+
|
14
|
+
es7210_bits_per_sample = es7210_ns.enum("ES7210BitsPerSample")
|
15
|
+
ES7210_BITS_PER_SAMPLE_ENUM = {
|
16
|
+
16: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_16,
|
17
|
+
24: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_24,
|
18
|
+
32: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_32,
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
ES7210_MIC_GAINS = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 34.5, 36, 37.5]
|
23
|
+
|
24
|
+
_validate_bits = cv.float_with_unit("bits", "bit")
|
25
|
+
|
26
|
+
CONFIG_SCHEMA = (
|
27
|
+
cv.Schema(
|
28
|
+
{
|
29
|
+
cv.GenerateID(): cv.declare_id(ES7210),
|
30
|
+
cv.Optional(CONF_BITS_PER_SAMPLE, default="16bit"): cv.All(
|
31
|
+
_validate_bits, cv.enum(ES7210_BITS_PER_SAMPLE_ENUM)
|
32
|
+
),
|
33
|
+
cv.Optional(CONF_MIC_GAIN, default="24db"): cv.All(
|
34
|
+
cv.decibel, cv.one_of(*ES7210_MIC_GAINS)
|
35
|
+
),
|
36
|
+
cv.Optional(CONF_SAMPLE_RATE, default=16000): cv.int_range(min=1),
|
37
|
+
}
|
38
|
+
)
|
39
|
+
.extend(cv.COMPONENT_SCHEMA)
|
40
|
+
.extend(i2c.i2c_device_schema(0x40))
|
41
|
+
)
|
42
|
+
|
43
|
+
|
44
|
+
async def to_code(config):
|
45
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
46
|
+
await cg.register_component(var, config)
|
47
|
+
await i2c.register_i2c_device(var, config)
|
48
|
+
|
49
|
+
cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE]))
|
50
|
+
cg.add(var.set_mic_gain(config[CONF_MIC_GAIN]))
|
51
|
+
cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE]))
|
@@ -0,0 +1,228 @@
|
|
1
|
+
#include "es7210.h"
|
2
|
+
#include "es7210_const.h"
|
3
|
+
#include "esphome/core/hal.h"
|
4
|
+
#include "esphome/core/log.h"
|
5
|
+
#include <cinttypes>
|
6
|
+
|
7
|
+
namespace esphome {
|
8
|
+
namespace es7210 {
|
9
|
+
|
10
|
+
static const char *const TAG = "es7210";
|
11
|
+
|
12
|
+
static const size_t MCLK_DIV_FRE = 256;
|
13
|
+
|
14
|
+
// Mark the component as failed; use only in setup
|
15
|
+
#define ES7210_ERROR_FAILED(func) \
|
16
|
+
if (!(func)) { \
|
17
|
+
this->mark_failed(); \
|
18
|
+
return; \
|
19
|
+
}
|
20
|
+
|
21
|
+
// Return false; use outside of setup
|
22
|
+
#define ES7210_ERROR_CHECK(func) \
|
23
|
+
if (!(func)) { \
|
24
|
+
return false; \
|
25
|
+
}
|
26
|
+
|
27
|
+
void ES7210::dump_config() {
|
28
|
+
ESP_LOGCONFIG(TAG, "ES7210 audio ADC:");
|
29
|
+
ESP_LOGCONFIG(TAG, " Bits Per Sample: %" PRIu8, this->bits_per_sample_);
|
30
|
+
ESP_LOGCONFIG(TAG, " Sample Rate: %" PRIu32, this->sample_rate_);
|
31
|
+
|
32
|
+
if (this->is_failed()) {
|
33
|
+
ESP_LOGE(TAG, " Failed to initialize");
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
void ES7210::setup() {
|
39
|
+
ESP_LOGCONFIG(TAG, "Setting up ES7210...");
|
40
|
+
|
41
|
+
// Software reset
|
42
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0xff));
|
43
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x32));
|
44
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_CLOCK_OFF_REG01, 0x3f));
|
45
|
+
|
46
|
+
// Set initialization time when device powers up
|
47
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_TIME_CONTROL0_REG09, 0x30));
|
48
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_TIME_CONTROL1_REG0A, 0x30));
|
49
|
+
|
50
|
+
// Configure HFP for all ADC channels
|
51
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC12_HPF2_REG23, 0x2a));
|
52
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC12_HPF1_REG22, 0x0a));
|
53
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC34_HPF2_REG20, 0x0a));
|
54
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC34_HPF1_REG21, 0x2a));
|
55
|
+
|
56
|
+
// Secondary I2S mode settings
|
57
|
+
ES7210_ERROR_FAILED(this->es7210_update_reg_bit_(ES7210_MODE_CONFIG_REG08, 0x01, 0x00));
|
58
|
+
|
59
|
+
// Configure analog power
|
60
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_ANALOG_REG40, 0xC3));
|
61
|
+
|
62
|
+
// Set mic bias
|
63
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC12_BIAS_REG41, 0x70));
|
64
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC34_BIAS_REG42, 0x70));
|
65
|
+
|
66
|
+
// Configure I2S settings, sample rate, and microphone gains
|
67
|
+
ES7210_ERROR_FAILED(this->configure_i2s_format_());
|
68
|
+
ES7210_ERROR_FAILED(this->configure_sample_rate_());
|
69
|
+
ES7210_ERROR_FAILED(this->configure_mic_gain_());
|
70
|
+
|
71
|
+
// Power on mics 1 through 4
|
72
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC1_POWER_REG47, 0x08));
|
73
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC2_POWER_REG48, 0x08));
|
74
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC3_POWER_REG49, 0x08));
|
75
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC4_POWER_REG4A, 0x08));
|
76
|
+
|
77
|
+
// Power down DLL
|
78
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_POWER_DOWN_REG06, 0x04));
|
79
|
+
|
80
|
+
// Power on MIC1-4 bias & ADC1-4 & PGA1-4 Power
|
81
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x0F));
|
82
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x0F));
|
83
|
+
|
84
|
+
// Enable device
|
85
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x71));
|
86
|
+
ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x41));
|
87
|
+
|
88
|
+
this->setup_complete_ = true;
|
89
|
+
}
|
90
|
+
|
91
|
+
bool ES7210::set_mic_gain(float mic_gain) {
|
92
|
+
this->mic_gain_ = clamp<float>(mic_gain, ES7210_MIC_GAIN_MIN, ES7210_MIC_GAIN_MAX);
|
93
|
+
if (this->setup_complete_) {
|
94
|
+
return this->configure_mic_gain_();
|
95
|
+
}
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
|
99
|
+
bool ES7210::configure_sample_rate_() {
|
100
|
+
int mclk_fre = this->sample_rate_ * MCLK_DIV_FRE;
|
101
|
+
int coeff = -1;
|
102
|
+
|
103
|
+
for (int i = 0; i < (sizeof(ES7210_COEFFICIENTS) / sizeof(ES7210_COEFFICIENTS[0])); ++i) {
|
104
|
+
if (ES7210_COEFFICIENTS[i].lrclk == this->sample_rate_ && ES7210_COEFFICIENTS[i].mclk == mclk_fre)
|
105
|
+
coeff = i;
|
106
|
+
}
|
107
|
+
|
108
|
+
if (coeff >= 0) {
|
109
|
+
// Set adc_div & doubler & dll
|
110
|
+
uint8_t regv;
|
111
|
+
ES7210_ERROR_CHECK(this->read_byte(ES7210_MAINCLK_REG02, ®v));
|
112
|
+
regv = regv & 0x00;
|
113
|
+
regv |= ES7210_COEFFICIENTS[coeff].adc_div;
|
114
|
+
regv |= ES7210_COEFFICIENTS[coeff].doubler << 6;
|
115
|
+
regv |= ES7210_COEFFICIENTS[coeff].dll << 7;
|
116
|
+
|
117
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MAINCLK_REG02, regv));
|
118
|
+
|
119
|
+
// Set osr
|
120
|
+
regv = ES7210_COEFFICIENTS[coeff].osr;
|
121
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_OSR_REG07, regv));
|
122
|
+
// Set lrck
|
123
|
+
regv = ES7210_COEFFICIENTS[coeff].lrck_h;
|
124
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_LRCK_DIVH_REG04, regv));
|
125
|
+
regv = ES7210_COEFFICIENTS[coeff].lrck_l;
|
126
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_LRCK_DIVL_REG05, regv));
|
127
|
+
} else {
|
128
|
+
// Invalid sample frequency
|
129
|
+
ESP_LOGE(TAG, "Invalid sample rate");
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
|
133
|
+
return true;
|
134
|
+
}
|
135
|
+
|
136
|
+
bool ES7210::configure_mic_gain_() {
|
137
|
+
auto regv = this->es7210_gain_reg_value_(this->mic_gain_);
|
138
|
+
for (uint8_t i = 0; i < 4; ++i) {
|
139
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43 + i, 0x10, 0x00));
|
140
|
+
}
|
141
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0xff));
|
142
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0xff));
|
143
|
+
|
144
|
+
// Configure mic 1
|
145
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
|
146
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00));
|
147
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x10, 0x10));
|
148
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x0f, regv));
|
149
|
+
|
150
|
+
// Configure mic 2
|
151
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
|
152
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00));
|
153
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x10, 0x10));
|
154
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x0f, regv));
|
155
|
+
|
156
|
+
// Configure mic 3
|
157
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
|
158
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00));
|
159
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x10, 0x10));
|
160
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x0f, regv));
|
161
|
+
|
162
|
+
// Configure mic 4
|
163
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00));
|
164
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00));
|
165
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x10, 0x10));
|
166
|
+
ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x0f, regv));
|
167
|
+
|
168
|
+
return true;
|
169
|
+
}
|
170
|
+
|
171
|
+
uint8_t ES7210::es7210_gain_reg_value_(float mic_gain) {
|
172
|
+
// reg: 12 - 34.5dB, 13 - 36dB, 14 - 37.5dB
|
173
|
+
mic_gain += 0.5;
|
174
|
+
if (mic_gain <= 33.0) {
|
175
|
+
return (uint8_t) mic_gain / 3;
|
176
|
+
}
|
177
|
+
if (mic_gain < 36.0) {
|
178
|
+
return 12;
|
179
|
+
}
|
180
|
+
if (mic_gain < 37.0) {
|
181
|
+
return 13;
|
182
|
+
}
|
183
|
+
return 14;
|
184
|
+
}
|
185
|
+
|
186
|
+
bool ES7210::configure_i2s_format_() {
|
187
|
+
// Configure bits per sample
|
188
|
+
uint8_t reg_val = 0;
|
189
|
+
switch (this->bits_per_sample_) {
|
190
|
+
case ES7210_BITS_PER_SAMPLE_16:
|
191
|
+
reg_val = 0x60;
|
192
|
+
break;
|
193
|
+
case ES7210_BITS_PER_SAMPLE_18:
|
194
|
+
reg_val = 0x40;
|
195
|
+
break;
|
196
|
+
case ES7210_BITS_PER_SAMPLE_20:
|
197
|
+
reg_val = 0x20;
|
198
|
+
break;
|
199
|
+
case ES7210_BITS_PER_SAMPLE_24:
|
200
|
+
reg_val = 0x00;
|
201
|
+
break;
|
202
|
+
case ES7210_BITS_PER_SAMPLE_32:
|
203
|
+
reg_val = 0x80;
|
204
|
+
break;
|
205
|
+
default:
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE1_REG11, reg_val));
|
209
|
+
|
210
|
+
if (this->enable_tdm_) {
|
211
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE2_REG12, 0x02));
|
212
|
+
} else {
|
213
|
+
// Microphones 1 and 2 output on SDOUT1, microphones 3 and 4 output on SDOUT2
|
214
|
+
ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE2_REG12, 0x00));
|
215
|
+
}
|
216
|
+
|
217
|
+
return true;
|
218
|
+
}
|
219
|
+
|
220
|
+
bool ES7210::es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data) {
|
221
|
+
uint8_t regv;
|
222
|
+
ES7210_ERROR_CHECK(this->read_byte(reg_addr, ®v));
|
223
|
+
regv = (regv & (~update_bits)) | (update_bits & data);
|
224
|
+
return this->write_byte(reg_addr, regv);
|
225
|
+
}
|
226
|
+
|
227
|
+
} // namespace es7210
|
228
|
+
} // namespace esphome
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/components/audio_adc/audio_adc.h"
|
4
|
+
#include "esphome/components/i2c/i2c.h"
|
5
|
+
#include "esphome/core/component.h"
|
6
|
+
|
7
|
+
#include "es7210_const.h"
|
8
|
+
|
9
|
+
namespace esphome {
|
10
|
+
namespace es7210 {
|
11
|
+
|
12
|
+
enum ES7210BitsPerSample : uint8_t {
|
13
|
+
ES7210_BITS_PER_SAMPLE_16 = 16,
|
14
|
+
ES7210_BITS_PER_SAMPLE_18 = 18,
|
15
|
+
ES7210_BITS_PER_SAMPLE_20 = 20,
|
16
|
+
ES7210_BITS_PER_SAMPLE_24 = 24,
|
17
|
+
ES7210_BITS_PER_SAMPLE_32 = 32,
|
18
|
+
};
|
19
|
+
|
20
|
+
class ES7210 : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice {
|
21
|
+
/* Class for configuring an ES7210 ADC for microphone input.
|
22
|
+
* Based on code from:
|
23
|
+
* - https://github.com/espressif/esp-bsp/ (accessed 20241219)
|
24
|
+
* - https://github.com/espressif/esp-adf/ (accessed 20241219)
|
25
|
+
*/
|
26
|
+
public:
|
27
|
+
void setup() override;
|
28
|
+
float get_setup_priority() const override { return setup_priority::DATA; }
|
29
|
+
void dump_config() override;
|
30
|
+
|
31
|
+
void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; }
|
32
|
+
bool set_mic_gain(float mic_gain) override;
|
33
|
+
void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; }
|
34
|
+
|
35
|
+
float mic_gain() override { return this->mic_gain_; };
|
36
|
+
|
37
|
+
protected:
|
38
|
+
/// @brief Updates an I2C registry address by modifying the current state
|
39
|
+
/// @param reg_addr I2C register address
|
40
|
+
/// @param update_bits Mask of allowed bits to be modified
|
41
|
+
/// @param data Bit values to be written
|
42
|
+
/// @return True if successful, false otherwise
|
43
|
+
bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data);
|
44
|
+
|
45
|
+
/// @brief Convert floating point mic gain value to register value
|
46
|
+
/// @param mic_gain Gain value to convert
|
47
|
+
/// @return Corresponding register value for specified gain
|
48
|
+
uint8_t es7210_gain_reg_value_(float mic_gain);
|
49
|
+
|
50
|
+
bool configure_i2s_format_();
|
51
|
+
bool configure_mic_gain_();
|
52
|
+
bool configure_sample_rate_();
|
53
|
+
|
54
|
+
bool setup_complete_{false};
|
55
|
+
bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12
|
56
|
+
float mic_gain_{0};
|
57
|
+
ES7210BitsPerSample bits_per_sample_{ES7210_BITS_PER_SAMPLE_16};
|
58
|
+
uint32_t sample_rate_{0};
|
59
|
+
};
|
60
|
+
|
61
|
+
} // namespace es7210
|
62
|
+
} // namespace esphome
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <cinttypes>
|
4
|
+
|
5
|
+
namespace esphome {
|
6
|
+
namespace es7210 {
|
7
|
+
|
8
|
+
// ES7210 register addresses
|
9
|
+
static const uint8_t ES7210_RESET_REG00 = 0x00; /* Reset control */
|
10
|
+
static const uint8_t ES7210_CLOCK_OFF_REG01 = 0x01; /* Used to turn off the ADC clock */
|
11
|
+
static const uint8_t ES7210_MAINCLK_REG02 = 0x02; /* Set ADC clock frequency division */
|
12
|
+
|
13
|
+
static const uint8_t ES7210_MASTER_CLK_REG03 = 0x03; /* MCLK source $ SCLK division */
|
14
|
+
static const uint8_t ES7210_LRCK_DIVH_REG04 = 0x04; /* lrck_divh */
|
15
|
+
static const uint8_t ES7210_LRCK_DIVL_REG05 = 0x05; /* lrck_divl */
|
16
|
+
static const uint8_t ES7210_POWER_DOWN_REG06 = 0x06; /* power down */
|
17
|
+
static const uint8_t ES7210_OSR_REG07 = 0x07;
|
18
|
+
static const uint8_t ES7210_MODE_CONFIG_REG08 = 0x08; /* Set primary/secondary & channels */
|
19
|
+
static const uint8_t ES7210_TIME_CONTROL0_REG09 = 0x09; /* Set Chip intial state period*/
|
20
|
+
static const uint8_t ES7210_TIME_CONTROL1_REG0A = 0x0A; /* Set Power up state period */
|
21
|
+
static const uint8_t ES7210_SDP_INTERFACE1_REG11 = 0x11; /* Set sample & fmt */
|
22
|
+
static const uint8_t ES7210_SDP_INTERFACE2_REG12 = 0x12; /* Pins state */
|
23
|
+
static const uint8_t ES7210_ADC_AUTOMUTE_REG13 = 0x13; /* Set mute */
|
24
|
+
static const uint8_t ES7210_ADC34_MUTERANGE_REG14 = 0x14; /* Set mute range */
|
25
|
+
static const uint8_t ES7210_ADC12_MUTERANGE_REG15 = 0x15; /* Set mute range */
|
26
|
+
static const uint8_t ES7210_ADC34_HPF2_REG20 = 0x20; /* HPF */
|
27
|
+
static const uint8_t ES7210_ADC34_HPF1_REG21 = 0x21; /* HPF */
|
28
|
+
static const uint8_t ES7210_ADC12_HPF1_REG22 = 0x22; /* HPF */
|
29
|
+
static const uint8_t ES7210_ADC12_HPF2_REG23 = 0x23; /* HPF */
|
30
|
+
static const uint8_t ES7210_ANALOG_REG40 = 0x40; /* ANALOG Power */
|
31
|
+
static const uint8_t ES7210_MIC12_BIAS_REG41 = 0x41;
|
32
|
+
static const uint8_t ES7210_MIC34_BIAS_REG42 = 0x42;
|
33
|
+
static const uint8_t ES7210_MIC1_GAIN_REG43 = 0x43;
|
34
|
+
static const uint8_t ES7210_MIC2_GAIN_REG44 = 0x44;
|
35
|
+
static const uint8_t ES7210_MIC3_GAIN_REG45 = 0x45;
|
36
|
+
static const uint8_t ES7210_MIC4_GAIN_REG46 = 0x46;
|
37
|
+
static const uint8_t ES7210_MIC1_POWER_REG47 = 0x47;
|
38
|
+
static const uint8_t ES7210_MIC2_POWER_REG48 = 0x48;
|
39
|
+
static const uint8_t ES7210_MIC3_POWER_REG49 = 0x49;
|
40
|
+
static const uint8_t ES7210_MIC4_POWER_REG4A = 0x4A;
|
41
|
+
static const uint8_t ES7210_MIC12_POWER_REG4B = 0x4B; /* MICBias & ADC & PGA Power */
|
42
|
+
static const uint8_t ES7210_MIC34_POWER_REG4C = 0x4C;
|
43
|
+
|
44
|
+
/*
|
45
|
+
* Clock coefficient structure
|
46
|
+
*/
|
47
|
+
struct ES7210Coefficient {
|
48
|
+
uint32_t mclk; // mclk frequency
|
49
|
+
uint32_t lrclk;
|
50
|
+
uint8_t ss_ds;
|
51
|
+
uint8_t adc_div;
|
52
|
+
uint8_t dll; // dll_bypass
|
53
|
+
uint8_t doubler; // doubler_enable
|
54
|
+
uint8_t osr; // adc osr
|
55
|
+
uint8_t mclk_src; // sselect mclk source
|
56
|
+
uint8_t lrck_h; // High 4 bits of lrck
|
57
|
+
uint8_t lrck_l; // Low 8 bits of lrck
|
58
|
+
};
|
59
|
+
|
60
|
+
/* Codec hifi mclk clock divider coefficients
|
61
|
+
* MEMBER REG
|
62
|
+
* mclk: 0x03
|
63
|
+
* lrck: standard
|
64
|
+
* ss_ds: --
|
65
|
+
* adc_div: 0x02
|
66
|
+
* dll: 0x06
|
67
|
+
* doubler: 0x02
|
68
|
+
* osr: 0x07
|
69
|
+
* mclk_src: 0x03
|
70
|
+
* lrckh: 0x04
|
71
|
+
* lrckl: 0x05
|
72
|
+
*/
|
73
|
+
static const ES7210Coefficient ES7210_COEFFICIENTS[] = {
|
74
|
+
// mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl
|
75
|
+
/* 8k */
|
76
|
+
{12288000, 8000, 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00},
|
77
|
+
{16384000, 8000, 0x00, 0x04, 0x01, 0x00, 0x20, 0x00, 0x08, 0x00},
|
78
|
+
{19200000, 8000, 0x00, 0x1e, 0x00, 0x01, 0x28, 0x00, 0x09, 0x60},
|
79
|
+
{4096000, 8000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
80
|
+
|
81
|
+
/* 11.025k */
|
82
|
+
{11289600, 11025, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
|
83
|
+
|
84
|
+
/* 12k */
|
85
|
+
{12288000, 12000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
|
86
|
+
{19200000, 12000, 0x00, 0x14, 0x00, 0x01, 0x28, 0x00, 0x06, 0x40},
|
87
|
+
|
88
|
+
/* 16k */
|
89
|
+
{4096000, 16000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
|
90
|
+
{19200000, 16000, 0x00, 0x0a, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x80},
|
91
|
+
{16384000, 16000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
|
92
|
+
{12288000, 16000, 0x00, 0x03, 0x01, 0x01, 0x20, 0x00, 0x03, 0x00},
|
93
|
+
|
94
|
+
/* 22.05k */
|
95
|
+
{11289600, 22050, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
96
|
+
|
97
|
+
/* 24k */
|
98
|
+
{12288000, 24000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
99
|
+
{19200000, 24000, 0x00, 0x0a, 0x00, 0x01, 0x28, 0x00, 0x03, 0x20},
|
100
|
+
|
101
|
+
/* 32k */
|
102
|
+
{12288000, 32000, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x01, 0x80},
|
103
|
+
{16384000, 32000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
104
|
+
{19200000, 32000, 0x00, 0x05, 0x00, 0x00, 0x1e, 0x00, 0x02, 0x58},
|
105
|
+
|
106
|
+
/* 44.1k */
|
107
|
+
{11289600, 44100, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
|
108
|
+
|
109
|
+
/* 48k */
|
110
|
+
{12288000, 48000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
|
111
|
+
{19200000, 48000, 0x00, 0x05, 0x00, 0x01, 0x28, 0x00, 0x01, 0x90},
|
112
|
+
|
113
|
+
/* 64k */
|
114
|
+
{16384000, 64000, 0x01, 0x01, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
|
115
|
+
{19200000, 64000, 0x00, 0x05, 0x00, 0x01, 0x1e, 0x00, 0x01, 0x2c},
|
116
|
+
|
117
|
+
/* 88.2k */
|
118
|
+
{11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
|
119
|
+
|
120
|
+
/* 96k */
|
121
|
+
{12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
|
122
|
+
{19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8},
|
123
|
+
};
|
124
|
+
|
125
|
+
static const float ES7210_MIC_GAIN_MIN = 0.0;
|
126
|
+
static const float ES7210_MIC_GAIN_MAX = 37.5;
|
127
|
+
|
128
|
+
} // namespace es7210
|
129
|
+
} // namespace esphome
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import i2c
|
3
|
+
from esphome.components.audio_adc import AudioAdc
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import CONF_ID, CONF_MIC_GAIN
|
6
|
+
|
7
|
+
CODEOWNERS = ["@kbx81"]
|
8
|
+
DEPENDENCIES = ["i2c"]
|
9
|
+
|
10
|
+
es7243e_ns = cg.esphome_ns.namespace("es7243e")
|
11
|
+
ES7243E = es7243e_ns.class_("ES7243E", AudioAdc, cg.Component, i2c.I2CDevice)
|
12
|
+
|
13
|
+
ES7243E_MIC_GAINS = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 34.5, 36, 37.5]
|
14
|
+
|
15
|
+
CONFIG_SCHEMA = (
|
16
|
+
cv.Schema(
|
17
|
+
{
|
18
|
+
cv.GenerateID(): cv.declare_id(ES7243E),
|
19
|
+
cv.Optional(CONF_MIC_GAIN, default="24db"): cv.All(
|
20
|
+
cv.decibel, cv.one_of(*ES7243E_MIC_GAINS)
|
21
|
+
),
|
22
|
+
}
|
23
|
+
)
|
24
|
+
.extend(cv.COMPONENT_SCHEMA)
|
25
|
+
.extend(i2c.i2c_device_schema(0x10))
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
async def to_code(config):
|
30
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
31
|
+
await cg.register_component(var, config)
|
32
|
+
await i2c.register_i2c_device(var, config)
|
33
|
+
|
34
|
+
cg.add(var.set_mic_gain(config[CONF_MIC_GAIN]))
|