mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
		| @@ -20,14 +20,16 @@ adjusted_ids = set() | ||||
|  | ||||
| CONFIG_SCHEMA = cv.All( | ||||
|     cv.ensure_list( | ||||
|         { | ||||
|             cv.GenerateID(): cv.declare_id(EspLdo), | ||||
|             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.COMPONENT_SCHEMA.extend( | ||||
|             { | ||||
|                 cv.GenerateID(): cv.declare_id(EspLdo), | ||||
|                 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.only_with_esp_idf, | ||||
|     only_on_variant(supported=[VARIANT_ESP32P4]), | ||||
|   | ||||
| @@ -17,6 +17,9 @@ class EspLdo : public Component { | ||||
|   void set_adjustable(bool adjustable) { this->adjustable_ = adjustable; } | ||||
|   void set_voltage(float voltage) { this->voltage_ = voltage; } | ||||
|   void adjust_voltage(float voltage); | ||||
|   float get_setup_priority() const override { | ||||
|     return setup_priority::BUS;  // LDO setup should be done early | ||||
|   } | ||||
|  | ||||
|  protected: | ||||
|   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()); } | ||||
|  | ||||
| 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) | ||||
|     return ""; | ||||
|   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::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) { | ||||
|   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); | ||||
| } | ||||
| std::string format_hex_pretty(const std::string &data, char separator, bool show_length) { | ||||
|   if (data.empty()) | ||||
|     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; | ||||
|   return format_hex_pretty_uint8(reinterpret_cast<const uint8_t *>(data.data()), data.length(), separator, show_length); | ||||
| } | ||||
|  | ||||
| std::string format_bin(const uint8_t *data, size_t length) { | ||||
|   | ||||
| @@ -6,6 +6,7 @@ esp_ldo: | ||||
|   - id: ldo_4 | ||||
|     channel: 4 | ||||
|     voltage: 2.0V | ||||
|     setup_priority: 900 | ||||
|  | ||||
| esphome: | ||||
|   on_boot: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user