1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-13 00:25:26 +00:00

This is a much better way of dealing with being partway into an incoming event. Subject to eliminating overruns, of course.

This commit is contained in:
Thomas Harte
2016-12-24 20:54:27 -05:00
parent 4cb17143ef
commit bedea48d03
2 changed files with 5 additions and 6 deletions

View File

@@ -49,8 +49,7 @@ void Controller::setup_track()
time_into_track_of_last_event_.set_zero(); time_into_track_of_last_event_.set_zero();
} }
reset_timer_to_offset(offset * rotational_multiplier_); get_next_event(offset);
get_next_event();
} }
void Controller::run_for_cycles(int number_of_cycles) void Controller::run_for_cycles(int number_of_cycles)
@@ -76,7 +75,7 @@ void Controller::run_for_cycles(int number_of_cycles)
#pragma mark - Track timed event loop #pragma mark - Track timed event loop
void Controller::get_next_event() void Controller::get_next_event(const Time &duration_already_passed)
{ {
if(track_) if(track_)
current_event_ = track_->get_next_event(); current_event_ = track_->get_next_event();
@@ -89,7 +88,7 @@ void Controller::get_next_event()
// divide interval, which is in terms of a rotation of the disk, by rotation speed, and // divide interval, which is in terms of a rotation of the disk, by rotation speed, and
// convert it into revolutions per second // convert it into revolutions per second
set_next_event_time_interval(current_event_.length * rotational_multiplier_); set_next_event_time_interval((current_event_.length - duration_already_passed) * rotational_multiplier_);
} }
void Controller::process_next_event() void Controller::process_next_event()
@@ -108,7 +107,7 @@ void Controller::process_next_event()
process_index_hole(); process_index_hole();
break; break;
} }
get_next_event(); get_next_event(Time(0));
} }
Storage::Time Controller::get_time_into_track() Storage::Time Controller::get_time_into_track()

View File

@@ -110,7 +110,7 @@ class Controller: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop
std::shared_ptr<Track> track_; std::shared_ptr<Track> track_;
unsigned int cycles_since_index_hole_, cycles_since_event_; unsigned int cycles_since_index_hole_, cycles_since_event_;
inline void get_next_event(); inline void get_next_event(const Time &duration_already_passed);
Track::Event current_event_; Track::Event current_event_;
Time time_into_track_of_last_event_; Time time_into_track_of_last_event_;
bool motor_is_on_; bool motor_is_on_;