|
ESPHome 2025.12.0-dev
|
Go to the source code of this file.
Namespaces | |
| namespace | esphome |
| Providing packet encoding functions for exchanging data with a remote host. | |
Functions | |
| template<int(*)(int) fn> | |
| std::string | esphome::str_ctype_transform (const std::string &str) |
| std::string | esphome::str_snprintf (const char *fmt, size_t len,...) |
| std::string | esphome::str_sprintf (const char *fmt,...) |
| std::string | esphome::format_mac_address_pretty (const uint8_t *mac) |
Mathematics | |
| uint8_t | esphome::crc8 (const uint8_t *data, uint8_t len, uint8_t crc=0x00, uint8_t poly=0x8C, bool msb_first=false) |
Calculate a CRC-8 checksum of data with size len. | |
| uint16_t | esphome::crc16 (const uint8_t *data, uint16_t len, uint16_t crc=0xffff, uint16_t reverse_poly=0xa001, bool refin=false, bool refout=false) |
Calculate a CRC-16 checksum of data with size len. | |
| uint16_t | esphome::crc16be (const uint8_t *data, uint16_t len, uint16_t crc, uint16_t poly, bool refin, bool refout) |
| uint32_t | esphome::fnv1_hash (const char *str) |
Calculate a FNV-1 hash of str. | |
| float | esphome::random_float () |
| Return a random float between 0 and 1. | |
Strings | |
| bool | esphome::str_equals_case_insensitive (const std::string &a, const std::string &b) |
| Compare strings for equality in case-insensitive manner. | |
| bool | esphome::str_startswith (const std::string &str, const std::string &start) |
| Check whether a string starts with a value. | |
| bool | esphome::str_endswith (const std::string &str, const std::string &end) |
| Check whether a string ends with a value. | |
| std::string | esphome::str_truncate (const std::string &str, size_t length) |
| Truncate a string to a specific length. | |
| std::string | esphome::str_until (const char *str, char ch) |
| Extract the part of the string until either the first occurrence of the specified character, or the end (requires str to be null-terminated). | |
| std::string | esphome::str_until (const std::string &str, char ch) |
| Extract the part of the string until either the first occurrence of the specified character, or the end. | |
| std::string | esphome::str_lower_case (const std::string &str) |
| Convert the string to lower case. | |
| std::string | esphome::str_upper_case (const std::string &str) |
| Convert the string to upper case. | |
| std::string | esphome::str_snake_case (const std::string &str) |
| Convert the string to snake case (lowercase with underscores). | |
| std::string | esphome::str_sanitize (const std::string &str) |
| Sanitizes the input string by removing all characters but alphanumerics, dashes and underscores. | |
| std::string | esphome::make_name_with_suffix (const std::string &name, char sep, const char *suffix_ptr, size_t suffix_len) |
| Concatenate a name with a separator and suffix using an efficient stack-based approach. | |
Parsing & formatting | |
| size_t | esphome::parse_hex (const char *str, size_t len, uint8_t *data, size_t count) |
| Parse bytes from a hex-encoded string into a byte array. | |
| std::string | esphome::format_hex (const uint8_t *data, size_t length) |
Format the byte array data of length len in lowercased hex. | |
| std::string | esphome::format_hex (const std::vector< uint8_t > &data) |
Format the vector data in lowercased hex. | |
| std::string | esphome::format_hex_pretty (const uint8_t *data, size_t length, char separator='.', bool show_length=true) |
| Format a byte array in pretty-printed, human-readable hex format. | |
| std::string | esphome::format_hex_pretty (const std::vector< uint8_t > &data, char separator='.', bool show_length=true) |
| Format a byte vector in pretty-printed, human-readable hex format. | |
| std::string | esphome::format_hex_pretty (const uint16_t *data, size_t length, char separator='.', bool show_length=true) |
| Format a 16-bit word array in pretty-printed, human-readable hex format. | |
| std::string | esphome::format_hex_pretty (const std::vector< uint16_t > &data, char separator='.', bool show_length=true) |
| Format a 16-bit word vector in pretty-printed, human-readable hex format. | |
| std::string | esphome::format_hex_pretty (const std::string &data, char separator='.', bool show_length=true) |
| Format a string's bytes in pretty-printed, human-readable hex format. | |
| std::string | esphome::format_bin (const uint8_t *data, size_t length) |
Format the byte array data of length len in binary. | |
| ParseOnOffState | esphome::parse_on_off (const char *str, const char *on=nullptr, const char *off=nullptr) |
| Parse a string that contains either on, off or toggle. | |
| std::string | esphome::value_accuracy_to_string (float value, int8_t accuracy_decimals) |
| Create a string from a value and an accuracy in decimals. | |
| std::string | esphome::value_accuracy_with_uom_to_string (float value, int8_t accuracy_decimals, StringRef unit_of_measurement) |
| Create a string from a value, an accuracy in decimals, and a unit of measurement. | |
| int8_t | esphome::step_to_accuracy_decimals (float step) |
| Derive accuracy in decimals from an increment step. | |
| std::string | esphome::base64_encode (const std::vector< uint8_t > &buf) |
| std::string | esphome::base64_encode (const uint8_t *buf, size_t buf_len) |
| size_t | esphome::base64_decode (const std::string &encoded_string, uint8_t *buf, size_t buf_len) |
| std::vector< uint8_t > | esphome::base64_decode (const std::string &encoded_string) |
Colors | |
| float | esphome::gamma_correct (float value, float gamma) |
Applies gamma correction of gamma to value. | |
| float | esphome::gamma_uncorrect (float value, float gamma) |
Reverts gamma correction of gamma to value. | |
| void | esphome::rgb_to_hsv (float red, float green, float blue, int &hue, float &saturation, float &value) |
Convert red, green and blue (all 0-1) values to hue (0-360), saturation (0-1) and value (0-1). | |
| void | esphome::hsv_to_rgb (int hue, float saturation, float value, float &red, float &green, float &blue) |
Convert hue (0-360), saturation (0-1) and value (0-1) to red, green and blue (all 0-1). | |
System APIs | |
| std::string | esphome::get_mac_address () |
| Get the device MAC address as a string, in lowercase hex notation. | |
| std::string | esphome::get_mac_address_pretty () |
| Get the device MAC address as a string, in colon-separated uppercase hex notation. | |
| void | esphome::get_mac_address_into_buffer (std::span< char, 13 > buf) |
| Get the device MAC address into the given buffer, in lowercase hex notation. | |
| bool | esphome::has_custom_mac_address () |
| Check if a custom MAC address is set (ESP32 & variants) | |
| bool | esphome::mac_address_is_valid (const uint8_t *mac) |
| Check if the MAC address is not all zeros or all ones. | |
| void IRAM_ATTR HOT | esphome::delay_microseconds_safe (uint32_t us) |
| Delay for the given amount of microseconds, possibly yielding to other processes during the wait. | |