mirror of
https://github.com/esphome/esphome.git
synced 2025-08-05 09:57:47 +00:00
Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
commit
6cd443e9dc
@ -20,14 +20,16 @@ adjusted_ids = set()
|
|||||||
|
|
||||||
CONFIG_SCHEMA = cv.All(
|
CONFIG_SCHEMA = cv.All(
|
||||||
cv.ensure_list(
|
cv.ensure_list(
|
||||||
{
|
cv.COMPONENT_SCHEMA.extend(
|
||||||
cv.GenerateID(): cv.declare_id(EspLdo),
|
{
|
||||||
cv.Required(CONF_VOLTAGE): cv.All(
|
cv.GenerateID(): cv.declare_id(EspLdo),
|
||||||
cv.voltage, cv.float_range(min=0.5, max=2.7)
|
cv.Required(CONF_VOLTAGE): cv.All(
|
||||||
),
|
cv.voltage, cv.float_range(min=0.5, max=2.7)
|
||||||
cv.Required(CONF_CHANNEL): cv.one_of(*CHANNELS, int=True),
|
),
|
||||||
cv.Optional(CONF_ADJUSTABLE, default=False): cv.boolean,
|
cv.Required(CONF_CHANNEL): cv.one_of(*CHANNELS, int=True),
|
||||||
}
|
cv.Optional(CONF_ADJUSTABLE, default=False): cv.boolean,
|
||||||
|
}
|
||||||
|
)
|
||||||
),
|
),
|
||||||
cv.only_with_esp_idf,
|
cv.only_with_esp_idf,
|
||||||
only_on_variant(supported=[VARIANT_ESP32P4]),
|
only_on_variant(supported=[VARIANT_ESP32P4]),
|
||||||
|
@ -17,6 +17,9 @@ class EspLdo : public Component {
|
|||||||
void set_adjustable(bool adjustable) { this->adjustable_ = adjustable; }
|
void set_adjustable(bool adjustable) { this->adjustable_ = adjustable; }
|
||||||
void set_voltage(float voltage) { this->voltage_ = voltage; }
|
void set_voltage(float voltage) { this->voltage_ = voltage; }
|
||||||
void adjust_voltage(float voltage);
|
void adjust_voltage(float voltage);
|
||||||
|
float get_setup_priority() const override {
|
||||||
|
return setup_priority::BUS; // LDO setup should be done early
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int channel_;
|
int channel_;
|
||||||
|
@ -258,7 +258,9 @@ std::string format_hex(const uint8_t *data, size_t length) {
|
|||||||
std::string format_hex(const std::vector<uint8_t> &data) { return format_hex(data.data(), data.size()); }
|
std::string format_hex(const std::vector<uint8_t> &data) { return format_hex(data.data(), data.size()); }
|
||||||
|
|
||||||
static char format_hex_pretty_char(uint8_t v) { return v >= 10 ? 'A' + (v - 10) : '0' + v; }
|
static char format_hex_pretty_char(uint8_t v) { return v >= 10 ? 'A' + (v - 10) : '0' + v; }
|
||||||
std::string format_hex_pretty(const uint8_t *data, size_t length, char separator, bool show_length) {
|
|
||||||
|
// Shared implementation for uint8_t and string hex formatting
|
||||||
|
static std::string format_hex_pretty_uint8(const uint8_t *data, size_t length, char separator, bool show_length) {
|
||||||
if (data == nullptr || length == 0)
|
if (data == nullptr || length == 0)
|
||||||
return "";
|
return "";
|
||||||
std::string ret;
|
std::string ret;
|
||||||
@ -274,6 +276,10 @@ std::string format_hex_pretty(const uint8_t *data, size_t length, char separator
|
|||||||
return ret + " (" + std::to_string(length) + ")";
|
return ret + " (" + std::to_string(length) + ")";
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string format_hex_pretty(const uint8_t *data, size_t length, char separator, bool show_length) {
|
||||||
|
return format_hex_pretty_uint8(data, length, separator, show_length);
|
||||||
|
}
|
||||||
std::string format_hex_pretty(const std::vector<uint8_t> &data, char separator, bool show_length) {
|
std::string format_hex_pretty(const std::vector<uint8_t> &data, char separator, bool show_length) {
|
||||||
return format_hex_pretty(data.data(), data.size(), separator, show_length);
|
return format_hex_pretty(data.data(), data.size(), separator, show_length);
|
||||||
}
|
}
|
||||||
@ -300,20 +306,7 @@ std::string format_hex_pretty(const std::vector<uint16_t> &data, char separator,
|
|||||||
return format_hex_pretty(data.data(), data.size(), separator, show_length);
|
return format_hex_pretty(data.data(), data.size(), separator, show_length);
|
||||||
}
|
}
|
||||||
std::string format_hex_pretty(const std::string &data, char separator, bool show_length) {
|
std::string format_hex_pretty(const std::string &data, char separator, bool show_length) {
|
||||||
if (data.empty())
|
return format_hex_pretty_uint8(reinterpret_cast<const uint8_t *>(data.data()), data.length(), separator, show_length);
|
||||||
return "";
|
|
||||||
std::string ret;
|
|
||||||
uint8_t multiple = separator ? 3 : 2; // 3 if separator is not \0, 2 otherwise
|
|
||||||
ret.resize(multiple * data.length() - (separator ? 1 : 0));
|
|
||||||
for (size_t i = 0; i < data.length(); i++) {
|
|
||||||
ret[multiple * i] = format_hex_pretty_char((data[i] & 0xF0) >> 4);
|
|
||||||
ret[multiple * i + 1] = format_hex_pretty_char(data[i] & 0x0F);
|
|
||||||
if (separator && i != data.length() - 1)
|
|
||||||
ret[multiple * i + 2] = separator;
|
|
||||||
}
|
|
||||||
if (show_length && data.length() > 4)
|
|
||||||
return ret + " (" + std::to_string(data.length()) + ")";
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string format_bin(const uint8_t *data, size_t length) {
|
std::string format_bin(const uint8_t *data, size_t length) {
|
||||||
|
@ -6,6 +6,7 @@ esp_ldo:
|
|||||||
- id: ldo_4
|
- id: ldo_4
|
||||||
channel: 4
|
channel: 4
|
||||||
voltage: 2.0V
|
voltage: 2.0V
|
||||||
|
setup_priority: 900
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
on_boot:
|
on_boot:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user