|
|
| template<typename To , typename From , enable_if_t< sizeof(To)==sizeof(From) &&is_trivially_copyable< From >::value &&is_trivially_copyable< To >::value, int > = 0> |
| To | esphome::bit_cast (const From &src) |
| | Convert data between types, without aliasing issues or undefined behaviour.
|
| |
| float | esphome::lerp (float completion, float start, float end)=delete |
| |
| template<typename T > |
| constexpr T | esphome::byteswap (T n) |
| |
| template<> |
| constexpr uint8_t | esphome::byteswap (uint8_t n) |
| |
| template<> |
| uint16_t | esphome::byteswap (uint16_t n) |
| |
| template<> |
| uint32_t | esphome::byteswap (uint32_t n) |
| |
| template<> |
| uint64_t | esphome::byteswap (uint64_t n) |
| |
| template<> |
| int8_t | esphome::byteswap (int8_t n) |
| |
| template<> |
| int16_t | esphome::byteswap (int16_t n) |
| |
| template<> |
| int32_t | esphome::byteswap (int32_t n) |
| |
| template<> |
| int64_t | esphome::byteswap (int64_t n) |
| |
| template<> |
| constexpr uint16_t | esphome::byteswap (uint16_t n) |
| |
| template<> |
| constexpr uint32_t | esphome::byteswap (uint32_t n) |
| |
| template<> |
| constexpr uint64_t | esphome::byteswap (uint64_t n) |
| |
| template<> |
| constexpr int8_t | esphome::byteswap (int8_t n) |
| |
| template<> |
| constexpr int16_t | esphome::byteswap (int16_t n) |
| |
| template<> |
| constexpr int32_t | esphome::byteswap (int32_t n) |
| |
| template<> |
| constexpr int64_t | esphome::byteswap (int64_t n) |
| |
|
| template<typename T , typename U > |
| T | esphome::remap (U value, U min, U max, T min_out, T max_out) |
| | Remap value from the range (min, max) to (min_out, max_out).
|
| |
| 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.
|
| |
| uint32_t | esphome::fnv1_hash (const std::string &str) |
| |
| uint32_t | esphome::random_uint32 () |
| | Return a random 32-bit unsigned integer.
|
| |
| float | esphome::random_float () |
| | Return a random float between 0 and 1.
|
| |
| bool | esphome::random_bytes (uint8_t *data, size_t len) |
| | Generate len number of random bytes.
|
| |
|
| constexpr uint16_t | esphome::encode_uint16 (uint8_t msb, uint8_t lsb) |
| | Encode a 16-bit value given the most and least significant byte.
|
| |
| constexpr uint32_t | esphome::encode_uint24 (uint8_t byte1, uint8_t byte2, uint8_t byte3) |
| | Encode a 24-bit value given three bytes in most to least significant byte order.
|
| |
| constexpr uint32_t | esphome::encode_uint32 (uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4) |
| | Encode a 32-bit value given four bytes in most to least significant byte order.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| constexpr T | esphome::encode_value (const uint8_t *bytes) |
| | Encode a value from its constituent bytes (from most to least significant) in an array with length sizeof(T).
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| constexpr T | esphome::encode_value (const std::array< uint8_t, sizeof(T)> bytes) |
| | Encode a value from its constituent bytes (from most to least significant) in an std::array with length sizeof(T).
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| constexpr std::array< uint8_t, sizeof(T)> | esphome::decode_value (T val) |
| | Decode a value into its constituent bytes (from most to least significant).
|
| |
| uint8_t | esphome::reverse_bits (uint8_t x) |
| | Reverse the order of 8 bits.
|
| |
| uint16_t | esphome::reverse_bits (uint16_t x) |
| | Reverse the order of 16 bits.
|
| |
| uint32_t | esphome::reverse_bits (uint32_t x) |
| | Reverse the order of 32 bits.
|
| |
| template<typename T > |
| constexpr T | esphome::convert_big_endian (T val) |
| | Convert a value between host byte order and big endian (most significant byte first) order.
|
| |
| template<typename T > |
| constexpr T | esphome::convert_little_endian (T val) |
| | Convert a value between host byte order and little endian (least significant byte first) order.
|
| |
|
| 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).
|
| |
|
| constexpr float | esphome::celsius_to_fahrenheit (float value) |
| | Convert degrees Celsius to degrees Fahrenheit.
|
| |
| constexpr float | esphome::fahrenheit_to_celsius (float value) |
| | Convert degrees Fahrenheit to degrees Celsius.
|
| |
|
| template<typename T , enable_if_t<!std::is_pointer< T >::value, int > = 0> |
| T | esphome::id (T value) |
| | Helper function to make id(var) known from lambdas work in custom components.
|
| |
| template<typename T , enable_if_t< std::is_pointer< T * >::value, int > = 0> |
| T & | esphome::id (T *value) |
| | Helper function to make id(var) known from lambdas work in custom components.
|
| |
|
| enum | esphome::ParseOnOffState : uint8_t { esphome::PARSE_NONE = 0
, esphome::PARSE_ON
, esphome::PARSE_OFF
, esphome::PARSE_TOGGLE
} |
| | Return values for parse_on_off(). More...
|
| |
| template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value), int > = 0> |
| optional< T > | esphome::parse_number (const char *str) |
| | Parse an unsigned decimal number from a null-terminated string.
|
| |
| template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value), int > = 0> |
| optional< T > | esphome::parse_number (const std::string &str) |
| | Parse an unsigned decimal number.
|
| |
| 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.
|
| |
| bool | esphome::parse_hex (const char *str, uint8_t *data, size_t count) |
| | Parse count bytes from the hex-encoded string str of at least 2*count characters into array data.
|
| |
| bool | esphome::parse_hex (const std::string &str, uint8_t *data, size_t count) |
| | Parse count bytes from the hex-encoded string str of at least 2*count characters into array data.
|
| |
| bool | esphome::parse_hex (const char *str, std::vector< uint8_t > &data, size_t count) |
| | Parse count bytes from the hex-encoded string str of at least 2*count characters into vector data.
|
| |
| bool | esphome::parse_hex (const std::string &str, std::vector< uint8_t > &data, size_t count) |
| | Parse count bytes from the hex-encoded string str of at least 2*count characters into vector data.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| optional< T > | esphome::parse_hex (const char *str, size_t len) |
| | Parse a hex-encoded string into an unsigned integer.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| optional< T > | esphome::parse_hex (const char *str) |
| | Parse a hex-encoded null-terminated string (starting with the most significant byte) into an unsigned integer.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| optional< T > | esphome::parse_hex (const std::string &str) |
| | Parse a hex-encoded null-terminated string (starting with the most significant byte) into an unsigned integer.
|
| |
| char | esphome::format_hex_char (uint8_t v) |
| | Convert a nibble (0-15) to lowercase hex char.
|
| |
| char | esphome::format_hex_pretty_char (uint8_t v) |
| | Convert a nibble (0-15) to uppercase hex char (used for pretty printing) This always uses uppercase (A-F) for pretty/human-readable output.
|
| |
| void | esphome::format_mac_addr_upper (const uint8_t *mac, char *output) |
| | Format MAC address as XX:XX:XX:XX:XX:XX (uppercase)
|
| |
| void | esphome::format_mac_addr_lower_no_sep (const uint8_t *mac, char *output) |
| | Format MAC address as xxxxxxxxxxxxxx (lowercase, no separators)
|
| |
| std::string | esphome::format_mac_address_pretty (const uint8_t mac[6]) |
| | Format the six-byte array mac into a MAC address.
|
| |
| 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.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| std::string | esphome::format_hex (T val) |
| | Format an unsigned integer in lowercased hex, starting with the most significant byte.
|
| |
| template<std::size_t N> |
| std::string | esphome::format_hex (const std::array< uint8_t, N > &data) |
| |
| 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 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< 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 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.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| std::string | esphome::format_hex_pretty (T val, char separator='.', bool show_length=true) |
| | Format an unsigned integer 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.
|
| |
| template<typename T , enable_if_t< std::is_unsigned< T >::value, int > = 0> |
| std::string | esphome::format_bin (T val) |
| | Format an unsigned integer in binary, starting with the most significant byte.
|
| |
| 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 uint8_t *buf, size_t buf_len) |
| |
| std::string | esphome::base64_encode (const std::vector< uint8_t > &buf) |
| |
| std::vector< uint8_t > | esphome::base64_decode (const std::string &encoded_string) |
| |
| size_t | esphome::base64_decode (const std::string &encoded_string, uint8_t *buf, size_t buf_len) |
| |
|
| std::string size_t | esphome::len |
| |
| 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::__attribute__ ((format(printf, 1, 3))) str_snprintf(const char *fmt |
| | snprintf-like function returning std::string of maximum length len (excluding null terminator).
|
| |
| std::string size_t std::string | esphome::__attribute__ ((format(printf, 1, 2))) str_sprintf(const char *fmt |
| | sprintf-like function returning std::string.
|
| |
| 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.
|
| |
| std::string | esphome::make_name_with_suffix (const char *name, size_t name_len, char sep, const char *suffix_ptr, size_t suffix_len) |
| | Optimized string concatenation: name + separator + suffix (const char* overload) Uses a fixed stack buffer to avoid heap allocations.
|
| |