mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 02:28:28 +02:00
Add encode_uint32 method (#1427)
This commit is contained in:
@@ -299,6 +299,10 @@ std::array<uint8_t, 2> decode_uint16(uint16_t value) {
|
||||
return {msb, lsb};
|
||||
}
|
||||
|
||||
uint32_t encode_uint32(uint8_t msb, uint8_t byte2, uint8_t byte3, uint8_t lsb) {
|
||||
return (uint32_t(msb) << 24) | (uint32_t(byte2) << 16) | (uint32_t(byte3) << 8) | uint32_t(lsb);
|
||||
}
|
||||
|
||||
std::string hexencode(const uint8_t *data, uint32_t len) {
|
||||
char buf[20];
|
||||
std::string res;
|
||||
|
||||
@@ -132,6 +132,8 @@ uint32_t reverse_bits_32(uint32_t x);
|
||||
uint16_t encode_uint16(uint8_t msb, uint8_t lsb);
|
||||
/// Decode a 16-bit unsigned integer into an array of two values: most significant byte, least significant byte.
|
||||
std::array<uint8_t, 2> decode_uint16(uint16_t value);
|
||||
/// Encode a 32-bit unsigned integer given four bytes in MSB -> LSB order
|
||||
uint32_t encode_uint32(uint8_t msb, uint8_t byte2, uint8_t byte3, uint8_t lsb);
|
||||
|
||||
/***
|
||||
* An interrupt helper class.
|
||||
|
||||
Reference in New Issue
Block a user