I've witnessed zeros as well as values larger than the initial setting,
albeit spuriously. Added a saturating subtraction and a modulo to the
position calculation and overrun now seems to be working correctly
There still seems to be more overruns than should strictly be happening,
but I've been unable to pin them down and they disappear when clocking
low enough. They might even be real but it is difficult to know. But
this fix is solid
Thank you, @electroCutie. I've left a comment in your commit. Some additional notes:
There are known problems with ADC/DMA that might account for the overruns you're seeing. See #104 and #105.
I think it's better to move some of the explanation from your commit message into the code, as a comment. When wondering why something looks like it does, it's always nicer to have a comment right there, instead of having to hunt for the right commit message.
I've witnessed zeros as well as values larger than the initial setting, albeit spuriously. Added a saturating subtraction and a modulo to the position calculation and overrun now seems to be working correctly
There still seems to be more overruns than should strictly be happening, but I've been unable to pin them down and they disappear when clocking low enough. They might even be real but it is difficult to know. But this fix is solid
Fix for #125