esphome 2024.12.3__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.3.dist-info → esphome-2025.2.0b1.dist-info}/METADATA +12 -7
- {esphome-2024.12.3.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.3.dist-info → esphome-2025.2.0b1.dist-info}/LICENSE +0 -0
- {esphome-2024.12.3.dist-info → esphome-2025.2.0b1.dist-info}/WHEEL +0 -0
- {esphome-2024.12.3.dist-info → esphome-2025.2.0b1.dist-info}/entry_points.txt +0 -0
- {esphome-2024.12.3.dist-info → esphome-2025.2.0b1.dist-info}/top_level.txt +0 -0
@@ -2,15 +2,110 @@
|
|
2
2
|
#include "esphome/core/log.h"
|
3
3
|
|
4
4
|
#ifdef USE_ESP32
|
5
|
-
#include <driver/
|
5
|
+
#include <driver/gpio.h>
|
6
6
|
|
7
7
|
namespace esphome {
|
8
8
|
namespace remote_receiver {
|
9
9
|
|
10
10
|
static const char *const TAG = "remote_receiver.esp32";
|
11
|
+
#ifdef USE_ESP32_VARIANT_ESP32H2
|
12
|
+
static const uint32_t RMT_CLK_FREQ = 32000000;
|
13
|
+
#else
|
14
|
+
static const uint32_t RMT_CLK_FREQ = 80000000;
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
18
|
+
static bool IRAM_ATTR HOT rmt_callback(rmt_channel_handle_t channel, const rmt_rx_done_event_data_t *event, void *arg) {
|
19
|
+
RemoteReceiverComponentStore *store = (RemoteReceiverComponentStore *) arg;
|
20
|
+
rmt_rx_done_event_data_t *event_buffer = (rmt_rx_done_event_data_t *) (store->buffer + store->buffer_write);
|
21
|
+
uint32_t event_size = sizeof(rmt_rx_done_event_data_t);
|
22
|
+
uint32_t next_write = store->buffer_write + event_size + event->num_symbols * sizeof(rmt_symbol_word_t);
|
23
|
+
if (next_write + event_size + store->receive_size > store->buffer_size) {
|
24
|
+
next_write = 0;
|
25
|
+
}
|
26
|
+
if (store->buffer_read - next_write < event_size + store->receive_size) {
|
27
|
+
next_write = store->buffer_write;
|
28
|
+
store->overflow = true;
|
29
|
+
}
|
30
|
+
if (event->num_symbols <= store->filter_symbols) {
|
31
|
+
next_write = store->buffer_write;
|
32
|
+
}
|
33
|
+
store->error =
|
34
|
+
rmt_receive(channel, (uint8_t *) store->buffer + next_write + event_size, store->receive_size, &store->config);
|
35
|
+
event_buffer->num_symbols = event->num_symbols;
|
36
|
+
event_buffer->received_symbols = event->received_symbols;
|
37
|
+
store->buffer_write = next_write;
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
#endif
|
11
41
|
|
12
42
|
void RemoteReceiverComponent::setup() {
|
13
43
|
ESP_LOGCONFIG(TAG, "Setting up Remote Receiver...");
|
44
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
45
|
+
rmt_rx_channel_config_t channel;
|
46
|
+
memset(&channel, 0, sizeof(channel));
|
47
|
+
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
48
|
+
channel.resolution_hz = this->clock_resolution_;
|
49
|
+
channel.mem_block_symbols = rmt_symbols_;
|
50
|
+
channel.gpio_num = gpio_num_t(this->pin_->get_pin());
|
51
|
+
channel.intr_priority = 0;
|
52
|
+
channel.flags.invert_in = 0;
|
53
|
+
channel.flags.with_dma = this->with_dma_;
|
54
|
+
channel.flags.io_loop_back = 0;
|
55
|
+
esp_err_t error = rmt_new_rx_channel(&channel, &this->channel_);
|
56
|
+
if (error != ESP_OK) {
|
57
|
+
this->error_code_ = error;
|
58
|
+
if (error == ESP_ERR_NOT_FOUND) {
|
59
|
+
this->error_string_ = "out of RMT symbol memory";
|
60
|
+
} else {
|
61
|
+
this->error_string_ = "in rmt_new_rx_channel";
|
62
|
+
}
|
63
|
+
this->mark_failed();
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
if (this->pin_->get_flags() & gpio::FLAG_PULLUP) {
|
67
|
+
gpio_pullup_en(gpio_num_t(this->pin_->get_pin()));
|
68
|
+
} else {
|
69
|
+
gpio_pullup_dis(gpio_num_t(this->pin_->get_pin()));
|
70
|
+
}
|
71
|
+
error = rmt_enable(this->channel_);
|
72
|
+
if (error != ESP_OK) {
|
73
|
+
this->error_code_ = error;
|
74
|
+
this->error_string_ = "in rmt_enable";
|
75
|
+
this->mark_failed();
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
79
|
+
rmt_rx_event_callbacks_t callbacks;
|
80
|
+
memset(&callbacks, 0, sizeof(callbacks));
|
81
|
+
callbacks.on_recv_done = rmt_callback;
|
82
|
+
error = rmt_rx_register_event_callbacks(this->channel_, &callbacks, &this->store_);
|
83
|
+
if (error != ESP_OK) {
|
84
|
+
this->error_code_ = error;
|
85
|
+
this->error_string_ = "in rmt_rx_register_event_callbacks";
|
86
|
+
this->mark_failed();
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
|
90
|
+
uint32_t event_size = sizeof(rmt_rx_done_event_data_t);
|
91
|
+
uint32_t max_filter_ns = 255u * 1000 / (RMT_CLK_FREQ / 1000000);
|
92
|
+
uint32_t max_idle_ns = 65535u * 1000;
|
93
|
+
memset(&this->store_.config, 0, sizeof(this->store_.config));
|
94
|
+
this->store_.config.signal_range_min_ns = std::min(this->filter_us_ * 1000, max_filter_ns);
|
95
|
+
this->store_.config.signal_range_max_ns = std::min(this->idle_us_ * 1000, max_idle_ns);
|
96
|
+
this->store_.filter_symbols = this->filter_symbols_;
|
97
|
+
this->store_.receive_size = this->receive_symbols_ * sizeof(rmt_symbol_word_t);
|
98
|
+
this->store_.buffer_size = std::max((event_size + this->store_.receive_size) * 2, this->buffer_size_);
|
99
|
+
this->store_.buffer = new uint8_t[this->buffer_size_];
|
100
|
+
error = rmt_receive(this->channel_, (uint8_t *) this->store_.buffer + event_size, this->store_.receive_size,
|
101
|
+
&this->store_.config);
|
102
|
+
if (error != ESP_OK) {
|
103
|
+
this->error_code_ = error;
|
104
|
+
this->error_string_ = "in rmt_receive";
|
105
|
+
this->mark_failed();
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
#else
|
14
109
|
this->pin_->setup();
|
15
110
|
rmt_config_t rmt{};
|
16
111
|
this->config_rmt(rmt);
|
@@ -59,10 +154,18 @@ void RemoteReceiverComponent::setup() {
|
|
59
154
|
this->mark_failed();
|
60
155
|
return;
|
61
156
|
}
|
157
|
+
#endif
|
62
158
|
}
|
159
|
+
|
63
160
|
void RemoteReceiverComponent::dump_config() {
|
64
161
|
ESP_LOGCONFIG(TAG, "Remote Receiver:");
|
65
162
|
LOG_PIN(" Pin: ", this->pin_);
|
163
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
164
|
+
ESP_LOGCONFIG(TAG, " Clock resolution: %" PRIu32 " hz", this->clock_resolution_);
|
165
|
+
ESP_LOGCONFIG(TAG, " RMT symbols: %" PRIu32, this->rmt_symbols_);
|
166
|
+
ESP_LOGCONFIG(TAG, " Filter symbols: %" PRIu32, this->filter_symbols_);
|
167
|
+
ESP_LOGCONFIG(TAG, " Receive symbols: %" PRIu32, this->receive_symbols_);
|
168
|
+
#else
|
66
169
|
if (this->pin_->digital_read()) {
|
67
170
|
ESP_LOGW(TAG, "Remote Receiver Signal starts with a HIGH value. Usually this means you have to "
|
68
171
|
"invert the signal using 'inverted: True' in the pin schema!");
|
@@ -70,6 +173,7 @@ void RemoteReceiverComponent::dump_config() {
|
|
70
173
|
ESP_LOGCONFIG(TAG, " Channel: %d", this->channel_);
|
71
174
|
ESP_LOGCONFIG(TAG, " RMT memory blocks: %d", this->mem_block_num_);
|
72
175
|
ESP_LOGCONFIG(TAG, " Clock divider: %u", this->clock_divider_);
|
176
|
+
#endif
|
73
177
|
ESP_LOGCONFIG(TAG, " Tolerance: %" PRIu32 "%s", this->tolerance_,
|
74
178
|
(this->tolerance_mode_ == remote_base::TOLERANCE_MODE_TIME) ? " us" : "%");
|
75
179
|
ESP_LOGCONFIG(TAG, " Filter out pulses shorter than: %" PRIu32 " us", this->filter_us_);
|
@@ -81,10 +185,38 @@ void RemoteReceiverComponent::dump_config() {
|
|
81
185
|
}
|
82
186
|
|
83
187
|
void RemoteReceiverComponent::loop() {
|
188
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
189
|
+
if (this->store_.error != ESP_OK) {
|
190
|
+
ESP_LOGE(TAG, "Receive error");
|
191
|
+
this->error_code_ = this->store_.error;
|
192
|
+
this->error_string_ = "in rmt_callback";
|
193
|
+
this->mark_failed();
|
194
|
+
}
|
195
|
+
if (this->store_.overflow) {
|
196
|
+
ESP_LOGW(TAG, "Buffer overflow");
|
197
|
+
this->store_.overflow = false;
|
198
|
+
}
|
199
|
+
uint32_t buffer_write = this->store_.buffer_write;
|
200
|
+
while (this->store_.buffer_read != buffer_write) {
|
201
|
+
rmt_rx_done_event_data_t *event = (rmt_rx_done_event_data_t *) (this->store_.buffer + this->store_.buffer_read);
|
202
|
+
uint32_t event_size = sizeof(rmt_rx_done_event_data_t);
|
203
|
+
uint32_t next_read = this->store_.buffer_read + event_size + event->num_symbols * sizeof(rmt_symbol_word_t);
|
204
|
+
if (next_read + event_size + this->store_.receive_size > this->store_.buffer_size) {
|
205
|
+
next_read = 0;
|
206
|
+
}
|
207
|
+
this->decode_rmt_(event->received_symbols, event->num_symbols);
|
208
|
+
this->store_.buffer_read = next_read;
|
209
|
+
|
210
|
+
if (!this->temp_.empty()) {
|
211
|
+
this->temp_.push_back(-this->idle_us_);
|
212
|
+
this->call_listeners_dumpers_();
|
213
|
+
}
|
214
|
+
}
|
215
|
+
#else
|
84
216
|
size_t len = 0;
|
85
217
|
auto *item = (rmt_item32_t *) xRingbufferReceive(this->ringbuf_, &len, 0);
|
86
218
|
if (item != nullptr) {
|
87
|
-
this->decode_rmt_(item, len);
|
219
|
+
this->decode_rmt_(item, len / sizeof(rmt_item32_t));
|
88
220
|
vRingbufferReturnItem(this->ringbuf_, item);
|
89
221
|
|
90
222
|
if (this->temp_.empty())
|
@@ -93,13 +225,18 @@ void RemoteReceiverComponent::loop() {
|
|
93
225
|
this->temp_.push_back(-this->idle_us_);
|
94
226
|
this->call_listeners_dumpers_();
|
95
227
|
}
|
228
|
+
#endif
|
96
229
|
}
|
97
|
-
|
230
|
+
|
231
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
232
|
+
void RemoteReceiverComponent::decode_rmt_(rmt_symbol_word_t *item, size_t item_count) {
|
233
|
+
#else
|
234
|
+
void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t item_count) {
|
235
|
+
#endif
|
98
236
|
bool prev_level = false;
|
99
237
|
uint32_t prev_length = 0;
|
100
238
|
this->temp_.clear();
|
101
239
|
int32_t multiplier = this->pin_->is_inverted() ? -1 : 1;
|
102
|
-
size_t item_count = len / sizeof(rmt_item32_t);
|
103
240
|
uint32_t filter_ticks = this->from_microseconds_(this->filter_us_);
|
104
241
|
|
105
242
|
ESP_LOGVV(TAG, "START:");
|
@@ -124,7 +261,8 @@ void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t len) {
|
|
124
261
|
this->temp_.reserve(item_count * 2); // each RMT item has 2 pulses
|
125
262
|
for (size_t i = 0; i < item_count; i++) {
|
126
263
|
if (item[i].duration0 == 0u) {
|
127
|
-
//
|
264
|
+
// EOF, sometimes garbage follows, break early
|
265
|
+
break;
|
128
266
|
} else if ((bool(item[i].level0) == prev_level) || (item[i].duration0 < filter_ticks)) {
|
129
267
|
prev_length += item[i].duration0;
|
130
268
|
} else {
|
@@ -140,7 +278,8 @@ void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t len) {
|
|
140
278
|
}
|
141
279
|
|
142
280
|
if (item[i].duration1 == 0u) {
|
143
|
-
//
|
281
|
+
// EOF, sometimes garbage follows, break early
|
282
|
+
break;
|
144
283
|
} else if ((bool(item[i].level1) == prev_level) || (item[i].duration1 < filter_ticks)) {
|
145
284
|
prev_length += item[i].duration1;
|
146
285
|
} else {
|
@@ -2,10 +2,24 @@ from esphome import automation, pins
|
|
2
2
|
import esphome.codegen as cg
|
3
3
|
from esphome.components import esp32_rmt, remote_base
|
4
4
|
import esphome.config_validation as cv
|
5
|
-
from esphome.const import
|
5
|
+
from esphome.const import (
|
6
|
+
CONF_CARRIER_DUTY_PERCENT,
|
7
|
+
CONF_CLOCK_DIVIDER,
|
8
|
+
CONF_CLOCK_RESOLUTION,
|
9
|
+
CONF_ID,
|
10
|
+
CONF_INVERTED,
|
11
|
+
CONF_MODE,
|
12
|
+
CONF_OPEN_DRAIN,
|
13
|
+
CONF_PIN,
|
14
|
+
CONF_RMT_CHANNEL,
|
15
|
+
CONF_RMT_SYMBOLS,
|
16
|
+
CONF_USE_DMA,
|
17
|
+
)
|
18
|
+
from esphome.core import CORE
|
6
19
|
|
7
20
|
AUTO_LOAD = ["remote_base"]
|
8
21
|
|
22
|
+
CONF_EOT_LEVEL = "eot_level"
|
9
23
|
CONF_ON_TRANSMIT = "on_transmit"
|
10
24
|
CONF_ON_COMPLETE = "on_complete"
|
11
25
|
|
@@ -22,7 +36,28 @@ CONFIG_SCHEMA = cv.Schema(
|
|
22
36
|
cv.Required(CONF_CARRIER_DUTY_PERCENT): cv.All(
|
23
37
|
cv.percentage_int, cv.Range(min=1, max=100)
|
24
38
|
),
|
25
|
-
cv.Optional(
|
39
|
+
cv.Optional(CONF_CLOCK_RESOLUTION): cv.All(
|
40
|
+
cv.only_on_esp32,
|
41
|
+
cv.only_with_esp_idf,
|
42
|
+
esp32_rmt.validate_clock_resolution(),
|
43
|
+
),
|
44
|
+
cv.Optional(CONF_CLOCK_DIVIDER): cv.All(
|
45
|
+
cv.only_on_esp32, cv.only_with_arduino, cv.int_range(min=1, max=255)
|
46
|
+
),
|
47
|
+
cv.Optional(CONF_EOT_LEVEL): cv.All(cv.only_with_esp_idf, cv.boolean),
|
48
|
+
cv.Optional(CONF_USE_DMA): cv.All(cv.only_with_esp_idf, cv.boolean),
|
49
|
+
cv.SplitDefault(
|
50
|
+
CONF_RMT_SYMBOLS,
|
51
|
+
esp32_idf=64,
|
52
|
+
esp32_s2_idf=64,
|
53
|
+
esp32_s3_idf=48,
|
54
|
+
esp32_c3_idf=48,
|
55
|
+
esp32_c6_idf=48,
|
56
|
+
esp32_h2_idf=48,
|
57
|
+
): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)),
|
58
|
+
cv.Optional(CONF_RMT_CHANNEL): cv.All(
|
59
|
+
cv.only_with_arduino, esp32_rmt.validate_rmt_channel(tx=True)
|
60
|
+
),
|
26
61
|
cv.Optional(CONF_ON_TRANSMIT): automation.validate_automation(single=True),
|
27
62
|
cv.Optional(CONF_ON_COMPLETE): automation.validate_automation(single=True),
|
28
63
|
}
|
@@ -31,8 +66,31 @@ CONFIG_SCHEMA = cv.Schema(
|
|
31
66
|
|
32
67
|
async def to_code(config):
|
33
68
|
pin = await cg.gpio_pin_expression(config[CONF_PIN])
|
34
|
-
if
|
35
|
-
|
69
|
+
if CORE.is_esp32:
|
70
|
+
if esp32_rmt.use_new_rmt_driver():
|
71
|
+
var = cg.new_Pvariable(config[CONF_ID], pin)
|
72
|
+
cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS]))
|
73
|
+
if CONF_CLOCK_RESOLUTION in config:
|
74
|
+
cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION]))
|
75
|
+
if CONF_USE_DMA in config:
|
76
|
+
cg.add(var.set_with_dma(config[CONF_USE_DMA]))
|
77
|
+
if CONF_EOT_LEVEL in config:
|
78
|
+
cg.add(var.set_eot_level(config[CONF_EOT_LEVEL]))
|
79
|
+
else:
|
80
|
+
cg.add(
|
81
|
+
var.set_eot_level(
|
82
|
+
config[CONF_PIN][CONF_MODE][CONF_OPEN_DRAIN]
|
83
|
+
or config[CONF_PIN][CONF_INVERTED]
|
84
|
+
)
|
85
|
+
)
|
86
|
+
else:
|
87
|
+
if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None:
|
88
|
+
var = cg.new_Pvariable(config[CONF_ID], pin, rmt_channel)
|
89
|
+
else:
|
90
|
+
var = cg.new_Pvariable(config[CONF_ID], pin)
|
91
|
+
if CONF_CLOCK_DIVIDER in config:
|
92
|
+
cg.add(var.set_clock_divider(config[CONF_CLOCK_DIVIDER]))
|
93
|
+
|
36
94
|
else:
|
37
95
|
var = cg.new_Pvariable(config[CONF_ID], pin)
|
38
96
|
await cg.register_component(var, config)
|
@@ -5,6 +5,10 @@
|
|
5
5
|
|
6
6
|
#include <vector>
|
7
7
|
|
8
|
+
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
|
9
|
+
#include <driver/rmt_tx.h>
|
10
|
+
#endif
|
11
|
+
|
8
12
|
namespace esphome {
|
9
13
|
namespace remote_transmitter {
|
10
14
|
|
@@ -16,7 +20,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase,
|
|
16
20
|
#endif
|
17
21
|
{
|
18
22
|
public:
|
19
|
-
#
|
23
|
+
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5
|
20
24
|
RemoteTransmitterComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1)
|
21
25
|
: remote_base::RemoteTransmitterBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {}
|
22
26
|
|
@@ -29,10 +33,17 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase,
|
|
29
33
|
|
30
34
|
void dump_config() override;
|
31
35
|
|
32
|
-
|
36
|
+
// transmitter setup must run after receiver setup to allow the same GPIO to be used by both
|
37
|
+
float get_setup_priority() const override { return setup_priority::DATA - 1; }
|
33
38
|
|
34
39
|
void set_carrier_duty_percent(uint8_t carrier_duty_percent) { this->carrier_duty_percent_ = carrier_duty_percent; }
|
35
40
|
|
41
|
+
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
|
42
|
+
void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; }
|
43
|
+
void set_eot_level(bool eot_level) { this->eot_level_ = eot_level; }
|
44
|
+
void digital_write(bool value);
|
45
|
+
#endif
|
46
|
+
|
36
47
|
Trigger<> *get_transmit_trigger() const { return this->transmit_trigger_; };
|
37
48
|
Trigger<> *get_complete_trigger() const { return this->complete_trigger_; };
|
38
49
|
|
@@ -54,7 +65,15 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase,
|
|
54
65
|
|
55
66
|
uint32_t current_carrier_frequency_{38000};
|
56
67
|
bool initialized_{false};
|
68
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
69
|
+
std::vector<rmt_symbol_word_t> rmt_temp_;
|
70
|
+
bool with_dma_{false};
|
71
|
+
bool eot_level_{false};
|
72
|
+
rmt_channel_handle_t channel_{NULL};
|
73
|
+
rmt_encoder_handle_t encoder_{NULL};
|
74
|
+
#else
|
57
75
|
std::vector<rmt_item32_t> rmt_temp_;
|
76
|
+
#endif
|
58
77
|
esp_err_t error_code_{ESP_OK};
|
59
78
|
std::string error_string_{""};
|
60
79
|
bool inverted_{false};
|
@@ -3,19 +3,29 @@
|
|
3
3
|
#include "esphome/core/application.h"
|
4
4
|
|
5
5
|
#ifdef USE_ESP32
|
6
|
+
#include <driver/gpio.h>
|
6
7
|
|
7
8
|
namespace esphome {
|
8
9
|
namespace remote_transmitter {
|
9
10
|
|
10
11
|
static const char *const TAG = "remote_transmitter";
|
11
12
|
|
12
|
-
void RemoteTransmitterComponent::setup() {
|
13
|
+
void RemoteTransmitterComponent::setup() {
|
14
|
+
ESP_LOGCONFIG(TAG, "Setting up Remote Transmitter...");
|
15
|
+
this->inverted_ = this->pin_->is_inverted();
|
16
|
+
this->configure_rmt_();
|
17
|
+
}
|
13
18
|
|
14
19
|
void RemoteTransmitterComponent::dump_config() {
|
15
|
-
ESP_LOGCONFIG(TAG, "Remote Transmitter
|
20
|
+
ESP_LOGCONFIG(TAG, "Remote Transmitter:");
|
21
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
22
|
+
ESP_LOGCONFIG(TAG, " Clock resolution: %" PRIu32 " hz", this->clock_resolution_);
|
23
|
+
ESP_LOGCONFIG(TAG, " RMT symbols: %" PRIu32, this->rmt_symbols_);
|
24
|
+
#else
|
16
25
|
ESP_LOGCONFIG(TAG, " Channel: %d", this->channel_);
|
17
26
|
ESP_LOGCONFIG(TAG, " RMT memory blocks: %d", this->mem_block_num_);
|
18
27
|
ESP_LOGCONFIG(TAG, " Clock divider: %u", this->clock_divider_);
|
28
|
+
#endif
|
19
29
|
LOG_PIN(" Pin: ", this->pin_);
|
20
30
|
|
21
31
|
if (this->current_carrier_frequency_ != 0 && this->carrier_duty_percent_ != 100) {
|
@@ -28,7 +38,105 @@ void RemoteTransmitterComponent::dump_config() {
|
|
28
38
|
}
|
29
39
|
}
|
30
40
|
|
41
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
42
|
+
void RemoteTransmitterComponent::digital_write(bool value) {
|
43
|
+
rmt_symbol_word_t symbol = {
|
44
|
+
.duration0 = 1,
|
45
|
+
.level0 = value,
|
46
|
+
.duration1 = 0,
|
47
|
+
.level1 = value,
|
48
|
+
};
|
49
|
+
rmt_transmit_config_t config;
|
50
|
+
memset(&config, 0, sizeof(config));
|
51
|
+
config.loop_count = 0;
|
52
|
+
config.flags.eot_level = value;
|
53
|
+
esp_err_t error = rmt_transmit(this->channel_, this->encoder_, &symbol, sizeof(symbol), &config);
|
54
|
+
if (error != ESP_OK) {
|
55
|
+
ESP_LOGW(TAG, "rmt_transmit failed: %s", esp_err_to_name(error));
|
56
|
+
this->status_set_warning();
|
57
|
+
}
|
58
|
+
error = rmt_tx_wait_all_done(this->channel_, -1);
|
59
|
+
if (error != ESP_OK) {
|
60
|
+
ESP_LOGW(TAG, "rmt_tx_wait_all_done failed: %s", esp_err_to_name(error));
|
61
|
+
this->status_set_warning();
|
62
|
+
}
|
63
|
+
}
|
64
|
+
#endif
|
65
|
+
|
31
66
|
void RemoteTransmitterComponent::configure_rmt_() {
|
67
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
68
|
+
esp_err_t error;
|
69
|
+
|
70
|
+
if (!this->initialized_) {
|
71
|
+
bool open_drain = (this->pin_->get_flags() & gpio::FLAG_OPEN_DRAIN) != 0;
|
72
|
+
rmt_tx_channel_config_t channel;
|
73
|
+
memset(&channel, 0, sizeof(channel));
|
74
|
+
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
75
|
+
channel.resolution_hz = this->clock_resolution_;
|
76
|
+
channel.gpio_num = gpio_num_t(this->pin_->get_pin());
|
77
|
+
channel.mem_block_symbols = this->rmt_symbols_;
|
78
|
+
channel.trans_queue_depth = 1;
|
79
|
+
channel.flags.io_loop_back = open_drain;
|
80
|
+
channel.flags.io_od_mode = open_drain;
|
81
|
+
channel.flags.invert_out = 0;
|
82
|
+
channel.flags.with_dma = this->with_dma_;
|
83
|
+
channel.intr_priority = 0;
|
84
|
+
error = rmt_new_tx_channel(&channel, &this->channel_);
|
85
|
+
if (error != ESP_OK) {
|
86
|
+
this->error_code_ = error;
|
87
|
+
if (error == ESP_ERR_NOT_FOUND) {
|
88
|
+
this->error_string_ = "out of RMT symbol memory";
|
89
|
+
} else {
|
90
|
+
this->error_string_ = "in rmt_new_tx_channel";
|
91
|
+
}
|
92
|
+
this->mark_failed();
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
if (this->pin_->get_flags() & gpio::FLAG_PULLUP) {
|
96
|
+
gpio_pullup_en(gpio_num_t(this->pin_->get_pin()));
|
97
|
+
} else {
|
98
|
+
gpio_pullup_dis(gpio_num_t(this->pin_->get_pin()));
|
99
|
+
}
|
100
|
+
|
101
|
+
rmt_copy_encoder_config_t encoder;
|
102
|
+
memset(&encoder, 0, sizeof(encoder));
|
103
|
+
error = rmt_new_copy_encoder(&encoder, &this->encoder_);
|
104
|
+
if (error != ESP_OK) {
|
105
|
+
this->error_code_ = error;
|
106
|
+
this->error_string_ = "in rmt_new_copy_encoder";
|
107
|
+
this->mark_failed();
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
|
111
|
+
error = rmt_enable(this->channel_);
|
112
|
+
if (error != ESP_OK) {
|
113
|
+
this->error_code_ = error;
|
114
|
+
this->error_string_ = "in rmt_enable";
|
115
|
+
this->mark_failed();
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
this->digital_write(open_drain || this->inverted_);
|
119
|
+
this->initialized_ = true;
|
120
|
+
}
|
121
|
+
|
122
|
+
if (this->current_carrier_frequency_ == 0 || this->carrier_duty_percent_ == 100) {
|
123
|
+
error = rmt_apply_carrier(this->channel_, nullptr);
|
124
|
+
} else {
|
125
|
+
rmt_carrier_config_t carrier;
|
126
|
+
memset(&carrier, 0, sizeof(carrier));
|
127
|
+
carrier.frequency_hz = this->current_carrier_frequency_;
|
128
|
+
carrier.duty_cycle = (float) this->carrier_duty_percent_ / 100.0f;
|
129
|
+
carrier.flags.polarity_active_low = this->inverted_;
|
130
|
+
carrier.flags.always_on = 1;
|
131
|
+
error = rmt_apply_carrier(this->channel_, &carrier);
|
132
|
+
}
|
133
|
+
if (error != ESP_OK) {
|
134
|
+
this->error_code_ = error;
|
135
|
+
this->error_string_ = "in rmt_apply_carrier";
|
136
|
+
this->mark_failed();
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
#else
|
32
140
|
rmt_config_t c{};
|
33
141
|
|
34
142
|
this->config_rmt(c);
|
@@ -45,13 +153,12 @@ void RemoteTransmitterComponent::configure_rmt_() {
|
|
45
153
|
}
|
46
154
|
|
47
155
|
c.tx_config.idle_output_en = true;
|
48
|
-
if (!this->
|
156
|
+
if (!this->inverted_) {
|
49
157
|
c.tx_config.carrier_level = RMT_CARRIER_LEVEL_HIGH;
|
50
158
|
c.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
|
51
159
|
} else {
|
52
160
|
c.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW;
|
53
161
|
c.tx_config.idle_level = RMT_IDLE_LEVEL_HIGH;
|
54
|
-
this->inverted_ = true;
|
55
162
|
}
|
56
163
|
|
57
164
|
esp_err_t error = rmt_config(&c);
|
@@ -76,6 +183,7 @@ void RemoteTransmitterComponent::configure_rmt_() {
|
|
76
183
|
}
|
77
184
|
this->initialized_ = true;
|
78
185
|
}
|
186
|
+
#endif
|
79
187
|
}
|
80
188
|
|
81
189
|
void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t send_wait) {
|
@@ -90,7 +198,11 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen
|
|
90
198
|
this->rmt_temp_.clear();
|
91
199
|
this->rmt_temp_.reserve((this->temp_.get_data().size() + 1) / 2);
|
92
200
|
uint32_t rmt_i = 0;
|
201
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
202
|
+
rmt_symbol_word_t rmt_item;
|
203
|
+
#else
|
93
204
|
rmt_item32_t rmt_item;
|
205
|
+
#endif
|
94
206
|
|
95
207
|
for (int32_t val : this->temp_.get_data()) {
|
96
208
|
bool level = val >= 0;
|
@@ -125,6 +237,29 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen
|
|
125
237
|
return;
|
126
238
|
}
|
127
239
|
this->transmit_trigger_->trigger();
|
240
|
+
#if ESP_IDF_VERSION_MAJOR >= 5
|
241
|
+
for (uint32_t i = 0; i < send_times; i++) {
|
242
|
+
rmt_transmit_config_t config;
|
243
|
+
memset(&config, 0, sizeof(config));
|
244
|
+
config.loop_count = 0;
|
245
|
+
config.flags.eot_level = this->eot_level_;
|
246
|
+
esp_err_t error = rmt_transmit(this->channel_, this->encoder_, this->rmt_temp_.data(),
|
247
|
+
this->rmt_temp_.size() * sizeof(rmt_symbol_word_t), &config);
|
248
|
+
if (error != ESP_OK) {
|
249
|
+
ESP_LOGW(TAG, "rmt_transmit failed: %s", esp_err_to_name(error));
|
250
|
+
this->status_set_warning();
|
251
|
+
} else {
|
252
|
+
this->status_clear_warning();
|
253
|
+
}
|
254
|
+
error = rmt_tx_wait_all_done(this->channel_, -1);
|
255
|
+
if (error != ESP_OK) {
|
256
|
+
ESP_LOGW(TAG, "rmt_tx_wait_all_done failed: %s", esp_err_to_name(error));
|
257
|
+
this->status_set_warning();
|
258
|
+
}
|
259
|
+
if (i + 1 < send_times)
|
260
|
+
delayMicroseconds(send_wait);
|
261
|
+
}
|
262
|
+
#else
|
128
263
|
for (uint32_t i = 0; i < send_times; i++) {
|
129
264
|
esp_err_t error = rmt_write_items(this->channel_, this->rmt_temp_.data(), this->rmt_temp_.size(), true);
|
130
265
|
if (error != ESP_OK) {
|
@@ -136,6 +271,7 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen
|
|
136
271
|
if (i + 1 < send_times)
|
137
272
|
delayMicroseconds(send_wait);
|
138
273
|
}
|
274
|
+
#endif
|
139
275
|
this->complete_trigger_->trigger();
|
140
276
|
}
|
141
277
|
|
@@ -37,7 +37,7 @@ void RemoteTransmitterComponent::await_target_time_() {
|
|
37
37
|
const uint32_t current_time = micros();
|
38
38
|
if (this->target_time_ == 0) {
|
39
39
|
this->target_time_ = current_time;
|
40
|
-
} else if (this->target_time_
|
40
|
+
} else if ((int32_t) (this->target_time_ - current_time) > 0) {
|
41
41
|
delayMicroseconds(this->target_time_ - current_time);
|
42
42
|
}
|
43
43
|
}
|
@@ -50,13 +50,13 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint
|
|
50
50
|
if (this->carrier_duty_percent_ < 100 && (on_time > 0 || off_time > 0)) {
|
51
51
|
while (true) { // Modulate with carrier frequency
|
52
52
|
this->target_time_ += on_time;
|
53
|
-
if (this->target_time_
|
53
|
+
if ((int32_t) (this->target_time_ - target) >= 0)
|
54
54
|
break;
|
55
55
|
this->await_target_time_();
|
56
56
|
this->pin_->digital_write(false);
|
57
57
|
|
58
58
|
this->target_time_ += off_time;
|
59
|
-
if (this->target_time_
|
59
|
+
if ((int32_t) (this->target_time_ - target) >= 0)
|
60
60
|
break;
|
61
61
|
this->await_target_time_();
|
62
62
|
this->pin_->digital_write(true);
|
@@ -38,7 +38,7 @@ void RemoteTransmitterComponent::await_target_time_() {
|
|
38
38
|
if (this->target_time_ == 0) {
|
39
39
|
this->target_time_ = current_time;
|
40
40
|
} else {
|
41
|
-
while (this->target_time_
|
41
|
+
while ((int32_t) (this->target_time_ - micros()) > 0) {
|
42
42
|
// busy loop that ensures micros is constantly called
|
43
43
|
}
|
44
44
|
}
|
@@ -52,13 +52,13 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint
|
|
52
52
|
if (this->carrier_duty_percent_ < 100 && (on_time > 0 || off_time > 0)) {
|
53
53
|
while (true) { // Modulate with carrier frequency
|
54
54
|
this->target_time_ += on_time;
|
55
|
-
if (this->target_time_
|
55
|
+
if ((int32_t) (this->target_time_ - target) >= 0)
|
56
56
|
break;
|
57
57
|
this->await_target_time_();
|
58
58
|
this->pin_->digital_write(false);
|
59
59
|
|
60
60
|
this->target_time_ += off_time;
|
61
|
-
if (this->target_time_
|
61
|
+
if ((int32_t) (this->target_time_ - target) >= 0)
|
62
62
|
break;
|
63
63
|
this->await_target_time_();
|
64
64
|
this->pin_->digital_write(true);
|
File without changes
|