mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-28 07:29:45 +00:00
Ensures positional continuity across rotation speed changes.
This commit is contained in:
parent
3d20ae47ea
commit
d2bfd59953
@ -38,9 +38,10 @@ Drive::Drive(int input_clock_rate, int revolutions_per_minute, int number_of_hea
|
||||
Drive::Drive(int input_clock_rate, int number_of_heads) : Drive(input_clock_rate, 300, number_of_heads) {}
|
||||
|
||||
void Drive::set_rotation_speed(float revolutions_per_minute) {
|
||||
// TODO: probably I should look into
|
||||
// whether doing all this with quotients is really a good idea.
|
||||
rotational_multiplier_ = 60.0f / revolutions_per_minute;
|
||||
const float new_rotational_multiplier = 60.0f / revolutions_per_minute;
|
||||
cycles_since_index_hole_ *= new_rotational_multiplier / rotational_multiplier_;
|
||||
rotational_multiplier_ = new_rotational_multiplier;
|
||||
cycles_since_index_hole_ %= int(get_input_clock_rate() * rotational_multiplier_);
|
||||
}
|
||||
|
||||
Drive::~Drive() {
|
||||
|
Loading…
Reference in New Issue
Block a user