mirror of
https://github.com/esphome/esphome.git
synced 2025-07-31 07:36:35 +00:00
Merge branch 'dev' into api_heap_churn_info
This commit is contained in:
commit
5c5f29fbc8
@ -1 +1 @@
|
|||||||
b7056e39f1484500ca2d237068670b789fe9241786b48da0681d646b25af05d5
|
f84518ea4140c194b21cc516aae05aaa0cf876ab866f89e22e91842df46333ed
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from esphome import pins
|
from esphome import pins
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components.esp32 import get_esp32_variant
|
from esphome.components.esp32 import VARIANT_ESP32P4, get_esp32_variant
|
||||||
from esphome.components.esp32.const import (
|
from esphome.components.esp32.const import (
|
||||||
VARIANT_ESP32,
|
VARIANT_ESP32,
|
||||||
VARIANT_ESP32C2,
|
VARIANT_ESP32C2,
|
||||||
@ -140,6 +140,16 @@ ESP32_VARIANT_ADC1_PIN_TO_CHANNEL = {
|
|||||||
9: adc_channel_t.ADC_CHANNEL_8,
|
9: adc_channel_t.ADC_CHANNEL_8,
|
||||||
10: adc_channel_t.ADC_CHANNEL_9,
|
10: adc_channel_t.ADC_CHANNEL_9,
|
||||||
},
|
},
|
||||||
|
VARIANT_ESP32P4: {
|
||||||
|
16: adc_channel_t.ADC_CHANNEL_0,
|
||||||
|
17: adc_channel_t.ADC_CHANNEL_1,
|
||||||
|
18: adc_channel_t.ADC_CHANNEL_2,
|
||||||
|
19: adc_channel_t.ADC_CHANNEL_3,
|
||||||
|
20: adc_channel_t.ADC_CHANNEL_4,
|
||||||
|
21: adc_channel_t.ADC_CHANNEL_5,
|
||||||
|
22: adc_channel_t.ADC_CHANNEL_6,
|
||||||
|
23: adc_channel_t.ADC_CHANNEL_7,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# pin to adc2 channel mapping
|
# pin to adc2 channel mapping
|
||||||
@ -198,6 +208,14 @@ ESP32_VARIANT_ADC2_PIN_TO_CHANNEL = {
|
|||||||
19: adc_channel_t.ADC_CHANNEL_8,
|
19: adc_channel_t.ADC_CHANNEL_8,
|
||||||
20: adc_channel_t.ADC_CHANNEL_9,
|
20: adc_channel_t.ADC_CHANNEL_9,
|
||||||
},
|
},
|
||||||
|
VARIANT_ESP32P4: {
|
||||||
|
49: adc_channel_t.ADC_CHANNEL_0,
|
||||||
|
50: adc_channel_t.ADC_CHANNEL_1,
|
||||||
|
51: adc_channel_t.ADC_CHANNEL_2,
|
||||||
|
52: adc_channel_t.ADC_CHANNEL_3,
|
||||||
|
53: adc_channel_t.ADC_CHANNEL_4,
|
||||||
|
54: adc_channel_t.ADC_CHANNEL_5,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
|
|||||||
adc_oneshot_unit_handle_t adc_handle_{nullptr};
|
adc_oneshot_unit_handle_t adc_handle_{nullptr};
|
||||||
adc_cali_handle_t calibration_handle_{nullptr};
|
adc_cali_handle_t calibration_handle_{nullptr};
|
||||||
adc_atten_t attenuation_{ADC_ATTEN_DB_0};
|
adc_atten_t attenuation_{ADC_ATTEN_DB_0};
|
||||||
adc_channel_t channel_;
|
adc_channel_t channel_{};
|
||||||
adc_unit_t adc_unit_;
|
adc_unit_t adc_unit_{};
|
||||||
struct SetupFlags {
|
struct SetupFlags {
|
||||||
uint8_t init_complete : 1;
|
uint8_t init_complete : 1;
|
||||||
uint8_t config_complete : 1;
|
uint8_t config_complete : 1;
|
||||||
|
@ -72,10 +72,9 @@ void ADCSensor::setup() {
|
|||||||
// Initialize ADC calibration
|
// Initialize ADC calibration
|
||||||
if (this->calibration_handle_ == nullptr) {
|
if (this->calibration_handle_ == nullptr) {
|
||||||
adc_cali_handle_t handle = nullptr;
|
adc_cali_handle_t handle = nullptr;
|
||||||
esp_err_t err;
|
|
||||||
|
|
||||||
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
||||||
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2
|
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2 || USE_ESP32_VARIANT_ESP32P4
|
||||||
// RISC-V variants and S3 use curve fitting calibration
|
// RISC-V variants and S3 use curve fitting calibration
|
||||||
adc_cali_curve_fitting_config_t cali_config = {}; // Zero initialize first
|
adc_cali_curve_fitting_config_t cali_config = {}; // Zero initialize first
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
|
||||||
@ -187,7 +186,7 @@ float ADCSensor::sample_fixed_attenuation_() {
|
|||||||
ESP_LOGW(TAG, "ADC calibration conversion failed with error %d, disabling calibration", err);
|
ESP_LOGW(TAG, "ADC calibration conversion failed with error %d, disabling calibration", err);
|
||||||
if (this->calibration_handle_ != nullptr) {
|
if (this->calibration_handle_ != nullptr) {
|
||||||
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
||||||
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2
|
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2 || USE_ESP32_VARIANT_ESP32P4
|
||||||
adc_cali_delete_scheme_curve_fitting(this->calibration_handle_);
|
adc_cali_delete_scheme_curve_fitting(this->calibration_handle_);
|
||||||
#else // Other ESP32 variants use line fitting calibration
|
#else // Other ESP32 variants use line fitting calibration
|
||||||
adc_cali_delete_scheme_line_fitting(this->calibration_handle_);
|
adc_cali_delete_scheme_line_fitting(this->calibration_handle_);
|
||||||
@ -220,7 +219,7 @@ float ADCSensor::sample_autorange_() {
|
|||||||
if (this->calibration_handle_ != nullptr) {
|
if (this->calibration_handle_ != nullptr) {
|
||||||
// Delete old calibration handle
|
// Delete old calibration handle
|
||||||
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
||||||
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2
|
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2 || USE_ESP32_VARIANT_ESP32P4
|
||||||
adc_cali_delete_scheme_curve_fitting(this->calibration_handle_);
|
adc_cali_delete_scheme_curve_fitting(this->calibration_handle_);
|
||||||
#else
|
#else
|
||||||
adc_cali_delete_scheme_line_fitting(this->calibration_handle_);
|
adc_cali_delete_scheme_line_fitting(this->calibration_handle_);
|
||||||
@ -232,7 +231,7 @@ float ADCSensor::sample_autorange_() {
|
|||||||
adc_cali_handle_t handle = nullptr;
|
adc_cali_handle_t handle = nullptr;
|
||||||
|
|
||||||
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
||||||
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2
|
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2 || USE_ESP32_VARIANT_ESP32P4
|
||||||
adc_cali_curve_fitting_config_t cali_config = {};
|
adc_cali_curve_fitting_config_t cali_config = {};
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
|
||||||
cali_config.chan = this->channel_;
|
cali_config.chan = this->channel_;
|
||||||
@ -261,7 +260,7 @@ float ADCSensor::sample_autorange_() {
|
|||||||
ESP_LOGW(TAG, "ADC read failed in autorange with error %d", err);
|
ESP_LOGW(TAG, "ADC read failed in autorange with error %d", err);
|
||||||
if (handle != nullptr) {
|
if (handle != nullptr) {
|
||||||
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
||||||
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2
|
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2 || USE_ESP32_VARIANT_ESP32P4
|
||||||
adc_cali_delete_scheme_curve_fitting(handle);
|
adc_cali_delete_scheme_curve_fitting(handle);
|
||||||
#else
|
#else
|
||||||
adc_cali_delete_scheme_line_fitting(handle);
|
adc_cali_delete_scheme_line_fitting(handle);
|
||||||
@ -281,7 +280,7 @@ float ADCSensor::sample_autorange_() {
|
|||||||
}
|
}
|
||||||
// Clean up calibration handle
|
// Clean up calibration handle
|
||||||
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
#if USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C5 || USE_ESP32_VARIANT_ESP32C6 || \
|
||||||
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2
|
USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32H2 || USE_ESP32_VARIANT_ESP32P4
|
||||||
adc_cali_delete_scheme_curve_fitting(handle);
|
adc_cali_delete_scheme_curve_fitting(handle);
|
||||||
#else
|
#else
|
||||||
adc_cali_delete_scheme_line_fitting(handle);
|
adc_cali_delete_scheme_line_fitting(handle);
|
||||||
|
@ -1297,6 +1297,7 @@ enum MediaPlayerState {
|
|||||||
MEDIA_PLAYER_STATE_IDLE = 1;
|
MEDIA_PLAYER_STATE_IDLE = 1;
|
||||||
MEDIA_PLAYER_STATE_PLAYING = 2;
|
MEDIA_PLAYER_STATE_PLAYING = 2;
|
||||||
MEDIA_PLAYER_STATE_PAUSED = 3;
|
MEDIA_PLAYER_STATE_PAUSED = 3;
|
||||||
|
MEDIA_PLAYER_STATE_ANNOUNCING = 4;
|
||||||
}
|
}
|
||||||
enum MediaPlayerCommand {
|
enum MediaPlayerCommand {
|
||||||
MEDIA_PLAYER_COMMAND_PLAY = 0;
|
MEDIA_PLAYER_COMMAND_PLAY = 0;
|
||||||
@ -1304,6 +1305,13 @@ enum MediaPlayerCommand {
|
|||||||
MEDIA_PLAYER_COMMAND_STOP = 2;
|
MEDIA_PLAYER_COMMAND_STOP = 2;
|
||||||
MEDIA_PLAYER_COMMAND_MUTE = 3;
|
MEDIA_PLAYER_COMMAND_MUTE = 3;
|
||||||
MEDIA_PLAYER_COMMAND_UNMUTE = 4;
|
MEDIA_PLAYER_COMMAND_UNMUTE = 4;
|
||||||
|
MEDIA_PLAYER_COMMAND_TOGGLE = 5;
|
||||||
|
MEDIA_PLAYER_COMMAND_VOLUME_UP = 6;
|
||||||
|
MEDIA_PLAYER_COMMAND_VOLUME_DOWN = 7;
|
||||||
|
MEDIA_PLAYER_COMMAND_ENQUEUE = 8;
|
||||||
|
MEDIA_PLAYER_COMMAND_REPEAT_ONE = 9;
|
||||||
|
MEDIA_PLAYER_COMMAND_REPEAT_OFF = 10;
|
||||||
|
MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST = 11;
|
||||||
}
|
}
|
||||||
enum MediaPlayerFormatPurpose {
|
enum MediaPlayerFormatPurpose {
|
||||||
MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT = 0;
|
MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT = 0;
|
||||||
@ -1338,6 +1346,8 @@ message ListEntitiesMediaPlayerResponse {
|
|||||||
repeated MediaPlayerSupportedFormat supported_formats = 9;
|
repeated MediaPlayerSupportedFormat supported_formats = 9;
|
||||||
|
|
||||||
uint32 device_id = 10 [(field_ifdef) = "USE_DEVICES"];
|
uint32 device_id = 10 [(field_ifdef) = "USE_DEVICES"];
|
||||||
|
|
||||||
|
uint32 feature_flags = 11;
|
||||||
}
|
}
|
||||||
message MediaPlayerStateResponse {
|
message MediaPlayerStateResponse {
|
||||||
option (id) = 64;
|
option (id) = 64;
|
||||||
|
@ -999,6 +999,7 @@ uint16_t APIConnection::try_send_media_player_info(EntityBase *entity, APIConnec
|
|||||||
ListEntitiesMediaPlayerResponse msg;
|
ListEntitiesMediaPlayerResponse msg;
|
||||||
auto traits = media_player->get_traits();
|
auto traits = media_player->get_traits();
|
||||||
msg.supports_pause = traits.get_supports_pause();
|
msg.supports_pause = traits.get_supports_pause();
|
||||||
|
msg.feature_flags = traits.get_feature_flags();
|
||||||
for (auto &supported_format : traits.get_supported_formats()) {
|
for (auto &supported_format : traits.get_supported_formats()) {
|
||||||
msg.supported_formats.emplace_back();
|
msg.supported_formats.emplace_back();
|
||||||
auto &media_format = msg.supported_formats.back();
|
auto &media_format = msg.supported_formats.back();
|
||||||
|
@ -1725,6 +1725,7 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
#ifdef USE_DEVICES
|
#ifdef USE_DEVICES
|
||||||
buffer.encode_uint32(10, this->device_id);
|
buffer.encode_uint32(10, this->device_id);
|
||||||
#endif
|
#endif
|
||||||
|
buffer.encode_uint32(11, this->feature_flags);
|
||||||
}
|
}
|
||||||
void ListEntitiesMediaPlayerResponse::calculate_size(ProtoSize &size) const {
|
void ListEntitiesMediaPlayerResponse::calculate_size(ProtoSize &size) const {
|
||||||
size.add_length(1, this->object_id_ref_.size());
|
size.add_length(1, this->object_id_ref_.size());
|
||||||
@ -1740,6 +1741,7 @@ void ListEntitiesMediaPlayerResponse::calculate_size(ProtoSize &size) const {
|
|||||||
#ifdef USE_DEVICES
|
#ifdef USE_DEVICES
|
||||||
size.add_uint32(1, this->device_id);
|
size.add_uint32(1, this->device_id);
|
||||||
#endif
|
#endif
|
||||||
|
size.add_uint32(1, this->feature_flags);
|
||||||
}
|
}
|
||||||
void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const {
|
void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_fixed32(1, this->key);
|
buffer.encode_fixed32(1, this->key);
|
||||||
|
@ -150,6 +150,7 @@ enum MediaPlayerState : uint32_t {
|
|||||||
MEDIA_PLAYER_STATE_IDLE = 1,
|
MEDIA_PLAYER_STATE_IDLE = 1,
|
||||||
MEDIA_PLAYER_STATE_PLAYING = 2,
|
MEDIA_PLAYER_STATE_PLAYING = 2,
|
||||||
MEDIA_PLAYER_STATE_PAUSED = 3,
|
MEDIA_PLAYER_STATE_PAUSED = 3,
|
||||||
|
MEDIA_PLAYER_STATE_ANNOUNCING = 4,
|
||||||
};
|
};
|
||||||
enum MediaPlayerCommand : uint32_t {
|
enum MediaPlayerCommand : uint32_t {
|
||||||
MEDIA_PLAYER_COMMAND_PLAY = 0,
|
MEDIA_PLAYER_COMMAND_PLAY = 0,
|
||||||
@ -157,6 +158,13 @@ enum MediaPlayerCommand : uint32_t {
|
|||||||
MEDIA_PLAYER_COMMAND_STOP = 2,
|
MEDIA_PLAYER_COMMAND_STOP = 2,
|
||||||
MEDIA_PLAYER_COMMAND_MUTE = 3,
|
MEDIA_PLAYER_COMMAND_MUTE = 3,
|
||||||
MEDIA_PLAYER_COMMAND_UNMUTE = 4,
|
MEDIA_PLAYER_COMMAND_UNMUTE = 4,
|
||||||
|
MEDIA_PLAYER_COMMAND_TOGGLE = 5,
|
||||||
|
MEDIA_PLAYER_COMMAND_VOLUME_UP = 6,
|
||||||
|
MEDIA_PLAYER_COMMAND_VOLUME_DOWN = 7,
|
||||||
|
MEDIA_PLAYER_COMMAND_ENQUEUE = 8,
|
||||||
|
MEDIA_PLAYER_COMMAND_REPEAT_ONE = 9,
|
||||||
|
MEDIA_PLAYER_COMMAND_REPEAT_OFF = 10,
|
||||||
|
MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST = 11,
|
||||||
};
|
};
|
||||||
enum MediaPlayerFormatPurpose : uint32_t {
|
enum MediaPlayerFormatPurpose : uint32_t {
|
||||||
MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT = 0,
|
MEDIA_PLAYER_FORMAT_PURPOSE_DEFAULT = 0,
|
||||||
@ -1684,12 +1692,13 @@ class MediaPlayerSupportedFormat : public ProtoMessage {
|
|||||||
class ListEntitiesMediaPlayerResponse : public InfoResponseProtoMessage {
|
class ListEntitiesMediaPlayerResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 63;
|
static constexpr uint8_t MESSAGE_TYPE = 63;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 76;
|
static constexpr uint8_t ESTIMATED_SIZE = 80;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_media_player_response"; }
|
const char *message_name() const override { return "list_entities_media_player_response"; }
|
||||||
#endif
|
#endif
|
||||||
bool supports_pause{false};
|
bool supports_pause{false};
|
||||||
std::vector<MediaPlayerSupportedFormat> supported_formats{};
|
std::vector<MediaPlayerSupportedFormat> supported_formats{};
|
||||||
|
uint32_t feature_flags{0};
|
||||||
void encode(ProtoWriteBuffer buffer) const override;
|
void encode(ProtoWriteBuffer buffer) const override;
|
||||||
void calculate_size(ProtoSize &size) const override;
|
void calculate_size(ProtoSize &size) const override;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
|
@ -383,6 +383,8 @@ template<> const char *proto_enum_to_string<enums::MediaPlayerState>(enums::Medi
|
|||||||
return "MEDIA_PLAYER_STATE_PLAYING";
|
return "MEDIA_PLAYER_STATE_PLAYING";
|
||||||
case enums::MEDIA_PLAYER_STATE_PAUSED:
|
case enums::MEDIA_PLAYER_STATE_PAUSED:
|
||||||
return "MEDIA_PLAYER_STATE_PAUSED";
|
return "MEDIA_PLAYER_STATE_PAUSED";
|
||||||
|
case enums::MEDIA_PLAYER_STATE_ANNOUNCING:
|
||||||
|
return "MEDIA_PLAYER_STATE_ANNOUNCING";
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
@ -399,6 +401,20 @@ template<> const char *proto_enum_to_string<enums::MediaPlayerCommand>(enums::Me
|
|||||||
return "MEDIA_PLAYER_COMMAND_MUTE";
|
return "MEDIA_PLAYER_COMMAND_MUTE";
|
||||||
case enums::MEDIA_PLAYER_COMMAND_UNMUTE:
|
case enums::MEDIA_PLAYER_COMMAND_UNMUTE:
|
||||||
return "MEDIA_PLAYER_COMMAND_UNMUTE";
|
return "MEDIA_PLAYER_COMMAND_UNMUTE";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_TOGGLE:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_TOGGLE";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_VOLUME_UP:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_VOLUME_UP";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_VOLUME_DOWN:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_VOLUME_DOWN";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_ENQUEUE:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_ENQUEUE";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_REPEAT_ONE:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_REPEAT_ONE";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_REPEAT_OFF:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_REPEAT_OFF";
|
||||||
|
case enums::MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST:
|
||||||
|
return "MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST";
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
@ -1466,6 +1482,7 @@ void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const {
|
|||||||
#ifdef USE_DEVICES
|
#ifdef USE_DEVICES
|
||||||
dump_field(out, "device_id", this->device_id);
|
dump_field(out, "device_id", this->device_id);
|
||||||
#endif
|
#endif
|
||||||
|
dump_field(out, "feature_flags", this->feature_flags);
|
||||||
}
|
}
|
||||||
void MediaPlayerStateResponse::dump_to(std::string &out) const {
|
void MediaPlayerStateResponse::dump_to(std::string &out) const {
|
||||||
MessageDumpHelper helper(out, "MediaPlayerStateResponse");
|
MessageDumpHelper helper(out, "MediaPlayerStateResponse");
|
||||||
|
@ -313,7 +313,7 @@ def _format_framework_espidf_version(
|
|||||||
RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(3, 2, 1)
|
RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(3, 2, 1)
|
||||||
# The platform-espressif32 version to use for arduino frameworks
|
# The platform-espressif32 version to use for arduino frameworks
|
||||||
# - https://github.com/pioarduino/platform-espressif32/releases
|
# - https://github.com/pioarduino/platform-espressif32/releases
|
||||||
ARDUINO_PLATFORM_VERSION = cv.Version(54, 3, 21)
|
ARDUINO_PLATFORM_VERSION = cv.Version(54, 3, 21, "1")
|
||||||
|
|
||||||
# The default/recommended esp-idf framework version
|
# The default/recommended esp-idf framework version
|
||||||
# - https://github.com/espressif/esp-idf/releases
|
# - https://github.com/espressif/esp-idf/releases
|
||||||
@ -322,7 +322,7 @@ RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION = cv.Version(5, 4, 2)
|
|||||||
# The platformio/espressif32 version to use for esp-idf frameworks
|
# The platformio/espressif32 version to use for esp-idf frameworks
|
||||||
# - https://github.com/platformio/platform-espressif32/releases
|
# - https://github.com/platformio/platform-espressif32/releases
|
||||||
# - https://api.registry.platformio.org/v3/packages/platformio/platform/espressif32
|
# - https://api.registry.platformio.org/v3/packages/platformio/platform/espressif32
|
||||||
ESP_IDF_PLATFORM_VERSION = cv.Version(54, 3, 21)
|
ESP_IDF_PLATFORM_VERSION = cv.Version(54, 3, 21, "1")
|
||||||
|
|
||||||
# List based on https://registry.platformio.org/tools/platformio/framework-espidf/versions
|
# List based on https://registry.platformio.org/tools/platformio/framework-espidf/versions
|
||||||
SUPPORTED_PLATFORMIO_ESP_IDF_5X = [
|
SUPPORTED_PLATFORMIO_ESP_IDF_5X = [
|
||||||
@ -468,10 +468,10 @@ def _parse_platform_version(value):
|
|||||||
try:
|
try:
|
||||||
ver = cv.Version.parse(cv.version_number(value))
|
ver = cv.Version.parse(cv.version_number(value))
|
||||||
if ver.major >= 50: # a pioarduino version
|
if ver.major >= 50: # a pioarduino version
|
||||||
if "-" in value:
|
release = f"{ver.major}.{ver.minor:02d}.{ver.patch:02d}"
|
||||||
# maybe a release candidate?...definitely not our default, just use it as-is...
|
if ver.extra:
|
||||||
return f"https://github.com/pioarduino/platform-espressif32/releases/download/{value}/platform-espressif32.zip"
|
release += f"-{ver.extra}"
|
||||||
return f"https://github.com/pioarduino/platform-espressif32/releases/download/{ver.major}.{ver.minor:02d}.{ver.patch:02d}/platform-espressif32.zip"
|
return f"https://github.com/pioarduino/platform-espressif32/releases/download/{release}/platform-espressif32.zip"
|
||||||
# if platform version is a valid version constraint, prefix the default package
|
# if platform version is a valid version constraint, prefix the default package
|
||||||
cv.platformio_version_constraint(value)
|
cv.platformio_version_constraint(value)
|
||||||
return f"platformio/espressif32@{value}"
|
return f"platformio/espressif32@{value}"
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
Import("env")
|
Import("env") # noqa: F821
|
||||||
|
|
||||||
|
import itertools # noqa: E402
|
||||||
|
import json # noqa: E402
|
||||||
|
import os # noqa: E402
|
||||||
|
import pathlib # noqa: E402
|
||||||
|
import shutil # noqa: E402
|
||||||
|
|
||||||
import os
|
|
||||||
import json
|
|
||||||
import shutil
|
|
||||||
import pathlib
|
|
||||||
import itertools
|
|
||||||
|
|
||||||
def merge_factory_bin(source, target, env):
|
def merge_factory_bin(source, target, env):
|
||||||
"""
|
"""
|
||||||
@ -25,7 +26,9 @@ def merge_factory_bin(source, target, env):
|
|||||||
try:
|
try:
|
||||||
with flasher_args_path.open() as f:
|
with flasher_args_path.open() as f:
|
||||||
flash_data = json.load(f)
|
flash_data = json.load(f)
|
||||||
for addr, fname in sorted(flash_data["flash_files"].items(), key=lambda kv: int(kv[0], 16)):
|
for addr, fname in sorted(
|
||||||
|
flash_data["flash_files"].items(), key=lambda kv: int(kv[0], 16)
|
||||||
|
):
|
||||||
file_path = pathlib.Path(fname)
|
file_path = pathlib.Path(fname)
|
||||||
if file_path.exists():
|
if file_path.exists():
|
||||||
sections.append((addr, str(file_path)))
|
sections.append((addr, str(file_path)))
|
||||||
@ -40,20 +43,27 @@ def merge_factory_bin(source, target, env):
|
|||||||
if flash_images:
|
if flash_images:
|
||||||
print("Using FLASH_EXTRA_IMAGES from PlatformIO environment")
|
print("Using FLASH_EXTRA_IMAGES from PlatformIO environment")
|
||||||
# flatten any nested lists
|
# flatten any nested lists
|
||||||
flat = list(itertools.chain.from_iterable(
|
flat = list(
|
||||||
x if isinstance(x, (list, tuple)) else [x] for x in flash_images
|
itertools.chain.from_iterable(
|
||||||
))
|
x if isinstance(x, (list, tuple)) else [x] for x in flash_images
|
||||||
|
)
|
||||||
|
)
|
||||||
entries = [env.subst(x) for x in flat]
|
entries = [env.subst(x) for x in flat]
|
||||||
for i in range(0, len(entries) - 1, 2):
|
for i in range(0, len(entries) - 1, 2):
|
||||||
addr, fname = entries[i], entries[i + 1]
|
addr, fname = entries[i], entries[i + 1]
|
||||||
if isinstance(fname, (list, tuple)):
|
if isinstance(fname, (list, tuple)):
|
||||||
print(f"Warning: Skipping malformed FLASH_EXTRA_IMAGES entry: {fname}")
|
print(
|
||||||
|
f"Warning: Skipping malformed FLASH_EXTRA_IMAGES entry: {fname}"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
file_path = pathlib.Path(str(fname))
|
file_path = pathlib.Path(str(fname))
|
||||||
if file_path.exists():
|
if file_path.exists():
|
||||||
sections.append((addr, str(file_path)))
|
sections.append((addr, file_path))
|
||||||
else:
|
else:
|
||||||
print(f"Info: {file_path.name} not found — skipping")
|
print(f"Info: {file_path.name} not found — skipping")
|
||||||
|
if sections:
|
||||||
|
# Append main firmware to sections
|
||||||
|
sections.append(("0x10000", firmware_path))
|
||||||
|
|
||||||
# 3. Final fallback: guess standard image locations
|
# 3. Final fallback: guess standard image locations
|
||||||
if not sections:
|
if not sections:
|
||||||
@ -62,11 +72,11 @@ def merge_factory_bin(source, target, env):
|
|||||||
("0x0", build_dir / "bootloader" / "bootloader.bin"),
|
("0x0", build_dir / "bootloader" / "bootloader.bin"),
|
||||||
("0x8000", build_dir / "partition_table" / "partition-table.bin"),
|
("0x8000", build_dir / "partition_table" / "partition-table.bin"),
|
||||||
("0xe000", build_dir / "ota_data_initial.bin"),
|
("0xe000", build_dir / "ota_data_initial.bin"),
|
||||||
("0x10000", firmware_path)
|
("0x10000", firmware_path),
|
||||||
]
|
]
|
||||||
for addr, file_path in guesses:
|
for addr, file_path in guesses:
|
||||||
if file_path.exists():
|
if file_path.exists():
|
||||||
sections.append((addr, str(file_path)))
|
sections.append((addr, file_path))
|
||||||
else:
|
else:
|
||||||
print(f"Info: {file_path.name} not found — skipping")
|
print(f"Info: {file_path.name} not found — skipping")
|
||||||
|
|
||||||
@ -76,21 +86,25 @@ def merge_factory_bin(source, target, env):
|
|||||||
return
|
return
|
||||||
|
|
||||||
output_path = firmware_path.with_suffix(".factory.bin")
|
output_path = firmware_path.with_suffix(".factory.bin")
|
||||||
|
python_exe = f'"{env.subst("$PYTHONEXE")}"'
|
||||||
cmd = [
|
cmd = [
|
||||||
"--chip", chip,
|
python_exe,
|
||||||
|
"-m",
|
||||||
|
"esptool",
|
||||||
|
"--chip",
|
||||||
|
chip,
|
||||||
"merge_bin",
|
"merge_bin",
|
||||||
"--flash_size", flash_size,
|
"--flash_size",
|
||||||
"--output", str(output_path)
|
flash_size,
|
||||||
|
"--output",
|
||||||
|
str(output_path),
|
||||||
]
|
]
|
||||||
for addr, file_path in sections:
|
for addr, file_path in sections:
|
||||||
cmd += [addr, file_path]
|
cmd += [addr, str(file_path)]
|
||||||
|
|
||||||
print(f"Merging binaries into {output_path}")
|
print(f"Merging binaries into {output_path}")
|
||||||
result = env.Execute(
|
result = env.Execute(
|
||||||
env.VerboseAction(
|
env.VerboseAction(" ".join(cmd), "Merging binaries with esptool")
|
||||||
f"{env.subst('$PYTHONEXE')} -m esptool " + " ".join(cmd),
|
|
||||||
"Merging binaries with esptool"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
@ -98,6 +112,7 @@ def merge_factory_bin(source, target, env):
|
|||||||
else:
|
else:
|
||||||
print(f"Error: esptool merge_bin failed with code {result}")
|
print(f"Error: esptool merge_bin failed with code {result}")
|
||||||
|
|
||||||
|
|
||||||
def esp32_copy_ota_bin(source, target, env):
|
def esp32_copy_ota_bin(source, target, env):
|
||||||
"""
|
"""
|
||||||
Copy the main firmware to a .ota.bin file for compatibility with ESPHome OTA tools.
|
Copy the main firmware to a .ota.bin file for compatibility with ESPHome OTA tools.
|
||||||
@ -107,6 +122,7 @@ def esp32_copy_ota_bin(source, target, env):
|
|||||||
shutil.copyfile(firmware_name, new_file_name)
|
shutil.copyfile(firmware_name, new_file_name)
|
||||||
print(f"Copied firmware to {new_file_name}")
|
print(f"Copied firmware to {new_file_name}")
|
||||||
|
|
||||||
|
|
||||||
# Run merge first, then ota copy second
|
# Run merge first, then ota copy second
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", merge_factory_bin)
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", merge_factory_bin) # noqa: F821
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin)
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin) # noqa: F821
|
||||||
|
@ -6,12 +6,38 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace media_player {
|
namespace media_player {
|
||||||
|
|
||||||
|
enum MediaPlayerEntityFeature : uint32_t {
|
||||||
|
PAUSE = 1 << 0,
|
||||||
|
SEEK = 1 << 1,
|
||||||
|
VOLUME_SET = 1 << 2,
|
||||||
|
VOLUME_MUTE = 1 << 3,
|
||||||
|
PREVIOUS_TRACK = 1 << 4,
|
||||||
|
NEXT_TRACK = 1 << 5,
|
||||||
|
|
||||||
|
TURN_ON = 1 << 7,
|
||||||
|
TURN_OFF = 1 << 8,
|
||||||
|
PLAY_MEDIA = 1 << 9,
|
||||||
|
VOLUME_STEP = 1 << 10,
|
||||||
|
SELECT_SOURCE = 1 << 11,
|
||||||
|
STOP = 1 << 12,
|
||||||
|
CLEAR_PLAYLIST = 1 << 13,
|
||||||
|
PLAY = 1 << 14,
|
||||||
|
SHUFFLE_SET = 1 << 15,
|
||||||
|
SELECT_SOUND_MODE = 1 << 16,
|
||||||
|
BROWSE_MEDIA = 1 << 17,
|
||||||
|
REPEAT_SET = 1 << 18,
|
||||||
|
GROUPING = 1 << 19,
|
||||||
|
MEDIA_ANNOUNCE = 1 << 20,
|
||||||
|
MEDIA_ENQUEUE = 1 << 21,
|
||||||
|
SEARCH_MEDIA = 1 << 22,
|
||||||
|
};
|
||||||
|
|
||||||
enum MediaPlayerState : uint8_t {
|
enum MediaPlayerState : uint8_t {
|
||||||
MEDIA_PLAYER_STATE_NONE = 0,
|
MEDIA_PLAYER_STATE_NONE = 0,
|
||||||
MEDIA_PLAYER_STATE_IDLE = 1,
|
MEDIA_PLAYER_STATE_IDLE = 1,
|
||||||
MEDIA_PLAYER_STATE_PLAYING = 2,
|
MEDIA_PLAYER_STATE_PLAYING = 2,
|
||||||
MEDIA_PLAYER_STATE_PAUSED = 3,
|
MEDIA_PLAYER_STATE_PAUSED = 3,
|
||||||
MEDIA_PLAYER_STATE_ANNOUNCING = 4
|
MEDIA_PLAYER_STATE_ANNOUNCING = 4,
|
||||||
};
|
};
|
||||||
const char *media_player_state_to_string(MediaPlayerState state);
|
const char *media_player_state_to_string(MediaPlayerState state);
|
||||||
|
|
||||||
@ -56,6 +82,17 @@ class MediaPlayerTraits {
|
|||||||
|
|
||||||
std::vector<MediaPlayerSupportedFormat> &get_supported_formats() { return this->supported_formats_; }
|
std::vector<MediaPlayerSupportedFormat> &get_supported_formats() { return this->supported_formats_; }
|
||||||
|
|
||||||
|
uint32_t get_feature_flags() const {
|
||||||
|
uint32_t flags = 0;
|
||||||
|
flags |= MediaPlayerEntityFeature::PLAY_MEDIA | MediaPlayerEntityFeature::BROWSE_MEDIA |
|
||||||
|
MediaPlayerEntityFeature::STOP | MediaPlayerEntityFeature::VOLUME_SET |
|
||||||
|
MediaPlayerEntityFeature::VOLUME_MUTE | MediaPlayerEntityFeature::MEDIA_ANNOUNCE;
|
||||||
|
if (this->get_supports_pause()) {
|
||||||
|
flags |= MediaPlayerEntityFeature::PAUSE | MediaPlayerEntityFeature::PLAY;
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool supports_pause_{false};
|
bool supports_pause_{false};
|
||||||
std::vector<MediaPlayerSupportedFormat> supported_formats_{};
|
std::vector<MediaPlayerSupportedFormat> supported_formats_{};
|
||||||
|
@ -291,6 +291,8 @@ class Version:
|
|||||||
extra: str = ""
|
extra: str = ""
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
if self.extra:
|
||||||
|
return f"{self.major}.{self.minor}.{self.patch}-{self.extra}"
|
||||||
return f"{self.major}.{self.minor}.{self.patch}"
|
return f"{self.major}.{self.minor}.{self.patch}"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -161,7 +161,7 @@ void Component::call() {
|
|||||||
this->call_setup();
|
this->call_setup();
|
||||||
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
|
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
|
||||||
uint32_t setup_time = millis() - start_time;
|
uint32_t setup_time = millis() - start_time;
|
||||||
ESP_LOGD(TAG, "Setup %s took %ums", this->get_component_source(), (unsigned) setup_time);
|
ESP_LOGCONFIG(TAG, "Setup %s took %ums", this->get_component_source(), (unsigned) setup_time);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ extra_scripts = post:esphome/components/esp8266/post_build.py.script
|
|||||||
; This are common settings for the ESP32 (all variants) using Arduino.
|
; This are common settings for the ESP32 (all variants) using Arduino.
|
||||||
[common:esp32-arduino]
|
[common:esp32-arduino]
|
||||||
extends = common:arduino
|
extends = common:arduino
|
||||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21/platform-espressif32.zip
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-1/platform-espressif32.zip
|
||||||
platform_packages =
|
platform_packages =
|
||||||
pioarduino/framework-arduinoespressif32@https://github.com/espressif/arduino-esp32/releases/download/3.2.1/esp32-3.2.1.zip
|
pioarduino/framework-arduinoespressif32@https://github.com/espressif/arduino-esp32/releases/download/3.2.1/esp32-3.2.1.zip
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
|
|||||||
; This are common settings for the ESP32 (all variants) using IDF.
|
; This are common settings for the ESP32 (all variants) using IDF.
|
||||||
[common:esp32-idf]
|
[common:esp32-idf]
|
||||||
extends = common:idf
|
extends = common:idf
|
||||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21/platform-espressif32.zip
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-1/platform-espressif32.zip
|
||||||
platform_packages =
|
platform_packages =
|
||||||
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.4.2/esp-idf-v5.4.2.zip
|
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.4.2/esp-idf-v5.4.2.zip
|
||||||
|
|
||||||
|
6
tests/components/adc/test.esp32-p4-idf.yaml
Normal file
6
tests/components/adc/test.esp32-p4-idf.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
packages:
|
||||||
|
base: !include common.yaml
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- id: !extend my_sensor
|
||||||
|
pin: GPIO50
|
Loading…
x
Reference in New Issue
Block a user