I finally got around to implementing some of these changes, so fingers crossed (again!).
This confused this shit out of me:
So I did that, as it seems sensible, but then everything (calibration-specifically) broke. Took me a good 10min to figure out it was because the analog. library was using current_value and previous_value elsewhere in the code, so without those variables available outside of the main loop(), the calibration function wasn’t returning any values.
I’ve also implemented @TheTechnobear’s interrupt LED code into the main loop, which I’ll enable if/when I see problems again, to see if it has gotten stuck somewhere other than the main loop.