diff --git a/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp b/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp index 5da17b9a3..fe1e5199b 100644 --- a/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp +++ b/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp @@ -26,22 +26,23 @@ void DriveSpeedAccumulator::post_sample(uint8_t sample) { // Treat 33 as a zero point and count zero crossings; then approximate // the RPM from the frequency of those. int samples_over = 0; + int sum = 0; const uint8_t centre = 33; for(size_t c = 0; c < 512; ++c) { if(samples_[c] > centre) ++ samples_over; + sum += samples_[c]; } // TODO: if the above is the correct test, do it on sample receipt rather than // bothering with an intermediate buffer. - // The below fits for a function like `a + bc`; I'm not sure it's - const float duty_cycle = float(samples_over) / float(samples_.size()); - const float rotation_speed = 392.0f + duty_cycle * 19.95f; + // The below fits for a function like `a + bc`. + const float rotation_speed = (float(sum) * 0.052896440564137f) - 259.0f; for(int c = 0; c < number_of_drives_; ++c) { drives_[c]->set_rotation_speed(rotation_speed); } -// printf("RPM: %0.2f (%d over)\n", rotation_speed, samples_over); +// printf("RPM: %0.2f (%d over; %d sum)\n", rotation_speed, samples_over, sum); } }