SCP: Only write the last continuous fluxmap.

This commit is contained in:
Thomas Daede
2021-12-06 11:42:16 -08:00
parent 376270dd53
commit 0c3c08db36
3 changed files with 20 additions and 2 deletions

View File

@@ -93,3 +93,18 @@ void Fluxmap::precompensate(int threshold_ticks, int amount_ticks)
}
}
}
std::vector<Fluxmap> Fluxmap::split() {
std::vector<Fluxmap> maps;
Fluxmap map;
for (unsigned i=0; i<_bytes.size(); i++) {
if (_bytes[i] == F_DESYNC) {
maps.push_back(map);
map = Fluxmap();
} else {
map.appendByte(_bytes[i]);
}
}
maps.push_back(map);
return maps;
}

View File

@@ -58,7 +58,8 @@ public:
Fluxmap& appendBits(const std::vector<bool>& bits, nanoseconds_t clock);
void precompensate(int threshold_ticks, int amount_ticks);
void precompensate(int threshold_ticks, int amount_ticks);
std::vector<Fluxmap> split();
private:
uint8_t& findLastByte();

View File

@@ -92,7 +92,9 @@ public:
trackheader.header.track_id[2] = 'K';
trackheader.header.strack = strack;
FluxmapReader fmr(fluxmap);
auto lastFluxmap = fluxmap.split().back();
FluxmapReader fmr(lastFluxmap);
Bytes fluxdata;
ByteWriter fluxdataWriter(fluxdata);