esp-idf-hal
esp-idf-hal copied to clipboard
Bugfix: drop calibration handle on driver drop; more control on the r…
- Turns out, the "new" oneshot ADC driver does not deallocate the
adc_cali_handleon drop. - I also noticed that the
calibrationbool from theConfigdoes not have any effect. The driver always uses calibration, even ifcalibrationis set tofalse(which it is by default).
The fix also introduces a breaking change, in that the user is now capable of selecting the calibration scheme when configuring the driver (or no calibration), with:
Calibration::NoneCalibration::CurveFittingCalibration::LineFitting
Besides the small c2 thing, i am a bit skeptical about the correctness of the magic numbers we set on the attenuation matcher. E.g the return values we define as get_max_mv.
But since that is not something you touched i am fine with the PR.
The magic numbers are taken from the 4.4.X oneshot driver documentation here.
Weird, but while the new oneshot driver does explicitly list the same raw-level-to-mV conversion formula, it does not list reference min and max mV for each attenuation. Maybe just an omission in the documentation? Also the listed reference numbers are for esp32 and esp32s2, and no info for new MCUs, but this is the best we have.
But regardless - my point is - if you find "less magical" reference numbers for doing raw-to-mV conversion without calibration (and yes, I still think it is worth it to support this use case given that its conversion formula is explicitly documented in ESP IDF - both in legacy and new oneshot driver) - please paste the link here and I would gladly use your reference numbers instead! :D