esphome 2024.12.4__py3-none-any.whl → 2025.2.0b2__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/cse7766/cse7766.cpp +8 -16
- 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/graph/graph.cpp +4 -9
- 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/modbus_controller/text_sensor/modbus_textsensor.cpp +7 -13
- 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 +59 -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.0b2.dist-info}/METADATA +12 -7
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b2.dist-info}/RECORD +341 -292
- 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.0b2.dist-info}/LICENSE +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b2.dist-info}/WHEEL +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b2.dist-info}/entry_points.txt +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,107 @@
|
|
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 resampler {
|
16
|
+
|
17
|
+
class ResamplerSpeaker : public Component, public speaker::Speaker {
|
18
|
+
public:
|
19
|
+
float get_setup_priority() const override { return esphome::setup_priority::DATA; }
|
20
|
+
void setup() override;
|
21
|
+
void loop() override;
|
22
|
+
|
23
|
+
size_t play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) override;
|
24
|
+
size_t play(const uint8_t *data, size_t length) override { return this->play(data, length, 0); }
|
25
|
+
|
26
|
+
void start() override;
|
27
|
+
void stop() override;
|
28
|
+
void finish() override;
|
29
|
+
|
30
|
+
void set_pause_state(bool pause_state) override { this->output_speaker_->set_pause_state(pause_state); }
|
31
|
+
bool get_pause_state() const override { return this->output_speaker_->get_pause_state(); }
|
32
|
+
|
33
|
+
bool has_buffered_data() const override;
|
34
|
+
|
35
|
+
/// @brief Mute state changes are passed to the parent's output speaker
|
36
|
+
void set_mute_state(bool mute_state) override;
|
37
|
+
|
38
|
+
/// @brief Volume state changes are passed to the parent's output speaker
|
39
|
+
void set_volume(float volume) override;
|
40
|
+
|
41
|
+
void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; }
|
42
|
+
void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; }
|
43
|
+
|
44
|
+
void set_target_bits_per_sample(uint8_t target_bits_per_sample) {
|
45
|
+
this->target_bits_per_sample_ = target_bits_per_sample;
|
46
|
+
}
|
47
|
+
void set_target_sample_rate(uint32_t target_sample_rate) { this->target_sample_rate_ = target_sample_rate; }
|
48
|
+
|
49
|
+
void set_filters(uint16_t filters) { this->filters_ = filters; }
|
50
|
+
void set_taps(uint16_t taps) { this->taps_ = taps; }
|
51
|
+
|
52
|
+
void set_buffer_duration(uint32_t buffer_duration_ms) { this->buffer_duration_ms_ = buffer_duration_ms; }
|
53
|
+
|
54
|
+
protected:
|
55
|
+
/// @brief Starts the output speaker after setting the resampled stream info. If resampling is required, it starts the
|
56
|
+
/// task.
|
57
|
+
/// @return ESP_OK if resampling is required
|
58
|
+
/// return value of start_task_() if resampling is required
|
59
|
+
esp_err_t start_();
|
60
|
+
|
61
|
+
/// @brief Starts the resampler task after allocating the task stack
|
62
|
+
/// @return ESP_OK if successful,
|
63
|
+
/// ESP_ERR_NO_MEM if the task stack couldn't be allocated
|
64
|
+
/// ESP_ERR_INVALID_STATE if the task wasn't created
|
65
|
+
esp_err_t start_task_();
|
66
|
+
|
67
|
+
/// @brief Stops the output speaker. If the resampling task is running, it sends the stop command.
|
68
|
+
void stop_();
|
69
|
+
|
70
|
+
/// @brief Deallocates the task stack and resets the pointers.
|
71
|
+
/// @return ESP_OK if successful
|
72
|
+
/// ESP_ERR_INVALID_STATE if the task hasn't stopped itself
|
73
|
+
esp_err_t delete_task_();
|
74
|
+
|
75
|
+
inline bool requires_resampling_() const;
|
76
|
+
static void resample_task(void *params);
|
77
|
+
|
78
|
+
EventGroupHandle_t event_group_{nullptr};
|
79
|
+
|
80
|
+
std::weak_ptr<RingBuffer> ring_buffer_;
|
81
|
+
|
82
|
+
speaker::Speaker *output_speaker_{nullptr};
|
83
|
+
|
84
|
+
bool task_stack_in_psram_{false};
|
85
|
+
bool task_created_{false};
|
86
|
+
|
87
|
+
TaskHandle_t task_handle_{nullptr};
|
88
|
+
StaticTask_t task_stack_;
|
89
|
+
StackType_t *task_stack_buffer_{nullptr};
|
90
|
+
|
91
|
+
audio::AudioStreamInfo target_stream_info_;
|
92
|
+
|
93
|
+
uint16_t taps_;
|
94
|
+
uint16_t filters_;
|
95
|
+
|
96
|
+
uint8_t target_bits_per_sample_;
|
97
|
+
uint32_t target_sample_rate_;
|
98
|
+
|
99
|
+
uint32_t buffer_duration_ms_;
|
100
|
+
|
101
|
+
int32_t playback_differential_ms_{0};
|
102
|
+
};
|
103
|
+
|
104
|
+
} // namespace resampler
|
105
|
+
} // namespace esphome
|
106
|
+
|
107
|
+
#endif
|
@@ -1,8 +1,7 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
-
#include "esphome/components/resistance_sampler/resistance_sampler.h"
|
4
|
-
#include "esphome/components/sensor/sensor.h"
|
5
3
|
#include "esphome/core/component.h"
|
4
|
+
#include "esphome/components/sensor/sensor.h"
|
6
5
|
|
7
6
|
namespace esphome {
|
8
7
|
namespace resistance {
|
@@ -12,7 +11,7 @@ enum ResistanceConfiguration {
|
|
12
11
|
DOWNSTREAM,
|
13
12
|
};
|
14
13
|
|
15
|
-
class ResistanceSensor : public Component, public sensor::Sensor
|
14
|
+
class ResistanceSensor : public Component, public sensor::Sensor {
|
16
15
|
public:
|
17
16
|
void set_sensor(Sensor *sensor) { sensor_ = sensor; }
|
18
17
|
void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import esphome.codegen as cg
|
2
2
|
import esphome.config_validation as cv
|
3
|
-
from esphome.components import sensor
|
3
|
+
from esphome.components import sensor
|
4
4
|
from esphome.const import (
|
5
5
|
CONF_REFERENCE_VOLTAGE,
|
6
6
|
CONF_SENSOR,
|
@@ -9,15 +9,8 @@ from esphome.const import (
|
|
9
9
|
ICON_FLASH,
|
10
10
|
)
|
11
11
|
|
12
|
-
AUTO_LOAD = ["resistance_sampler"]
|
13
|
-
|
14
12
|
resistance_ns = cg.esphome_ns.namespace("resistance")
|
15
|
-
ResistanceSensor = resistance_ns.class_(
|
16
|
-
"ResistanceSensor",
|
17
|
-
cg.Component,
|
18
|
-
sensor.Sensor,
|
19
|
-
resistance_sampler.ResistanceSampler,
|
20
|
-
)
|
13
|
+
ResistanceSensor = resistance_ns.class_("ResistanceSensor", cg.Component, sensor.Sensor)
|
21
14
|
|
22
15
|
CONF_CONFIGURATION = "configuration"
|
23
16
|
CONF_RESISTOR = "resistor"
|
@@ -93,13 +93,17 @@ void IRAM_ATTR HOT RotaryEncoderSensorStore::gpio_intr(RotaryEncoderSensorStore
|
|
93
93
|
int8_t rotation_dir = 0;
|
94
94
|
uint16_t new_state = STATE_LOOKUP_TABLE[input_state];
|
95
95
|
if ((new_state & arg->resolution & STATE_HAS_INCREMENTED) != 0) {
|
96
|
-
if (arg->counter < arg->max_value)
|
97
|
-
arg->counter
|
96
|
+
if (arg->counter < arg->max_value) {
|
97
|
+
auto x = arg->counter + 1;
|
98
|
+
arg->counter = x;
|
99
|
+
}
|
98
100
|
rotation_dir = 1;
|
99
101
|
}
|
100
102
|
if ((new_state & arg->resolution & STATE_HAS_DECREMENTED) != 0) {
|
101
|
-
if (arg->counter > arg->min_value)
|
102
|
-
arg->counter
|
103
|
+
if (arg->counter > arg->min_value) {
|
104
|
+
auto x = arg->counter - 1;
|
105
|
+
arg->counter = x;
|
106
|
+
}
|
103
107
|
rotation_dir = -1;
|
104
108
|
}
|
105
109
|
|
esphome/components/rp2040/gpio.h
CHANGED
@@ -22,6 +22,7 @@ class RP2040GPIOPin : public InternalGPIOPin {
|
|
22
22
|
void detach_interrupt() const override;
|
23
23
|
ISRInternalGPIOPin to_isr() const override;
|
24
24
|
uint8_t get_pin() const override { return pin_; }
|
25
|
+
gpio::Flags get_flags() const override { return flags_; }
|
25
26
|
bool is_inverted() const override { return inverted_; }
|
26
27
|
|
27
28
|
protected:
|
@@ -0,0 +1,270 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import binary_sensor
|
3
|
+
from esphome.components.binary_sensor import BinarySensor
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import CONF_KEY
|
6
|
+
from esphome.core import Lambda
|
7
|
+
from esphome.cpp_generator import ExpressionStatement, RawExpression
|
8
|
+
|
9
|
+
from .display import CONF_SDL_ID, Sdl
|
10
|
+
|
11
|
+
CODEOWNERS = ["@bdm310"]
|
12
|
+
|
13
|
+
STATE_ARG = "state"
|
14
|
+
|
15
|
+
SDL_KEYMAP = {
|
16
|
+
"SDLK_UNKNOWN": 0,
|
17
|
+
"SDLK_FIRST": 0,
|
18
|
+
"SDLK_BACKSPACE": 8,
|
19
|
+
"SDLK_TAB": 9,
|
20
|
+
"SDLK_CLEAR": 12,
|
21
|
+
"SDLK_RETURN": 13,
|
22
|
+
"SDLK_PAUSE": 19,
|
23
|
+
"SDLK_ESCAPE": 27,
|
24
|
+
"SDLK_SPACE": 32,
|
25
|
+
"SDLK_EXCLAIM": 33,
|
26
|
+
"SDLK_QUOTEDBL": 34,
|
27
|
+
"SDLK_HASH": 35,
|
28
|
+
"SDLK_DOLLAR": 36,
|
29
|
+
"SDLK_AMPERSAND": 38,
|
30
|
+
"SDLK_QUOTE": 39,
|
31
|
+
"SDLK_LEFTPAREN": 40,
|
32
|
+
"SDLK_RIGHTPAREN": 41,
|
33
|
+
"SDLK_ASTERISK": 42,
|
34
|
+
"SDLK_PLUS": 43,
|
35
|
+
"SDLK_COMMA": 44,
|
36
|
+
"SDLK_MINUS": 45,
|
37
|
+
"SDLK_PERIOD": 46,
|
38
|
+
"SDLK_SLASH": 47,
|
39
|
+
"SDLK_0": 48,
|
40
|
+
"SDLK_1": 49,
|
41
|
+
"SDLK_2": 50,
|
42
|
+
"SDLK_3": 51,
|
43
|
+
"SDLK_4": 52,
|
44
|
+
"SDLK_5": 53,
|
45
|
+
"SDLK_6": 54,
|
46
|
+
"SDLK_7": 55,
|
47
|
+
"SDLK_8": 56,
|
48
|
+
"SDLK_9": 57,
|
49
|
+
"SDLK_COLON": 58,
|
50
|
+
"SDLK_SEMICOLON": 59,
|
51
|
+
"SDLK_LESS": 60,
|
52
|
+
"SDLK_EQUALS": 61,
|
53
|
+
"SDLK_GREATER": 62,
|
54
|
+
"SDLK_QUESTION": 63,
|
55
|
+
"SDLK_AT": 64,
|
56
|
+
"SDLK_LEFTBRACKET": 91,
|
57
|
+
"SDLK_BACKSLASH": 92,
|
58
|
+
"SDLK_RIGHTBRACKET": 93,
|
59
|
+
"SDLK_CARET": 94,
|
60
|
+
"SDLK_UNDERSCORE": 95,
|
61
|
+
"SDLK_BACKQUOTE": 96,
|
62
|
+
"SDLK_a": 97,
|
63
|
+
"SDLK_b": 98,
|
64
|
+
"SDLK_c": 99,
|
65
|
+
"SDLK_d": 100,
|
66
|
+
"SDLK_e": 101,
|
67
|
+
"SDLK_f": 102,
|
68
|
+
"SDLK_g": 103,
|
69
|
+
"SDLK_h": 104,
|
70
|
+
"SDLK_i": 105,
|
71
|
+
"SDLK_j": 106,
|
72
|
+
"SDLK_k": 107,
|
73
|
+
"SDLK_l": 108,
|
74
|
+
"SDLK_m": 109,
|
75
|
+
"SDLK_n": 110,
|
76
|
+
"SDLK_o": 111,
|
77
|
+
"SDLK_p": 112,
|
78
|
+
"SDLK_q": 113,
|
79
|
+
"SDLK_r": 114,
|
80
|
+
"SDLK_s": 115,
|
81
|
+
"SDLK_t": 116,
|
82
|
+
"SDLK_u": 117,
|
83
|
+
"SDLK_v": 118,
|
84
|
+
"SDLK_w": 119,
|
85
|
+
"SDLK_x": 120,
|
86
|
+
"SDLK_y": 121,
|
87
|
+
"SDLK_z": 122,
|
88
|
+
"SDLK_DELETE": 127,
|
89
|
+
"SDLK_WORLD_0": 160,
|
90
|
+
"SDLK_WORLD_1": 161,
|
91
|
+
"SDLK_WORLD_2": 162,
|
92
|
+
"SDLK_WORLD_3": 163,
|
93
|
+
"SDLK_WORLD_4": 164,
|
94
|
+
"SDLK_WORLD_5": 165,
|
95
|
+
"SDLK_WORLD_6": 166,
|
96
|
+
"SDLK_WORLD_7": 167,
|
97
|
+
"SDLK_WORLD_8": 168,
|
98
|
+
"SDLK_WORLD_9": 169,
|
99
|
+
"SDLK_WORLD_10": 170,
|
100
|
+
"SDLK_WORLD_11": 171,
|
101
|
+
"SDLK_WORLD_12": 172,
|
102
|
+
"SDLK_WORLD_13": 173,
|
103
|
+
"SDLK_WORLD_14": 174,
|
104
|
+
"SDLK_WORLD_15": 175,
|
105
|
+
"SDLK_WORLD_16": 176,
|
106
|
+
"SDLK_WORLD_17": 177,
|
107
|
+
"SDLK_WORLD_18": 178,
|
108
|
+
"SDLK_WORLD_19": 179,
|
109
|
+
"SDLK_WORLD_20": 180,
|
110
|
+
"SDLK_WORLD_21": 181,
|
111
|
+
"SDLK_WORLD_22": 182,
|
112
|
+
"SDLK_WORLD_23": 183,
|
113
|
+
"SDLK_WORLD_24": 184,
|
114
|
+
"SDLK_WORLD_25": 185,
|
115
|
+
"SDLK_WORLD_26": 186,
|
116
|
+
"SDLK_WORLD_27": 187,
|
117
|
+
"SDLK_WORLD_28": 188,
|
118
|
+
"SDLK_WORLD_29": 189,
|
119
|
+
"SDLK_WORLD_30": 190,
|
120
|
+
"SDLK_WORLD_31": 191,
|
121
|
+
"SDLK_WORLD_32": 192,
|
122
|
+
"SDLK_WORLD_33": 193,
|
123
|
+
"SDLK_WORLD_34": 194,
|
124
|
+
"SDLK_WORLD_35": 195,
|
125
|
+
"SDLK_WORLD_36": 196,
|
126
|
+
"SDLK_WORLD_37": 197,
|
127
|
+
"SDLK_WORLD_38": 198,
|
128
|
+
"SDLK_WORLD_39": 199,
|
129
|
+
"SDLK_WORLD_40": 200,
|
130
|
+
"SDLK_WORLD_41": 201,
|
131
|
+
"SDLK_WORLD_42": 202,
|
132
|
+
"SDLK_WORLD_43": 203,
|
133
|
+
"SDLK_WORLD_44": 204,
|
134
|
+
"SDLK_WORLD_45": 205,
|
135
|
+
"SDLK_WORLD_46": 206,
|
136
|
+
"SDLK_WORLD_47": 207,
|
137
|
+
"SDLK_WORLD_48": 208,
|
138
|
+
"SDLK_WORLD_49": 209,
|
139
|
+
"SDLK_WORLD_50": 210,
|
140
|
+
"SDLK_WORLD_51": 211,
|
141
|
+
"SDLK_WORLD_52": 212,
|
142
|
+
"SDLK_WORLD_53": 213,
|
143
|
+
"SDLK_WORLD_54": 214,
|
144
|
+
"SDLK_WORLD_55": 215,
|
145
|
+
"SDLK_WORLD_56": 216,
|
146
|
+
"SDLK_WORLD_57": 217,
|
147
|
+
"SDLK_WORLD_58": 218,
|
148
|
+
"SDLK_WORLD_59": 219,
|
149
|
+
"SDLK_WORLD_60": 220,
|
150
|
+
"SDLK_WORLD_61": 221,
|
151
|
+
"SDLK_WORLD_62": 222,
|
152
|
+
"SDLK_WORLD_63": 223,
|
153
|
+
"SDLK_WORLD_64": 224,
|
154
|
+
"SDLK_WORLD_65": 225,
|
155
|
+
"SDLK_WORLD_66": 226,
|
156
|
+
"SDLK_WORLD_67": 227,
|
157
|
+
"SDLK_WORLD_68": 228,
|
158
|
+
"SDLK_WORLD_69": 229,
|
159
|
+
"SDLK_WORLD_70": 230,
|
160
|
+
"SDLK_WORLD_71": 231,
|
161
|
+
"SDLK_WORLD_72": 232,
|
162
|
+
"SDLK_WORLD_73": 233,
|
163
|
+
"SDLK_WORLD_74": 234,
|
164
|
+
"SDLK_WORLD_75": 235,
|
165
|
+
"SDLK_WORLD_76": 236,
|
166
|
+
"SDLK_WORLD_77": 237,
|
167
|
+
"SDLK_WORLD_78": 238,
|
168
|
+
"SDLK_WORLD_79": 239,
|
169
|
+
"SDLK_WORLD_80": 240,
|
170
|
+
"SDLK_WORLD_81": 241,
|
171
|
+
"SDLK_WORLD_82": 242,
|
172
|
+
"SDLK_WORLD_83": 243,
|
173
|
+
"SDLK_WORLD_84": 244,
|
174
|
+
"SDLK_WORLD_85": 245,
|
175
|
+
"SDLK_WORLD_86": 246,
|
176
|
+
"SDLK_WORLD_87": 247,
|
177
|
+
"SDLK_WORLD_88": 248,
|
178
|
+
"SDLK_WORLD_89": 249,
|
179
|
+
"SDLK_WORLD_90": 250,
|
180
|
+
"SDLK_WORLD_91": 251,
|
181
|
+
"SDLK_WORLD_92": 252,
|
182
|
+
"SDLK_WORLD_93": 253,
|
183
|
+
"SDLK_WORLD_94": 254,
|
184
|
+
"SDLK_WORLD_95": 255,
|
185
|
+
"SDLK_KP0": 256,
|
186
|
+
"SDLK_KP1": 257,
|
187
|
+
"SDLK_KP2": 258,
|
188
|
+
"SDLK_KP3": 259,
|
189
|
+
"SDLK_KP4": 260,
|
190
|
+
"SDLK_KP5": 261,
|
191
|
+
"SDLK_KP6": 262,
|
192
|
+
"SDLK_KP7": 263,
|
193
|
+
"SDLK_KP8": 264,
|
194
|
+
"SDLK_KP9": 265,
|
195
|
+
"SDLK_KP_PERIOD": 266,
|
196
|
+
"SDLK_KP_DIVIDE": 267,
|
197
|
+
"SDLK_KP_MULTIPLY": 268,
|
198
|
+
"SDLK_KP_MINUS": 269,
|
199
|
+
"SDLK_KP_PLUS": 270,
|
200
|
+
"SDLK_KP_ENTER": 271,
|
201
|
+
"SDLK_KP_EQUALS": 272,
|
202
|
+
"SDLK_UP": 273,
|
203
|
+
"SDLK_DOWN": 274,
|
204
|
+
"SDLK_RIGHT": 275,
|
205
|
+
"SDLK_LEFT": 276,
|
206
|
+
"SDLK_INSERT": 277,
|
207
|
+
"SDLK_HOME": 278,
|
208
|
+
"SDLK_END": 279,
|
209
|
+
"SDLK_PAGEUP": 280,
|
210
|
+
"SDLK_PAGEDOWN": 281,
|
211
|
+
"SDLK_F1": 282,
|
212
|
+
"SDLK_F2": 283,
|
213
|
+
"SDLK_F3": 284,
|
214
|
+
"SDLK_F4": 285,
|
215
|
+
"SDLK_F5": 286,
|
216
|
+
"SDLK_F6": 287,
|
217
|
+
"SDLK_F7": 288,
|
218
|
+
"SDLK_F8": 289,
|
219
|
+
"SDLK_F9": 290,
|
220
|
+
"SDLK_F10": 291,
|
221
|
+
"SDLK_F11": 292,
|
222
|
+
"SDLK_F12": 293,
|
223
|
+
"SDLK_F13": 294,
|
224
|
+
"SDLK_F14": 295,
|
225
|
+
"SDLK_F15": 296,
|
226
|
+
"SDLK_NUMLOCK": 300,
|
227
|
+
"SDLK_CAPSLOCK": 301,
|
228
|
+
"SDLK_SCROLLOCK": 302,
|
229
|
+
"SDLK_RSHIFT": 303,
|
230
|
+
"SDLK_LSHIFT": 304,
|
231
|
+
"SDLK_RCTRL": 305,
|
232
|
+
"SDLK_LCTRL": 306,
|
233
|
+
"SDLK_RALT": 307,
|
234
|
+
"SDLK_LALT": 308,
|
235
|
+
"SDLK_RMETA": 309,
|
236
|
+
"SDLK_LMETA": 310,
|
237
|
+
"SDLK_LSUPER": 311,
|
238
|
+
"SDLK_RSUPER": 312,
|
239
|
+
"SDLK_MODE": 313,
|
240
|
+
"SDLK_COMPOSE": 314,
|
241
|
+
"SDLK_HELP": 315,
|
242
|
+
"SDLK_PRINT": 316,
|
243
|
+
"SDLK_SYSREQ": 317,
|
244
|
+
"SDLK_BREAK": 318,
|
245
|
+
"SDLK_MENU": 319,
|
246
|
+
"SDLK_POWER": 320,
|
247
|
+
"SDLK_EURO": 321,
|
248
|
+
"SDLK_UNDO": 322,
|
249
|
+
}
|
250
|
+
|
251
|
+
CONFIG_SCHEMA = (
|
252
|
+
binary_sensor.binary_sensor_schema(BinarySensor)
|
253
|
+
.extend(
|
254
|
+
{
|
255
|
+
cv.Required(CONF_KEY): cv.enum(SDL_KEYMAP),
|
256
|
+
cv.GenerateID(CONF_SDL_ID): cv.use_id(Sdl),
|
257
|
+
}
|
258
|
+
)
|
259
|
+
.extend(cv.COMPONENT_SCHEMA)
|
260
|
+
)
|
261
|
+
|
262
|
+
|
263
|
+
async def to_code(config):
|
264
|
+
var = await binary_sensor.new_binary_sensor(config)
|
265
|
+
parent = await cg.get_variable(config[CONF_SDL_ID])
|
266
|
+
listener = Lambda(
|
267
|
+
str(ExpressionStatement(var.publish_state(RawExpression(STATE_ARG))))
|
268
|
+
)
|
269
|
+
listener = await cg.process_lambda(listener, [(cg.bool_, STATE_ARG)])
|
270
|
+
cg.add(parent.add_key_listener(config[CONF_KEY], listener))
|
@@ -61,6 +61,12 @@ void Sdl::draw_pixel_at(int x, int y, Color color) {
|
|
61
61
|
this->y_high_ = y;
|
62
62
|
}
|
63
63
|
|
64
|
+
void Sdl::process_key(uint32_t keycode, bool down) {
|
65
|
+
auto callback = this->key_callbacks_.find(keycode);
|
66
|
+
if (callback != this->key_callbacks_.end())
|
67
|
+
callback->second(down);
|
68
|
+
}
|
69
|
+
|
64
70
|
void Sdl::loop() {
|
65
71
|
SDL_Event e;
|
66
72
|
if (SDL_PollEvent(&e)) {
|
@@ -87,6 +93,16 @@ void Sdl::loop() {
|
|
87
93
|
}
|
88
94
|
break;
|
89
95
|
|
96
|
+
case SDL_KEYDOWN:
|
97
|
+
ESP_LOGD(TAG, "keydown %d", e.key.keysym.sym);
|
98
|
+
this->process_key(e.key.keysym.sym, true);
|
99
|
+
break;
|
100
|
+
|
101
|
+
case SDL_KEYUP:
|
102
|
+
ESP_LOGD(TAG, "keyup %d", e.key.keysym.sym);
|
103
|
+
this->process_key(e.key.keysym.sym, false);
|
104
|
+
break;
|
105
|
+
|
90
106
|
case SDL_WINDOWEVENT:
|
91
107
|
switch (e.window.event) {
|
92
108
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
@@ -7,6 +7,7 @@
|
|
7
7
|
#include "esphome/components/display/display.h"
|
8
8
|
#define SDL_MAIN_HANDLED
|
9
9
|
#include "SDL.h"
|
10
|
+
#include <map>
|
10
11
|
|
11
12
|
namespace esphome {
|
12
13
|
namespace sdl {
|
@@ -22,6 +23,7 @@ class Sdl : public display::Display {
|
|
22
23
|
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order,
|
23
24
|
display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override;
|
24
25
|
void draw_pixel_at(int x, int y, Color color) override;
|
26
|
+
void process_key(uint32_t keycode, bool down);
|
25
27
|
void set_dimensions(uint16_t width, uint16_t height) {
|
26
28
|
this->width_ = width;
|
27
29
|
this->height_ = height;
|
@@ -30,6 +32,12 @@ class Sdl : public display::Display {
|
|
30
32
|
int get_height() override { return this->height_; }
|
31
33
|
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
32
34
|
void dump_config() override { LOG_DISPLAY("", "SDL", this); }
|
35
|
+
void add_key_listener(int32_t keycode, std::function<void(bool)> &&callback) {
|
36
|
+
if (!this->key_callbacks_.count(keycode)) {
|
37
|
+
this->key_callbacks_[keycode] = CallbackManager<void(bool)>();
|
38
|
+
}
|
39
|
+
this->key_callbacks_[keycode].add(std::move(callback));
|
40
|
+
}
|
33
41
|
|
34
42
|
int mouse_x{};
|
35
43
|
int mouse_y{};
|
@@ -48,6 +56,7 @@ class Sdl : public display::Display {
|
|
48
56
|
uint16_t y_low_{0};
|
49
57
|
uint16_t x_high_{0};
|
50
58
|
uint16_t y_high_{0};
|
59
|
+
std::map<int32_t, CallbackManager<void(bool)>> key_callbacks_{};
|
51
60
|
};
|
52
61
|
} // namespace sdl
|
53
62
|
} // namespace esphome
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import esphome.codegen as cg
|
2
|
+
from esphome.components import binary_sensor
|
3
|
+
import esphome.config_validation as cv
|
4
|
+
from esphome.const import (
|
5
|
+
DEVICE_CLASS_OCCUPANCY,
|
6
|
+
CONF_HAS_TARGET,
|
7
|
+
)
|
8
|
+
from . import CONF_MR60BHA2_ID, MR60BHA2Component
|
9
|
+
|
10
|
+
DEPENDENCIES = ["seeed_mr60bha2"]
|
11
|
+
|
12
|
+
CONFIG_SCHEMA = {
|
13
|
+
cv.GenerateID(CONF_MR60BHA2_ID): cv.use_id(MR60BHA2Component),
|
14
|
+
cv.Optional(CONF_HAS_TARGET): binary_sensor.binary_sensor_schema(
|
15
|
+
device_class=DEVICE_CLASS_OCCUPANCY, icon="mdi:motion-sensor"
|
16
|
+
),
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
async def to_code(config):
|
21
|
+
mr60bha2_component = await cg.get_variable(config[CONF_MR60BHA2_ID])
|
22
|
+
|
23
|
+
if has_target_config := config.get(CONF_HAS_TARGET):
|
24
|
+
sens = await binary_sensor.new_binary_sensor(has_target_config)
|
25
|
+
cg.add(mr60bha2_component.set_has_target_binary_sensor(sens))
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "seeed_mr60bha2.h"
|
2
2
|
#include "esphome/core/log.h"
|
3
3
|
|
4
|
+
#include <cinttypes>
|
4
5
|
#include <utility>
|
5
6
|
|
6
7
|
namespace esphome {
|
@@ -12,10 +13,14 @@ static const char *const TAG = "seeed_mr60bha2";
|
|
12
13
|
// items in an easy-to-read format, including the configuration key-value pairs.
|
13
14
|
void MR60BHA2Component::dump_config() {
|
14
15
|
ESP_LOGCONFIG(TAG, "MR60BHA2:");
|
16
|
+
#ifdef USE_BINARY_SENSOR
|
17
|
+
LOG_BINARY_SENSOR(" ", "People Exist Binary Sensor", this->has_target_binary_sensor_);
|
18
|
+
#endif
|
15
19
|
#ifdef USE_SENSOR
|
16
20
|
LOG_SENSOR(" ", "Breath Rate Sensor", this->breath_rate_sensor_);
|
17
21
|
LOG_SENSOR(" ", "Heart Rate Sensor", this->heart_rate_sensor_);
|
18
22
|
LOG_SENSOR(" ", "Distance Sensor", this->distance_sensor_);
|
23
|
+
LOG_SENSOR(" ", "Target Number Sensor", this->num_targets_sensor_);
|
19
24
|
#endif
|
20
25
|
}
|
21
26
|
|
@@ -94,7 +99,8 @@ bool MR60BHA2Component::validate_message_() {
|
|
94
99
|
uint16_t frame_type = encode_uint16(data[5], data[6]);
|
95
100
|
|
96
101
|
if (frame_type != BREATH_RATE_TYPE_BUFFER && frame_type != HEART_RATE_TYPE_BUFFER &&
|
97
|
-
frame_type != DISTANCE_TYPE_BUFFER
|
102
|
+
frame_type != DISTANCE_TYPE_BUFFER && frame_type != PEOPLE_EXIST_TYPE_BUFFER &&
|
103
|
+
frame_type != PRINT_CLOUD_BUFFER) {
|
98
104
|
return false;
|
99
105
|
}
|
100
106
|
|
@@ -144,6 +150,18 @@ void MR60BHA2Component::process_frame_(uint16_t frame_id, uint16_t frame_type, c
|
|
144
150
|
}
|
145
151
|
}
|
146
152
|
break;
|
153
|
+
case PEOPLE_EXIST_TYPE_BUFFER:
|
154
|
+
if (this->has_target_binary_sensor_ != nullptr && length >= 2) {
|
155
|
+
uint16_t has_target_int = encode_uint16(data[1], data[0]);
|
156
|
+
this->has_target_binary_sensor_->publish_state(has_target_int);
|
157
|
+
if (has_target_int == 0) {
|
158
|
+
this->breath_rate_sensor_->publish_state(0.0);
|
159
|
+
this->heart_rate_sensor_->publish_state(0.0);
|
160
|
+
this->distance_sensor_->publish_state(0.0);
|
161
|
+
this->num_targets_sensor_->publish_state(0);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
break;
|
147
165
|
case HEART_RATE_TYPE_BUFFER:
|
148
166
|
if (this->heart_rate_sensor_ != nullptr && length >= 4) {
|
149
167
|
uint32_t current_heart_rate_int = encode_uint32(data[3], data[2], data[1], data[0]);
|
@@ -155,7 +173,7 @@ void MR60BHA2Component::process_frame_(uint16_t frame_id, uint16_t frame_type, c
|
|
155
173
|
}
|
156
174
|
break;
|
157
175
|
case DISTANCE_TYPE_BUFFER:
|
158
|
-
if (
|
176
|
+
if (data[0] != 0) {
|
159
177
|
if (this->distance_sensor_ != nullptr && length >= 8) {
|
160
178
|
uint32_t current_distance_int = encode_uint32(data[7], data[6], data[5], data[4]);
|
161
179
|
float distance_float;
|
@@ -164,6 +182,12 @@ void MR60BHA2Component::process_frame_(uint16_t frame_id, uint16_t frame_type, c
|
|
164
182
|
}
|
165
183
|
}
|
166
184
|
break;
|
185
|
+
case PRINT_CLOUD_BUFFER:
|
186
|
+
if (this->num_targets_sensor_ != nullptr && length >= 4) {
|
187
|
+
uint32_t current_num_targets_int = encode_uint32(data[3], data[2], data[1], data[0]);
|
188
|
+
this->num_targets_sensor_->publish_state(current_num_targets_int);
|
189
|
+
}
|
190
|
+
break;
|
167
191
|
default:
|
168
192
|
break;
|
169
193
|
}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
#pragma once
|
2
2
|
#include "esphome/core/component.h"
|
3
3
|
#include "esphome/core/defines.h"
|
4
|
+
#ifdef USE_BINARY_SENSOR
|
5
|
+
#include "esphome/components/binary_sensor/binary_sensor.h"
|
6
|
+
#endif
|
4
7
|
#ifdef USE_SENSOR
|
5
8
|
#include "esphome/components/sensor/sensor.h"
|
6
9
|
#endif
|
@@ -12,37 +15,23 @@
|
|
12
15
|
|
13
16
|
namespace esphome {
|
14
17
|
namespace seeed_mr60bha2 {
|
15
|
-
|
16
|
-
static const uint8_t DATA_BUF_MAX_SIZE = 12;
|
17
|
-
static const uint8_t FRAME_BUF_MAX_SIZE = 21;
|
18
|
-
static const uint8_t LEN_TO_HEAD_CKSUM = 8;
|
19
|
-
static const uint8_t LEN_TO_DATA_FRAME = 9;
|
20
|
-
|
21
18
|
static const uint8_t FRAME_HEADER_BUFFER = 0x01;
|
22
19
|
static const uint16_t BREATH_RATE_TYPE_BUFFER = 0x0A14;
|
20
|
+
static const uint16_t PEOPLE_EXIST_TYPE_BUFFER = 0x0F09;
|
23
21
|
static const uint16_t HEART_RATE_TYPE_BUFFER = 0x0A15;
|
24
22
|
static const uint16_t DISTANCE_TYPE_BUFFER = 0x0A16;
|
25
|
-
|
26
|
-
enum FrameLocation {
|
27
|
-
LOCATE_FRAME_HEADER,
|
28
|
-
LOCATE_ID_FRAME1,
|
29
|
-
LOCATE_ID_FRAME2,
|
30
|
-
LOCATE_LENGTH_FRAME_H,
|
31
|
-
LOCATE_LENGTH_FRAME_L,
|
32
|
-
LOCATE_TYPE_FRAME1,
|
33
|
-
LOCATE_TYPE_FRAME2,
|
34
|
-
LOCATE_HEAD_CKSUM_FRAME, // Header checksum: [from the first byte to the previous byte of the HEAD_CKSUM bit]
|
35
|
-
LOCATE_DATA_FRAME,
|
36
|
-
LOCATE_DATA_CKSUM_FRAME, // Data checksum: [from the first to the previous byte of the DATA_CKSUM bit]
|
37
|
-
LOCATE_PROCESS_FRAME,
|
38
|
-
};
|
23
|
+
static const uint16_t PRINT_CLOUD_BUFFER = 0x0A04;
|
39
24
|
|
40
25
|
class MR60BHA2Component : public Component,
|
41
26
|
public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
|
27
|
+
#ifdef USE_BINARY_SENSOR
|
28
|
+
SUB_BINARY_SENSOR(has_target);
|
29
|
+
#endif
|
42
30
|
#ifdef USE_SENSOR
|
43
31
|
SUB_SENSOR(breath_rate);
|
44
32
|
SUB_SENSOR(heart_rate);
|
45
33
|
SUB_SENSOR(distance);
|
34
|
+
SUB_SENSOR(num_targets);
|
46
35
|
#endif
|
47
36
|
|
48
37
|
public:
|