1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-28 07:29:45 +00:00

Extends Drive to report is_writing and so that writing works as the first action.

This commit is contained in:
Thomas Harte 2019-07-12 18:53:41 -04:00
parent 2c39229b13
commit 5b05a9bc61
2 changed files with 19 additions and 0 deletions

View File

@ -311,6 +311,15 @@ void Drive::invalidate_track() {
// MARK: - Writing
void Drive::begin_writing(Time bit_length, bool clamp_to_index_hole) {
// Do nothing if already writing.
if(!is_reading_) return;
// Get a copy of the track if that hasn't happened yet.
if(!track_) {
setup_track();
}
// Store the relevant parameters, and kick off writing.
is_reading_ = false;
clamp_writing_to_index_hole_ = clamp_to_index_hole;
@ -350,6 +359,10 @@ void Drive::end_writing() {
}
}
bool Drive::is_writing() {
return !is_reading_;
}
void Drive::set_activity_observer(Activity::Observer *observer, const std::string &name, bool add_motor_led) {
observer_ = observer;
announce_motor_led_ = add_motor_led;

View File

@ -100,6 +100,12 @@ class Drive: public ClockingHint::Source, public TimedEventLoop {
*/
void end_writing();
/*!
@returns @c true if the drive has received a call to begin_writing but not yet a call to
end_writing; @c false otherwise.
*/
bool is_writing();
/*!
Advances the drive by @c number_of_cycles cycles.
*/