Arduino calibrator: persist slope/intercept and add getVoltage() method
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 27m
- Merged PRs (30d)
- 1
Description
## Summary
The calibration equation (`slope` and `intercept`) computed in `Calibrator::StateMachine::enterSecondRead()` is currently only printed to Serial and is not stored anywhere. Without persisting these values, the calibration cannot be applied to future voltage readings, defeating the purpose of the calibration process.
## Tasks
- [ ] Add `float slope`, `float intercept`, and `bool calibrated` member variables to the `StateMachine` class in `arduino/temp-netsender/calibrator.h`
- [ ] Initialize these members in the `Calibrator::StateMachine` constructor (e.g. `slope(1.0f)`, `intercept(0.0f)`, `calibrated(false)`)
- [ ] Assign the computed `slope` and `intercept` values and set `calibrated = true` inside `enterSecondRead()` in `arduino/temp-netsender/calibrator.cpp`
- [ ] Add a public `getVoltage(int rawReading)` method that returns `slope * rawReading + intercept` when calibrated, or a sensible fallback otherwise
## References
- Identified in PR #143: https://github.com/ausocean/client/pull/143
- Original review comment: https://github.com/ausocean/client/pull/143#discussion_r3216595655
Requested by @ao-david.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.