mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Precompensation adjustment is now done before writing (using hard-coded
values).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user