File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,11 @@ New APIs and options
163
163
164
164
* :kconfig:option: `CONFIG_NET_SOCKETS_INET_RAW `
165
165
166
+ * Sensor
167
+
168
+ * :c:func: `sensor_value_to_deci `
169
+ * :c:func: `sensor_value_to_centi `
170
+
166
171
* Stepper
167
172
168
173
* :c:func: `stepper_stop() `
Original file line number Diff line number Diff line change @@ -1468,6 +1468,28 @@ struct sensor_info {
1468
1468
#define SENSOR_DEVICE_DT_INST_DEFINE (inst , ...) \
1469
1469
SENSOR_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
1470
1470
1471
+ /**
1472
+ * @brief Helper function for converting struct sensor_value to integer deci units.
1473
+ *
1474
+ * @param val A pointer to a sensor_value struct.
1475
+ * @return The converted value.
1476
+ */
1477
+ static inline int64_t sensor_value_to_deci (const struct sensor_value * val )
1478
+ {
1479
+ return ((int64_t )val -> val1 * 10 ) + val -> val2 / 100000 ;
1480
+ }
1481
+
1482
+ /**
1483
+ * @brief Helper function for converting struct sensor_value to integer centi units.
1484
+ *
1485
+ * @param val A pointer to a sensor_value struct.
1486
+ * @return The converted value.
1487
+ */
1488
+ static inline int64_t sensor_value_to_centi (const struct sensor_value * val )
1489
+ {
1490
+ return ((int64_t )val -> val1 * 100 ) + val -> val2 / 10000 ;
1491
+ }
1492
+
1471
1493
/**
1472
1494
* @brief Helper function for converting struct sensor_value to integer milli units.
1473
1495
*
You can’t perform that action at this time.
0 commit comments