Skip to content

Commit

Permalink
Add sub-gram decimal point (#10)
Browse files Browse the repository at this point in the history
In the `sensor_value` val1 represents the integer part of the value, with val2 representing the fractional part.

Previously val2 was unset, leaving us without decimal points and no sub-gram precision.
  • Loading branch information
adisbladis authored Nov 11, 2024
1 parent c0404ba commit 93036a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/sensor/hx711/hx711.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ static int hx711_channel_get(const struct device *dev, enum sensor_channel chan,

switch (hx711_chan) {
case HX711_SENSOR_CHAN_WEIGHT: {
val->val1 = sensor_value_to_double(&data->slope) * (data->reading - data->offset);
sensor_value_from_double(val, sensor_value_to_double(&data->slope) * (data->reading - data->offset));
return 0;
}
default:
Expand Down

0 comments on commit 93036a1

Please # to comment.