Fix devicetree-coeffs bug
This commit is contained in:
parent
1983f31af9
commit
e24530b7c3
3 changed files with 5 additions and 5 deletions
|
|
@ -7,10 +7,10 @@ description: >
|
||||||
wet: For estimation of the fully dry state, given the battery voltage
|
wet: For estimation of the fully dry state, given the battery voltage
|
||||||
|
|
||||||
Note that each poly coefficient is specified as 1000 times its real values. This is because we can't
|
Note that each poly coefficient is specified as 1000 times its real values. This is because we can't
|
||||||
directly represent floating points in devicetree. The final evaludated value should be divided by
|
directly represent floating points in devicetree. The final evaluated value should be divided by
|
||||||
1000.0f in code.
|
1000.0f in code.
|
||||||
|
|
||||||
compatible: soil-calibration-coeffe
|
compatible: soil-calibration-coeffs
|
||||||
|
|
||||||
include: base.yaml
|
include: base.yaml
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ static inline float get_soil_moisture_percent(float battery_voltage,
|
||||||
|
|
||||||
const float dry2 = eval_poly(dry_coeffs, x);
|
const float dry2 = eval_poly(dry_coeffs, x);
|
||||||
const float wet2 = eval_poly(wet_coeffs, x);
|
const float wet2 = eval_poly(wet_coeffs, x);
|
||||||
const float percent2 = (raw_adc_output - dry) / (wet - dry);
|
const float percent2 = (raw_adc_output - dry2) / (wet2 - dry2);
|
||||||
LOG_INF("Read soil moisture 2: %.2f | Raw %u | Batt: %.2f | Dry: %.2f | Wet: %.2f",
|
LOG_INF("Read soil moisture 2: %.2f | Raw %u | Batt: %.2f | Dry: %.2f | Wet: %.2f",
|
||||||
100.0f * percent2, raw_adc_output, x, dry2, wet2);
|
100.0f * percent2, raw_adc_output, x, dry2, wet2);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue