Added the PLL phase adjustment stuff to the decoder. Much better decodes.

This commit is contained in:
David Given
2021-11-26 21:27:58 +01:00
parent 2cbe39e553
commit 910ccb273a

View File

@@ -4,6 +4,14 @@
#include "decoders/fluxdecoder.h" #include "decoders/fluxdecoder.h"
#include "lib/decoders/decoders.pb.h" #include "lib/decoders/decoders.pb.h"
/* This is a port of the samdisk code:
*
* https://github.com/simonowen/samdisk/blob/master/src/FluxDecoder.cpp
*
* I'm not actually terribly sure how it works, but it does, and much better
* than my code.
*/
FluxDecoder::FluxDecoder(FluxmapReader* fmr, nanoseconds_t bitcell, FluxDecoder::FluxDecoder(FluxmapReader* fmr, nanoseconds_t bitcell,
const DecoderProto& config): const DecoderProto& config):
_fmr(fmr), _fmr(fmr),
@@ -71,6 +79,12 @@ bool FluxDecoder::readBit()
_clock = std::min(std::max(_clock_min, _clock), _clock_max); _clock = std::min(std::max(_clock_min, _clock), _clock_max);
/* I'm not sure what this does, but the original comment is:
* Authentic PLL: Do not snap the timing window to each flux transition
*/
_flux = _flux * (1.0 - _pll_phase);
_goodbits++; _goodbits++;
return true; return true;
} }