[sensirion_common] Move sen5x's sensirion_convert_to_string_in_place() function to sensirion_common (#14269)

This commit is contained in:
Big Mike authored and GitHub committed 2026-02-25 07:34:58 -05:00
1 parent b134c4679c
commit bb05cfb711
2 files changed
+11 -9

No files matched your search

-9
View File
@@ -56,15 +56,6 @@ static const LogString *rht_accel_mode_to_string(RhtAccelerationMode mode) {
}
}
// This function performs an in-place conversion of the provided buffer
// from uint16_t values to big endianness
static inline const char *sensirion_convert_to_string_in_place(uint16_t *array, size_t length) {
for (size_t i = 0; i < length; i++) {
array[i] = convert_big_endian(array[i]);
}
return reinterpret_cast<const char *>(array);
}
void SEN5XComponent::setup() {
// the sensor needs 1000 ms to enter the idle state
this->set_timeout(1000, [this]() {
@@ -21,6 +21,17 @@ class SensirionI2CDevice : public i2c::I2CDevice {
public:
enum CommandLen : uint8_t { ADDR_8_BIT = 1, ADDR_16_BIT = 2 };
/**
* This function performs an in-place conversion of the provided buffer
* from uint16_t values to big endianness. Useful for Sensirion strings in SEN5X and SEN6X
*/
static inline const char *sensirion_convert_to_string_in_place(uint16_t *array, size_t length) {
for (size_t i = 0; i < length; i++) {
array[i] = convert_big_endian(array[i]);
}
return reinterpret_cast<const char *>(array);
}
/** Read data words from I2C device.
* handles CRC check used by Sensirion sensors
* @param data pointer to raw result