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
@@ -0,0 +1,207 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#ifdef USE_ESP32
|
4
|
+
|
5
|
+
#include "esphome/components/audio/audio.h"
|
6
|
+
#include "esphome/components/audio/audio_transfer_buffer.h"
|
7
|
+
#include "esphome/components/speaker/speaker.h"
|
8
|
+
|
9
|
+
#include "esphome/core/component.h"
|
10
|
+
|
11
|
+
#include <freertos/event_groups.h>
|
12
|
+
#include <freertos/FreeRTOS.h>
|
13
|
+
|
14
|
+
namespace esphome {
|
15
|
+
namespace mixer_speaker {
|
16
|
+
|
17
|
+
/* Classes for mixing several source speaker audio streams and writing it to another speaker component.
|
18
|
+
* - Volume controls are passed through to the output speaker
|
19
|
+
* - Directly handles pausing at the SourceSpeaker level; pause state is not passed through to the output speaker.
|
20
|
+
* - Audio sent to the SourceSpeaker's must have 16 bits per sample.
|
21
|
+
* - Audio sent to the SourceSpeaker can have any number of channels. They are duplicated or ignored as needed to match
|
22
|
+
* the number of channels required for the output speaker.
|
23
|
+
* - In queue mode, the audio sent to the SoureSpeakers can have different sample rates.
|
24
|
+
* - In non-queue mode, the audio sent to the SourceSpeakers must have the same sample rates.
|
25
|
+
* - SourceSpeaker has an internal ring buffer. It also allocates a shared_ptr for an AudioTranserBuffer object.
|
26
|
+
* - Audio Data Flow:
|
27
|
+
* - Audio data played on a SourceSpeaker first writes to its internal ring buffer.
|
28
|
+
* - MixerSpeaker task temporarily takes shared ownership of each SourceSpeaker's AudioTransferBuffer.
|
29
|
+
* - MixerSpeaker calls SourceSpeaker's `process_data_from_source`, which tranfers audio from the SourceSpeaker's
|
30
|
+
* ring buffer to its AudioTransferBuffer. Audio ducking is applied at this step.
|
31
|
+
* - In queue mode, MixerSpeaker prioritizes the earliest configured SourceSpeaker with audio data. Audio data is
|
32
|
+
* sent to the output speaker.
|
33
|
+
* - In non-queue mode, MixerSpeaker adds all the audio data in each SourceSpeaker into one stream that is written
|
34
|
+
* to the output speaker.
|
35
|
+
*/
|
36
|
+
|
37
|
+
class MixerSpeaker;
|
38
|
+
|
39
|
+
class SourceSpeaker : public speaker::Speaker, public Component {
|
40
|
+
public:
|
41
|
+
void dump_config() override;
|
42
|
+
void setup() override;
|
43
|
+
void loop() override;
|
44
|
+
|
45
|
+
size_t play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) override;
|
46
|
+
size_t play(const uint8_t *data, size_t length) override { return this->play(data, length, 0); }
|
47
|
+
|
48
|
+
void start() override;
|
49
|
+
void stop() override;
|
50
|
+
void finish() override;
|
51
|
+
|
52
|
+
bool has_buffered_data() const override;
|
53
|
+
|
54
|
+
/// @brief Mute state changes are passed to the parent's output speaker
|
55
|
+
void set_mute_state(bool mute_state) override;
|
56
|
+
|
57
|
+
/// @brief Volume state changes are passed to the parent's output speaker
|
58
|
+
void set_volume(float volume) override;
|
59
|
+
|
60
|
+
void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; }
|
61
|
+
bool get_pause_state() const override { return this->pause_state_; }
|
62
|
+
|
63
|
+
/// @brief Transfers audio from the ring buffer into the transfer buffer. Ducks audio while transferring.
|
64
|
+
/// @param ticks_to_wait FreeRTOS ticks to wait while waiting to read from the ring buffer.
|
65
|
+
/// @return Number of bytes transferred from the ring buffer.
|
66
|
+
size_t process_data_from_source(TickType_t ticks_to_wait);
|
67
|
+
|
68
|
+
/// @brief Sets the ducking level for the source speaker.
|
69
|
+
/// @param decibel_reduction (uint8_t) The dB reduction level. For example, 0 is no change, 10 is a reduction by 10 dB
|
70
|
+
/// @param duration (uint32_t) The number of milliseconds to transition from the current level to the new level
|
71
|
+
void apply_ducking(uint8_t decibel_reduction, uint32_t duration);
|
72
|
+
|
73
|
+
void set_buffer_duration(uint32_t buffer_duration_ms) { this->buffer_duration_ms_ = buffer_duration_ms; }
|
74
|
+
void set_parent(MixerSpeaker *parent) { this->parent_ = parent; }
|
75
|
+
void set_timeout(uint32_t ms) { this->timeout_ms_ = ms; }
|
76
|
+
|
77
|
+
std::weak_ptr<audio::AudioSourceTransferBuffer> get_transfer_buffer() { return this->transfer_buffer_; }
|
78
|
+
|
79
|
+
protected:
|
80
|
+
friend class MixerSpeaker;
|
81
|
+
esp_err_t start_();
|
82
|
+
void stop_();
|
83
|
+
|
84
|
+
/// @brief Ducks audio samples by a specified amount. When changing the ducking amount, it can transition gradually
|
85
|
+
/// over a specified amount of samples.
|
86
|
+
/// @param input_buffer buffer with audio samples to be ducked in place
|
87
|
+
/// @param input_samples_to_duck number of samples to process in ``input_buffer``
|
88
|
+
/// @param current_ducking_db_reduction pointer to the current dB reduction
|
89
|
+
/// @param ducking_transition_samples_remaining pointer to the total number of samples left before the the
|
90
|
+
/// transition is finished
|
91
|
+
/// @param samples_per_ducking_step total number of samples per ducking step for the transition
|
92
|
+
/// @param db_change_per_ducking_step the change in dB reduction per step
|
93
|
+
static void duck_samples(int16_t *input_buffer, uint32_t input_samples_to_duck, int8_t *current_ducking_db_reduction,
|
94
|
+
uint32_t *ducking_transition_samples_remaining, uint32_t samples_per_ducking_step,
|
95
|
+
int8_t db_change_per_ducking_step);
|
96
|
+
|
97
|
+
MixerSpeaker *parent_;
|
98
|
+
|
99
|
+
std::shared_ptr<audio::AudioSourceTransferBuffer> transfer_buffer_;
|
100
|
+
std::weak_ptr<RingBuffer> ring_buffer_;
|
101
|
+
|
102
|
+
uint32_t buffer_duration_ms_;
|
103
|
+
uint32_t last_seen_data_ms_{0};
|
104
|
+
optional<uint32_t> timeout_ms_;
|
105
|
+
bool stop_gracefully_{false};
|
106
|
+
|
107
|
+
bool pause_state_{false};
|
108
|
+
|
109
|
+
int8_t target_ducking_db_reduction_{0};
|
110
|
+
int8_t current_ducking_db_reduction_{0};
|
111
|
+
int8_t db_change_per_ducking_step_{1};
|
112
|
+
uint32_t ducking_transition_samples_remaining_{0};
|
113
|
+
uint32_t samples_per_ducking_step_{0};
|
114
|
+
|
115
|
+
uint32_t accumulated_frames_read_{0};
|
116
|
+
|
117
|
+
uint32_t pending_playback_ms_{0};
|
118
|
+
};
|
119
|
+
|
120
|
+
class MixerSpeaker : public Component {
|
121
|
+
public:
|
122
|
+
void dump_config() override;
|
123
|
+
void setup() override;
|
124
|
+
void loop() override;
|
125
|
+
|
126
|
+
void add_source_speaker(SourceSpeaker *source_speaker) { this->source_speakers_.push_back(source_speaker); }
|
127
|
+
|
128
|
+
/// @brief Starts the mixer task. Called by a source speaker giving the current audio stream information
|
129
|
+
/// @param stream_info The calling source speakers audio stream information
|
130
|
+
/// @return ESP_ERR_NOT_SUPPORTED if the incoming stream is incompatible due to unsupported bits per sample
|
131
|
+
/// ESP_ERR_INVALID_ARG if the incoming stream is incompatible to be mixed with the other input audio stream
|
132
|
+
/// ESP_ERR_NO_MEM if there isn't enough memory for the task's stack
|
133
|
+
/// ESP_ERR_INVALID_STATE if the task fails to start
|
134
|
+
/// ESP_OK if the incoming stream is compatible and the mixer task starts
|
135
|
+
esp_err_t start(audio::AudioStreamInfo &stream_info);
|
136
|
+
|
137
|
+
void stop();
|
138
|
+
|
139
|
+
void set_output_channels(uint8_t output_channels) { this->output_channels_ = output_channels; }
|
140
|
+
void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; }
|
141
|
+
void set_queue_mode(bool queue_mode) { this->queue_mode_ = queue_mode; }
|
142
|
+
void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; }
|
143
|
+
|
144
|
+
speaker::Speaker *get_output_speaker() const { return this->output_speaker_; }
|
145
|
+
|
146
|
+
protected:
|
147
|
+
/// @brief Copies audio frames from the input buffer to the output buffer taking into account the number of channels
|
148
|
+
/// in each stream. If the output stream has more channels, the input samples are duplicated. If the output stream has
|
149
|
+
/// less channels, the extra channel input samples are dropped.
|
150
|
+
/// @param input_buffer
|
151
|
+
/// @param input_stream_info
|
152
|
+
/// @param output_buffer
|
153
|
+
/// @param output_stream_info
|
154
|
+
/// @param frames_to_transfer number of frames (consisting of a sample for each channel) to copy from the input buffer
|
155
|
+
static void copy_frames(const int16_t *input_buffer, audio::AudioStreamInfo input_stream_info, int16_t *output_buffer,
|
156
|
+
audio::AudioStreamInfo output_stream_info, uint32_t frames_to_transfer);
|
157
|
+
|
158
|
+
/// @brief Mixes the primary and secondary streams taking into account the number of channels in each stream. Primary
|
159
|
+
/// and secondary samples are duplicated or dropped as necessary to ensure the output stream has the configured number
|
160
|
+
/// of channels. Output samples are clamped to the corresponding int16 min or max values if the mixed sample
|
161
|
+
/// overflows.
|
162
|
+
/// @param primary_buffer (int16_t *) samples buffer for the primary stream
|
163
|
+
/// @param primary_stream_info stream info for the primary stream
|
164
|
+
/// @param secondary_buffer (int16_t *) samples buffer for secondary stream
|
165
|
+
/// @param secondary_stream_info stream info for the secondary stream
|
166
|
+
/// @param output_buffer (int16_t *) buffer for the mixed samples
|
167
|
+
/// @param output_stream_info stream info for the output buffer
|
168
|
+
/// @param frames_to_mix number of frames in the primary and secondary buffers to mix together
|
169
|
+
static void mix_audio_samples(const int16_t *primary_buffer, audio::AudioStreamInfo primary_stream_info,
|
170
|
+
const int16_t *secondary_buffer, audio::AudioStreamInfo secondary_stream_info,
|
171
|
+
int16_t *output_buffer, audio::AudioStreamInfo output_stream_info,
|
172
|
+
uint32_t frames_to_mix);
|
173
|
+
|
174
|
+
static void audio_mixer_task(void *params);
|
175
|
+
|
176
|
+
/// @brief Starts the mixer task after allocating memory for the task stack.
|
177
|
+
/// @return ESP_ERR_NO_MEM if there isn't enough memory for the task's stack
|
178
|
+
/// ESP_ERR_INVALID_STATE if the task didn't start
|
179
|
+
/// ESP_OK if successful
|
180
|
+
esp_err_t start_task_();
|
181
|
+
|
182
|
+
/// @brief If the task is stopped, it sets the task handle to the nullptr and deallocates its stack
|
183
|
+
/// @return ESP_OK if the task was stopped, ESP_ERR_INVALID_STATE otherwise.
|
184
|
+
esp_err_t delete_task_();
|
185
|
+
|
186
|
+
EventGroupHandle_t event_group_{nullptr};
|
187
|
+
|
188
|
+
std::vector<SourceSpeaker *> source_speakers_;
|
189
|
+
speaker::Speaker *output_speaker_{nullptr};
|
190
|
+
|
191
|
+
uint8_t output_channels_;
|
192
|
+
bool queue_mode_;
|
193
|
+
bool task_stack_in_psram_{false};
|
194
|
+
|
195
|
+
bool task_created_{false};
|
196
|
+
|
197
|
+
TaskHandle_t task_handle_{nullptr};
|
198
|
+
StaticTask_t task_stack_;
|
199
|
+
StackType_t *task_stack_buffer_{nullptr};
|
200
|
+
|
201
|
+
optional<audio::AudioStreamInfo> audio_stream_info_;
|
202
|
+
};
|
203
|
+
|
204
|
+
} // namespace mixer_speaker
|
205
|
+
} // namespace esphome
|
206
|
+
|
207
|
+
#endif
|
@@ -117,6 +117,8 @@ class MPR121GPIOPin : public GPIOPin {
|
|
117
117
|
void set_inverted(bool inverted) { this->inverted_ = inverted; }
|
118
118
|
void set_flags(gpio::Flags flags) { this->flags_ = flags; }
|
119
119
|
|
120
|
+
gpio::Flags get_flags() const override { return this->flags_; }
|
121
|
+
|
120
122
|
protected:
|
121
123
|
MPR121Component *parent_;
|
122
124
|
uint8_t pin_;
|
@@ -373,7 +373,7 @@ async def to_code(config):
|
|
373
373
|
)
|
374
374
|
)
|
375
375
|
|
376
|
-
cg.add(var.set_topic_prefix(config[CONF_TOPIC_PREFIX]))
|
376
|
+
cg.add(var.set_topic_prefix(config[CONF_TOPIC_PREFIX], CORE.name))
|
377
377
|
|
378
378
|
if config[CONF_USE_ABBREVIATIONS]:
|
379
379
|
cg.add_define("USE_MQTT_ABBREVIATIONS")
|
@@ -606,7 +606,13 @@ void MQTTClientComponent::set_log_level(int level) { this->log_level_ = level; }
|
|
606
606
|
void MQTTClientComponent::set_keep_alive(uint16_t keep_alive_s) { this->mqtt_backend_.set_keep_alive(keep_alive_s); }
|
607
607
|
void MQTTClientComponent::set_log_message_template(MQTTMessage &&message) { this->log_message_ = std::move(message); }
|
608
608
|
const MQTTDiscoveryInfo &MQTTClientComponent::get_discovery_info() const { return this->discovery_info_; }
|
609
|
-
void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix
|
609
|
+
void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix, const std::string &check_topic_prefix) {
|
610
|
+
if (App.is_name_add_mac_suffix_enabled() && (topic_prefix == check_topic_prefix)) {
|
611
|
+
this->topic_prefix_ = str_sanitize(App.get_name());
|
612
|
+
} else {
|
613
|
+
this->topic_prefix_ = topic_prefix;
|
614
|
+
}
|
615
|
+
}
|
610
616
|
const std::string &MQTTClientComponent::get_topic_prefix() const { return this->topic_prefix_; }
|
611
617
|
void MQTTClientComponent::set_publish_nan_as_none(bool publish_nan_as_none) {
|
612
618
|
this->publish_nan_as_none_ = publish_nan_as_none;
|
@@ -165,7 +165,7 @@ class MQTTClientComponent : public Component {
|
|
165
165
|
*
|
166
166
|
* @param topic_prefix The topic prefix. The last "/" is appended automatically.
|
167
167
|
*/
|
168
|
-
void set_topic_prefix(const std::string &topic_prefix);
|
168
|
+
void set_topic_prefix(const std::string &topic_prefix, const std::string &check_topic_prefix);
|
169
169
|
/// Get the topic prefix of this device, using default if necessary
|
170
170
|
const std::string &get_topic_prefix() const;
|
171
171
|
|
@@ -72,9 +72,9 @@ void MQTTClimateComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCo
|
|
72
72
|
// max_temp
|
73
73
|
root[MQTT_MAX_TEMP] = traits.get_visual_max_temperature();
|
74
74
|
// target_temp_step
|
75
|
-
root[MQTT_TARGET_TEMPERATURE_STEP] = traits.get_visual_target_temperature_step();
|
75
|
+
root[MQTT_TARGET_TEMPERATURE_STEP] = roundf(traits.get_visual_target_temperature_step() * 10) * 0.1;
|
76
76
|
// current_temp_step
|
77
|
-
root[MQTT_CURRENT_TEMPERATURE_STEP] = traits.get_visual_current_temperature_step();
|
77
|
+
root[MQTT_CURRENT_TEMPERATURE_STEP] = roundf(traits.get_visual_current_temperature_step() * 10) * 0.1;
|
78
78
|
// temperature units are always coerced to Celsius internally
|
79
79
|
root[MQTT_TEMPERATURE_UNIT] = "C";
|
80
80
|
|
@@ -49,6 +49,7 @@ struct IPAddress {
|
|
49
49
|
}
|
50
50
|
IPAddress(const std::string &in_address) { inet_aton(in_address.c_str(), &ip_addr_); }
|
51
51
|
IPAddress(const ip_addr_t *other_ip) { ip_addr_ = *other_ip; }
|
52
|
+
std::string str() const { return str_lower_case(inet_ntoa(ip_addr_)); }
|
52
53
|
#else
|
53
54
|
IPAddress() { ip_addr_set_zero(&ip_addr_); }
|
54
55
|
IPAddress(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth) {
|
@@ -119,6 +120,7 @@ struct IPAddress {
|
|
119
120
|
bool is_set() { return !ip_addr_isany(&ip_addr_); } // NOLINT(readability-simplify-boolean-expr)
|
120
121
|
bool is_ip4() { return IP_IS_V4(&ip_addr_); }
|
121
122
|
bool is_ip6() { return IP_IS_V6(&ip_addr_); }
|
123
|
+
bool is_multicast() { return ip_addr_ismulticast(&ip_addr_); }
|
122
124
|
std::string str() const { return str_lower_case(ipaddr_ntoa(&ip_addr_)); }
|
123
125
|
bool operator==(const IPAddress &other) const { return ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
|
124
126
|
bool operator!=(const IPAddress &other) const { return !ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
|
@@ -49,6 +49,23 @@ class TouchTrigger : public Trigger<uint8_t, uint8_t, bool> {
|
|
49
49
|
}
|
50
50
|
};
|
51
51
|
|
52
|
+
template<typename... Ts> class NextionSetBrightnessAction : public Action<Ts...> {
|
53
|
+
public:
|
54
|
+
explicit NextionSetBrightnessAction(Nextion *component) : component_(component) {}
|
55
|
+
|
56
|
+
TEMPLATABLE_VALUE(float, brightness)
|
57
|
+
|
58
|
+
void play(Ts... x) override {
|
59
|
+
this->component_->set_brightness(this->brightness_.value(x...));
|
60
|
+
this->component_->set_backlight_brightness(this->brightness_.value(x...));
|
61
|
+
}
|
62
|
+
|
63
|
+
void set_brightness(std::function<void(Ts..., float)> brightness) { this->brightness_ = brightness; }
|
64
|
+
|
65
|
+
protected:
|
66
|
+
Nextion *component_;
|
67
|
+
};
|
68
|
+
|
52
69
|
template<typename... Ts> class NextionPublishFloatAction : public Action<Ts...> {
|
53
70
|
public:
|
54
71
|
explicit NextionPublishFloatAction(NextionComponent *component) : component_(component) {}
|
@@ -1,30 +1,30 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
import esphome.codegen as cg
|
3
|
+
from esphome.components import display, esp32, uart
|
2
4
|
import esphome.config_validation as cv
|
3
|
-
from esphome import automation
|
4
|
-
from esphome.components import display, uart
|
5
|
-
from esphome.components import esp32
|
6
5
|
from esphome.const import (
|
6
|
+
CONF_BRIGHTNESS,
|
7
7
|
CONF_ID,
|
8
8
|
CONF_LAMBDA,
|
9
|
-
CONF_BRIGHTNESS,
|
10
|
-
CONF_TRIGGER_ID,
|
11
9
|
CONF_ON_TOUCH,
|
10
|
+
CONF_TRIGGER_ID,
|
12
11
|
)
|
13
12
|
from esphome.core import CORE
|
13
|
+
|
14
14
|
from . import Nextion, nextion_ns, nextion_ref
|
15
15
|
from .base_component import (
|
16
|
+
CONF_AUTO_WAKE_ON_TOUCH,
|
17
|
+
CONF_EXIT_REPARSE_ON_START,
|
16
18
|
CONF_ON_BUFFER_OVERFLOW,
|
19
|
+
CONF_ON_PAGE,
|
20
|
+
CONF_ON_SETUP,
|
17
21
|
CONF_ON_SLEEP,
|
18
22
|
CONF_ON_WAKE,
|
19
|
-
|
20
|
-
|
23
|
+
CONF_SKIP_CONNECTION_HANDSHAKE,
|
24
|
+
CONF_START_UP_PAGE,
|
21
25
|
CONF_TFT_URL,
|
22
26
|
CONF_TOUCH_SLEEP_TIMEOUT,
|
23
27
|
CONF_WAKE_UP_PAGE,
|
24
|
-
CONF_START_UP_PAGE,
|
25
|
-
CONF_AUTO_WAKE_ON_TOUCH,
|
26
|
-
CONF_EXIT_REPARSE_ON_START,
|
27
|
-
CONF_SKIP_CONNECTION_HANDSHAKE,
|
28
28
|
)
|
29
29
|
|
30
30
|
CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"]
|
@@ -32,6 +32,9 @@ CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"]
|
|
32
32
|
DEPENDENCIES = ["uart"]
|
33
33
|
AUTO_LOAD = ["binary_sensor", "switch", "sensor", "text_sensor"]
|
34
34
|
|
35
|
+
NextionSetBrightnessAction = nextion_ns.class_(
|
36
|
+
"NextionSetBrightnessAction", automation.Action
|
37
|
+
)
|
35
38
|
SetupTrigger = nextion_ns.class_("SetupTrigger", automation.Trigger.template())
|
36
39
|
SleepTrigger = nextion_ns.class_("SleepTrigger", automation.Trigger.template())
|
37
40
|
WakeTrigger = nextion_ns.class_("WakeTrigger", automation.Trigger.template())
|
@@ -46,7 +49,7 @@ CONFIG_SCHEMA = (
|
|
46
49
|
{
|
47
50
|
cv.GenerateID(): cv.declare_id(Nextion),
|
48
51
|
cv.Optional(CONF_TFT_URL): cv.url,
|
49
|
-
cv.Optional(CONF_BRIGHTNESS
|
52
|
+
cv.Optional(CONF_BRIGHTNESS): cv.percentage,
|
50
53
|
cv.Optional(CONF_ON_SETUP): automation.validate_automation(
|
51
54
|
{
|
52
55
|
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SetupTrigger),
|
@@ -92,12 +95,34 @@ CONFIG_SCHEMA = (
|
|
92
95
|
)
|
93
96
|
|
94
97
|
|
98
|
+
@automation.register_action(
|
99
|
+
"display.nextion.set_brightness",
|
100
|
+
NextionSetBrightnessAction,
|
101
|
+
cv.maybe_simple_value(
|
102
|
+
{
|
103
|
+
cv.GenerateID(): cv.use_id(Nextion),
|
104
|
+
cv.Required(CONF_BRIGHTNESS): cv.templatable(cv.percentage),
|
105
|
+
},
|
106
|
+
key=CONF_BRIGHTNESS,
|
107
|
+
),
|
108
|
+
)
|
109
|
+
async def nextion_set_brightness_to_code(config, action_id, template_arg, args):
|
110
|
+
paren = await cg.get_variable(config[CONF_ID])
|
111
|
+
var = cg.new_Pvariable(action_id, template_arg, paren)
|
112
|
+
|
113
|
+
template_ = await cg.templatable(config[CONF_BRIGHTNESS], args, float)
|
114
|
+
cg.add(var.set_brightness(template_))
|
115
|
+
|
116
|
+
return var
|
117
|
+
|
118
|
+
|
95
119
|
async def to_code(config):
|
96
120
|
var = cg.new_Pvariable(config[CONF_ID])
|
97
121
|
await uart.register_uart_device(var, config)
|
98
122
|
|
99
123
|
if CONF_BRIGHTNESS in config:
|
100
124
|
cg.add(var.set_brightness(config[CONF_BRIGHTNESS]))
|
125
|
+
|
101
126
|
if CONF_LAMBDA in config:
|
102
127
|
lambda_ = await cg.process_lambda(
|
103
128
|
config[CONF_LAMBDA], [(nextion_ref, "it")], return_type=cg.void
|
@@ -119,17 +144,17 @@ async def to_code(config):
|
|
119
144
|
cg.add_library("ESP8266HTTPClient", None)
|
120
145
|
|
121
146
|
if CONF_TOUCH_SLEEP_TIMEOUT in config:
|
122
|
-
cg.add(var.
|
147
|
+
cg.add(var.set_touch_sleep_timeout(config[CONF_TOUCH_SLEEP_TIMEOUT]))
|
123
148
|
|
124
149
|
if CONF_WAKE_UP_PAGE in config:
|
125
|
-
cg.add(var.
|
150
|
+
cg.add(var.set_wake_up_page(config[CONF_WAKE_UP_PAGE]))
|
126
151
|
|
127
152
|
if CONF_START_UP_PAGE in config:
|
128
|
-
cg.add(var.
|
153
|
+
cg.add(var.set_start_up_page(config[CONF_START_UP_PAGE]))
|
129
154
|
|
130
|
-
cg.add(var.
|
155
|
+
cg.add(var.set_auto_wake_on_touch(config[CONF_AUTO_WAKE_ON_TOUCH]))
|
131
156
|
|
132
|
-
cg.add(var.
|
157
|
+
cg.add(var.set_exit_reparse_on_start(config[CONF_EXIT_REPARSE_ON_START]))
|
133
158
|
|
134
159
|
cg.add(var.set_skip_connection_handshake(config[CONF_SKIP_CONNECTION_HANDSHAKE]))
|
135
160
|
|
@@ -40,7 +40,7 @@ bool Nextion::send_command_(const std::string &command) {
|
|
40
40
|
}
|
41
41
|
|
42
42
|
bool Nextion::check_connect_() {
|
43
|
-
if (this->
|
43
|
+
if (this->is_connected_)
|
44
44
|
return true;
|
45
45
|
|
46
46
|
// Check if the handshake should be skipped for the Nextion connection
|
@@ -273,21 +273,15 @@ void Nextion::loop() {
|
|
273
273
|
this->sent_setup_commands_ = true;
|
274
274
|
this->send_command_("bkcmd=3"); // Always, returns 0x00 to 0x23 result of serial command.
|
275
275
|
|
276
|
-
|
276
|
+
if (this->brightness_.has_value()) {
|
277
|
+
this->set_backlight_brightness(this->brightness_.value());
|
278
|
+
}
|
277
279
|
|
278
280
|
// Check if a startup page has been set and send the command
|
279
281
|
if (this->start_up_page_ != -1) {
|
280
282
|
this->goto_page(this->start_up_page_);
|
281
283
|
}
|
282
284
|
|
283
|
-
// This could probably be removed from the loop area, as those are redundant.
|
284
|
-
this->set_auto_wake_on_touch(this->auto_wake_on_touch_);
|
285
|
-
this->set_exit_reparse_on_start(this->exit_reparse_on_start_);
|
286
|
-
|
287
|
-
if (this->touch_sleep_timeout_ != 0) {
|
288
|
-
this->set_touch_sleep_timeout(this->touch_sleep_timeout_);
|
289
|
-
}
|
290
|
-
|
291
285
|
if (this->wake_up_page_ != -1) {
|
292
286
|
this->set_wake_up_page(this->wake_up_page_);
|
293
287
|
}
|
@@ -856,76 +856,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
856
856
|
*/
|
857
857
|
void set_backlight_brightness(float brightness);
|
858
858
|
|
859
|
-
/**
|
860
|
-
* Set the touch sleep timeout of the display.
|
861
|
-
* @param timeout Timeout in seconds.
|
862
|
-
*
|
863
|
-
* Example:
|
864
|
-
* ```cpp
|
865
|
-
* it.set_touch_sleep_timeout(30);
|
866
|
-
* ```
|
867
|
-
*
|
868
|
-
* After 30 seconds the display will go to sleep. Note: the display will only wakeup by a restart or by setting up
|
869
|
-
* `thup`.
|
870
|
-
*/
|
871
|
-
void set_touch_sleep_timeout(uint16_t timeout);
|
872
|
-
|
873
|
-
/**
|
874
|
-
* Sets which page Nextion loads when exiting sleep mode. Note this can be set even when Nextion is in sleep mode.
|
875
|
-
* @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
876
|
-
* wakes up to current page.
|
877
|
-
*
|
878
|
-
* Example:
|
879
|
-
* ```cpp
|
880
|
-
* it.set_wake_up_page(2);
|
881
|
-
* ```
|
882
|
-
*
|
883
|
-
* The display will wake up to page 2.
|
884
|
-
*/
|
885
|
-
void set_wake_up_page(uint8_t page_id = 255);
|
886
|
-
|
887
|
-
/**
|
888
|
-
* Sets which page Nextion loads when connecting to ESPHome.
|
889
|
-
* @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
890
|
-
* wakes up to current page.
|
891
|
-
*
|
892
|
-
* Example:
|
893
|
-
* ```cpp
|
894
|
-
* it.set_start_up_page(2);
|
895
|
-
* ```
|
896
|
-
*
|
897
|
-
* The display will go to page 2 when it establishes a connection to ESPHome.
|
898
|
-
*/
|
899
|
-
void set_start_up_page(uint8_t page_id = 255);
|
900
|
-
|
901
|
-
/**
|
902
|
-
* Sets if Nextion should auto-wake from sleep when touch press occurs.
|
903
|
-
* @param auto_wake True or false. When auto_wake is true and Nextion is in sleep mode,
|
904
|
-
* the first touch will only trigger the auto wake mode and not trigger a Touch Event.
|
905
|
-
*
|
906
|
-
* Example:
|
907
|
-
* ```cpp
|
908
|
-
* it.set_auto_wake_on_touch(true);
|
909
|
-
* ```
|
910
|
-
*
|
911
|
-
* The display will wake up by touch.
|
912
|
-
*/
|
913
|
-
void set_auto_wake_on_touch(bool auto_wake);
|
914
|
-
|
915
|
-
/**
|
916
|
-
* Sets if Nextion should exit the active reparse mode before the "connect" command is sent
|
917
|
-
* @param exit_reparse True or false. When exit_reparse is true, the exit reparse command
|
918
|
-
* will be sent before requesting the connection from Nextion.
|
919
|
-
*
|
920
|
-
* Example:
|
921
|
-
* ```cpp
|
922
|
-
* it.set_exit_reparse_on_start(true);
|
923
|
-
* ```
|
924
|
-
*
|
925
|
-
* The display will be requested to leave active reparse mode before setup.
|
926
|
-
*/
|
927
|
-
void set_exit_reparse_on_start(bool exit_reparse);
|
928
|
-
|
929
859
|
/**
|
930
860
|
* Sets whether the Nextion display should skip the connection handshake process.
|
931
861
|
* @param skip_handshake True or false. When skip_connection_handshake is true,
|
@@ -1172,15 +1102,75 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1172
1102
|
|
1173
1103
|
void update_components_by_prefix(const std::string &prefix);
|
1174
1104
|
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1105
|
+
/**
|
1106
|
+
* Set the touch sleep timeout of the display.
|
1107
|
+
* @param timeout Timeout in seconds.
|
1108
|
+
*
|
1109
|
+
* Example:
|
1110
|
+
* ```cpp
|
1111
|
+
* it.set_touch_sleep_timeout(30);
|
1112
|
+
* ```
|
1113
|
+
*
|
1114
|
+
* After 30 seconds the display will go to sleep. Note: the display will only wakeup by a restart or by setting up
|
1115
|
+
* `thup`.
|
1116
|
+
*/
|
1117
|
+
void set_touch_sleep_timeout(uint32_t touch_sleep_timeout);
|
1118
|
+
|
1119
|
+
/**
|
1120
|
+
* Sets which page Nextion loads when exiting sleep mode. Note this can be set even when Nextion is in sleep mode.
|
1121
|
+
* @param wake_up_page The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
1122
|
+
* wakes up to current page.
|
1123
|
+
*
|
1124
|
+
* Example:
|
1125
|
+
* ```cpp
|
1126
|
+
* it.set_wake_up_page(2);
|
1127
|
+
* ```
|
1128
|
+
*
|
1129
|
+
* The display will wake up to page 2.
|
1130
|
+
*/
|
1131
|
+
void set_wake_up_page(uint8_t wake_up_page = 255);
|
1132
|
+
|
1133
|
+
/**
|
1134
|
+
* Sets which page Nextion loads when connecting to ESPHome.
|
1135
|
+
* @param start_up_page The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
1136
|
+
* wakes up to current page.
|
1137
|
+
*
|
1138
|
+
* Example:
|
1139
|
+
* ```cpp
|
1140
|
+
* it.set_start_up_page(2);
|
1141
|
+
* ```
|
1142
|
+
*
|
1143
|
+
* The display will go to page 2 when it establishes a connection to ESPHome.
|
1144
|
+
*/
|
1145
|
+
void set_start_up_page(uint8_t start_up_page = 255) { this->start_up_page_ = start_up_page; }
|
1146
|
+
|
1147
|
+
/**
|
1148
|
+
* Sets if Nextion should auto-wake from sleep when touch press occurs.
|
1149
|
+
* @param auto_wake_on_touch True or false. When auto_wake is true and Nextion is in sleep mode,
|
1150
|
+
* the first touch will only trigger the auto wake mode and not trigger a Touch Event.
|
1151
|
+
*
|
1152
|
+
* Example:
|
1153
|
+
* ```cpp
|
1154
|
+
* it.set_auto_wake_on_touch(true);
|
1155
|
+
* ```
|
1156
|
+
*
|
1157
|
+
* The display will wake up by touch.
|
1158
|
+
*/
|
1159
|
+
void set_auto_wake_on_touch(bool auto_wake_on_touch);
|
1160
|
+
|
1161
|
+
/**
|
1162
|
+
* Sets if Nextion should exit the active reparse mode before the "connect" command is sent
|
1163
|
+
* @param exit_reparse_on_start True or false. When exit_reparse_on_start is true, the exit reparse command
|
1164
|
+
* will be sent before requesting the connection from Nextion.
|
1165
|
+
*
|
1166
|
+
* Example:
|
1167
|
+
* ```cpp
|
1168
|
+
* it.set_exit_reparse_on_start(true);
|
1169
|
+
* ```
|
1170
|
+
*
|
1171
|
+
* The display will be requested to leave active reparse mode before setup.
|
1172
|
+
*/
|
1173
|
+
void set_exit_reparse_on_start(bool exit_reparse_on_start) { this->exit_reparse_on_start_ = exit_reparse_on_start; }
|
1184
1174
|
|
1185
1175
|
/**
|
1186
1176
|
* @brief Retrieves the number of commands pending in the Nextion command queue.
|
@@ -1217,6 +1207,25 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1217
1207
|
*/
|
1218
1208
|
bool is_updating() override;
|
1219
1209
|
|
1210
|
+
/**
|
1211
|
+
* @brief Check if the Nextion display is successfully connected.
|
1212
|
+
*
|
1213
|
+
* This method returns whether a successful connection has been established with
|
1214
|
+
* the Nextion display. A connection is considered established when:
|
1215
|
+
*
|
1216
|
+
* - The initial handshake with the display is completed successfully, or
|
1217
|
+
* - The handshake is skipped via skip_connection_handshake_ flag
|
1218
|
+
*
|
1219
|
+
* The connection status is particularly useful when:
|
1220
|
+
* - Troubleshooting communication issues
|
1221
|
+
* - Ensuring the display is ready before sending commands
|
1222
|
+
* - Implementing connection-dependent behaviors
|
1223
|
+
*
|
1224
|
+
* @return true if the Nextion display is connected and ready to receive commands
|
1225
|
+
* @return false if the display is not yet connected or connection was lost
|
1226
|
+
*/
|
1227
|
+
bool is_connected() { return this->is_connected_; }
|
1228
|
+
|
1220
1229
|
protected:
|
1221
1230
|
std::deque<NextionQueue *> nextion_queue_;
|
1222
1231
|
std::deque<NextionQueue *> waveform_queue_;
|
@@ -1315,8 +1324,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1315
1324
|
|
1316
1325
|
#endif // USE_NEXTION_TFT_UPLOAD
|
1317
1326
|
|
1318
|
-
bool get_is_connected_() { return this->is_connected_; }
|
1319
|
-
|
1320
1327
|
bool check_connect_();
|
1321
1328
|
|
1322
1329
|
std::vector<NextionComponentBase *> touch_;
|
@@ -1332,7 +1339,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|
1332
1339
|
CallbackManager<void()> buffer_overflow_callback_{};
|
1333
1340
|
|
1334
1341
|
optional<nextion_writer_t> writer_;
|
1335
|
-
float brightness_
|
1342
|
+
optional<float> brightness_;
|
1336
1343
|
|
1337
1344
|
std::string device_model_;
|
1338
1345
|
std::string firmware_version_;
|