Precompensation adjustment is now done before writing (using hard-coded

values).
This commit is contained in:
David Given
2019-01-03 22:03:00 +01:00
parent d1f4e6e198
commit 8d8f7b43c7
3 changed files with 28 additions and 0 deletions

View File

@@ -22,3 +22,27 @@ Fluxmap& Fluxmap::appendIntervals(const uint8_t* ptr, size_t len)
return *this;
}
void Fluxmap::precompensate(int threshold_ticks, int amount_ticks)
{
uint8_t junk = 0xff;
for (unsigned i=0; i<_intervals.size(); i++)
{
uint8_t& prev = (i == 0) ? junk : _intervals[i-1];
uint8_t& curr = _intervals[i];
if ((prev <= threshold_ticks) && (curr > threshold_ticks))
{
/* 01001; move the previous bit backwards. */
prev -= amount_ticks;
curr += amount_ticks;
}
else if ((prev > threshold_ticks) && (curr <= threshold_ticks))
{
/* 00101; move the current bit forwards. */
prev += amount_ticks;
curr -= amount_ticks;
}
}
}

View File

@@ -27,6 +27,8 @@ public:
Fluxmap& appendBits(const std::vector<bool>& bits, nanoseconds_t clock);
void precompensate(int threshold_ticks, int amount_ticks);
private:
nanoseconds_t _duration = 0;
int _ticks = 0;

View File

@@ -3,6 +3,7 @@
#include "fluxmap.h"
#include "writer.h"
#include "sql.h"
#include "protocol.h"
#include "fmt/format.h"
#include <regex>
@@ -73,6 +74,7 @@ void writeTracks(const std::function<Fluxmap(int track, int side)> producer)
{
std::cout << fmt::format("{0:>3}.{1}: ", track, side) << std::flush;
Fluxmap fluxmap = producer(track, side);
fluxmap.precompensate(PRECOMPENSATION_THRESHOLD_TICKS, 2);
if (outdb)
sqlWriteFlux(outdb, track, side, fluxmap);
else