1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-26 03:29:40 +00:00

Drives can now deliver activity events.

This commit is contained in:
Thomas Harte
2018-05-10 21:54:10 -04:00
parent 85e1610627
commit ef19a03efc
12 changed files with 77 additions and 32 deletions
+24
View File
@@ -88,6 +88,14 @@ bool Drive::get_is_ready() {
void Drive::set_motor_on(bool motor_is_on) {
motor_is_on_ = motor_is_on;
if(observer_) {
observer_->set_drive_motor_status(drive_name_, motor_is_on_);
if(announce_motor_led_) {
observer_->set_led_status(drive_name_, motor_is_on_);
}
}
if(!motor_is_on) {
ready_index_count_ = 0;
if(disk_) disk_->flush_tracks();
@@ -265,3 +273,19 @@ void Drive::end_writing() {
invalidate_track();
}
}
void Drive::set_activity_observer(Activity::Observer *observer, const std::string &name, bool add_motor_led) {
observer_ = observer;
announce_motor_led_ = add_motor_led;
if(observer) {
drive_name_ = name;
observer->register_drive(drive_name_);
observer->set_drive_motor_status(drive_name_, motor_is_on_);
if(add_motor_led) {
observer->register_led(drive_name_);
observer->set_led_status(drive_name_, motor_is_on_);
}
}
}