Open tyler-g opened 7 years ago
@sandeepmistry @tyler-g Hi folks! Sorry to zombie this, but I've just run into the "reading analog from LRADC doesn't give me enough fidelity" issue with a project of mine, and it looks like this PR might help resolve it.
Is there anything I can do to help get this across the finish line?
Allow VCC-1V8 pin to be read as 12-bit ADC
Based on some great information here: https://bbs.nextthing.co/t/chips-internal-adc/2136/59
The LRADC pin on the CHIP only allows for 6-bit (0-63) resolution. To allow for more precise reading, I've updated the axp209 controller so that if you request to read VCC-1V8 as analog, the axp209 tick will then call a special function to read the appropriate i2c register.
It will read 0 unless certain registers are written to allow for this. This is done in the
_configureVcc18Adc
which is called in the AXP209 open. I just put it there for testing, but it would be better if we could expose it somehow.This is not quite merge ready – need to figure out where to put the configure and reset calls. I didn't do much, just ported over the information in the above linked nextthing thread :)
Also, if anyone has suggestions on the efficiency of this, please feel free to send PRs or comments. I know we would want to keep the
tick
function as minimal as possible. Note that even though I've added to thistick
function, it will only attempt to read if you've requested that read, for example like this:I've tested this with an actual FSR sensor and it works great.