1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Disambiguates whether Step will occur in addition to below zero/beyond maximum.

This commit is contained in:
Thomas Harte 2018-05-11 21:44:08 -04:00
parent a43ca0db35
commit 0cb5362c6f
2 changed files with 3 additions and 2 deletions

View File

@ -33,7 +33,7 @@ class Observer {
virtual void set_led_status(const std::string &name, bool lit) = 0;
enum class DriveEvent {
Step,
StepNormal,
StepBelowZero,
StepBeyondMaximum
};

View File

@ -50,10 +50,11 @@ bool Drive::get_is_track_zero() {
void Drive::step(HeadPosition offset) {
HeadPosition old_head_position = head_position_;
head_position_ += offset;
if(observer_) observer_->announce_drive_event(drive_name_, Activity::Observer::DriveEvent::Step);
if(head_position_ < HeadPosition(0)) {
head_position_ = HeadPosition(0);
if(observer_) observer_->announce_drive_event(drive_name_, Activity::Observer::DriveEvent::StepBelowZero);
} else {
if(observer_) observer_->announce_drive_event(drive_name_, Activity::Observer::DriveEvent::StepNormal);
}
// If the head moved, flush the old track.