Allow fractional revolutions and non-synced reading. Find more things which

need fixing in the firmware sampler.
This commit is contained in:
David Given
2020-01-27 22:52:25 +01:00
parent 933ffe7ab4
commit 29bdfc043a
8 changed files with 83 additions and 56 deletions

View File

@@ -3,13 +3,19 @@
#include "fluxmap.h"
#include "usb.h"
#include "fluxsource/fluxsource.h"
#include "fmt/format.h"
FlagGroup hardwareFluxSourceFlags;
static IntFlag revolutions(
static DoubleFlag revolutions(
{ "--revolutions" },
"read this many revolutions of the disk",
1);
1.25);
static BoolFlag synced(
{ "--sync-with-index" },
"whether to wait for an index pulse before started to read",
false);
static IntFlag indexMode(
{ "--index-mode" },
@@ -29,6 +35,10 @@ public:
HardwareFluxSource(unsigned drive):
_drive(drive)
{
usbSetDrive(_drive, high_density, indexMode);
std::cerr << "Measuring rotational speed... " << std::flush;
_oneRevolution = usbGetRotationalPeriod();
std::cerr << fmt::format("{}ms\n", _oneRevolution / 1e6);
}
~HardwareFluxSource()
@@ -40,9 +50,10 @@ public:
{
usbSetDrive(_drive, high_density, indexMode);
usbSeek(track);
Bytes crunched = usbRead(side, revolutions);
Bytes crunched = usbRead(side, synced, revolutions * _oneRevolution);
auto fluxmap = std::make_unique<Fluxmap>();
fluxmap->appendBytes(crunched.uncrunch());
std::cerr << "return fluxmap\n";
return fluxmap;
}
@@ -59,13 +70,19 @@ public:
private:
unsigned _drive;
unsigned _revolutions;
nanoseconds_t _oneRevolution;
};
void setHardwareFluxSourceRevolutions(int revolutions)
void setHardwareFluxSourceRevolutions(double revolutions)
{
::revolutions.setDefaultValue(revolutions);
}
void setHardwareFluxSourceSynced(bool synced)
{
::synced.setDefaultValue(synced);
}
std::unique_ptr<FluxSource> FluxSource::createHardwareFluxSource(unsigned drive)
{
return std::unique_ptr<FluxSource>(new HardwareFluxSource(drive));