Skip to content

Commit 41cd72f

Browse files
committed
V1.8a - Added support for 'noclick'
1 parent b161117 commit 41cd72f

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

ArduinoFloppyReader/lib/ArduinoInterface.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ using namespace ArduinoFloppyReader;
6363
#define COMMAND_ISWRITEPROTECTED '$' // Requires Firmware V1.8
6464
#define COMMAND_ENABLE_NOWAIT '*' // Requires Firmware V1.8
6565
#define COMMAND_GOTOTRACK_REPORT '=' // Requires Firmware V1.8
66+
#define COMMAND_DO_NOCLICK_SEEK 'O' // Requires Firmware V1.8a
6667

6768
#define SPECIAL_ABORT_CHAR 'x'
6869

@@ -627,6 +628,36 @@ DiagnosticResponse ArduinoInterface::setDiskCapacity(bool switchToHD_Disk) {
627628
return m_lastError;
628629
}
629630

631+
// If the drive is on track 0, this does a test seek to -1 if supported
632+
DiagnosticResponse ArduinoInterface::performNoClickSeek() {
633+
// And send the command and track. This is sent as ASCII text as a result of terminal testing. Easier to see whats going on
634+
bool isV18 = (m_version.major > 1) || ((m_version.major == 1) && (m_version.minor >= 8));
635+
if (!isV18) return DiagnosticResponse::drOldFirmware;
636+
if (!m_version.fullControlMod) return DiagnosticResponse::drOldFirmware;
637+
638+
m_lastError = runCommand(COMMAND_DO_NOCLICK_SEEK);
639+
if (m_lastError == DiagnosticResponse::drOK) {
640+
// Read extended data
641+
char status;
642+
if (!deviceRead(&status, 1, true)) {
643+
m_lastError = DiagnosticResponse::drReadResponseFailed;
644+
return m_lastError;
645+
}
646+
// 'x' means we didnt check it
647+
if (status != 'x') m_diskInDrive = status == '1';
648+
649+
// Also read the write protect status
650+
if (!deviceRead(&status, 1, true)) {
651+
m_lastError = DiagnosticResponse::drReadResponseFailed;
652+
return m_lastError;
653+
}
654+
m_isWriteProtected = status == '1';
655+
}
656+
657+
return m_lastError;
658+
}
659+
660+
630661
// Select the track, this makes the motor seek to this position
631662
DiagnosticResponse ArduinoInterface::selectTrack(const unsigned char trackIndex, const TrackSearchSpeed searchSpeed, bool ignoreDiskInsertCheck) {
632663
if (trackIndex > 81) {

ArduinoFloppyReader/lib/ArduinoInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ namespace ArduinoFloppyReader {
232232
// Select the track, this makes the motor seek to this position
233233
DiagnosticResponse selectTrack(const unsigned char trackIndex, const TrackSearchSpeed searchSpeed = TrackSearchSpeed::tssNormal, bool ignoreDiskInsertCheck = false);
234234

235+
// If the drive is on track 0, this does a test seek to -1 if supported
236+
DiagnosticResponse performNoClickSeek();
237+
235238
// Choose which surface of the disk to read from
236239
DiagnosticResponse selectSurface(const DiskSurface side);
237240

FloppyDriveController.sketch/FloppyDriveController.sketch.ino

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
Added some new functions which allow for more direct control of the drive
2929
Remove the Erase function as discovered you just need to write a longer track to ensure you clear the gap. Workbench writes 13630 bytes per track. The first part is filler at 0xAA
3030
Added support for disk change notifications support (requires small hardware modification below)
31+
Firmware V1.8a: Added 'no-click' support
3132
*/
3233

3334
/////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -403,6 +404,35 @@ bool goToTrack0() {
403404
return true;
404405
}
405406

407+
// Handle a no-click seeking operation
408+
void handleNoClickSeek() {
409+
if (currentTrack != 0) {
410+
// Not allowed.
411+
writeByteToUART('0');
412+
return;
413+
}
414+
415+
startDriveForOperation();
416+
417+
digitalWrite(PIN_MOTOR_DIR,MOTOR_TRACK_DECREASE); // Move OUT
418+
stepDirectionHead();
419+
smalldelay(1);
420+
421+
writeByteToUART('1');
422+
423+
// Now see if there is a disk in the drive. Returning '#' means no disk in drive
424+
if (advancedControllerMode) {
425+
if (digitalRead(PIN_DISK_CHANGE) == HIGH) writeByteToUART('1'); else writeByteToUART('#');
426+
} else {
427+
// Don't detect disk
428+
writeByteToUART('x');
429+
}
430+
if (digitalRead(PIN_WRITE_PROTECTED) == LOW) writeByteToUART('1'); else writeByteToUART('#');
431+
432+
stopDriveForOperation();
433+
}
434+
435+
406436
// Goto to a specific track. During testing it was easier for the track number to be supplied as two ASCII characters, so I left it like this
407437
bool gotoTrackX(bool reportDiskChange) {
408438
// Read the bytes
@@ -1481,7 +1511,10 @@ void loop() {
14811511
// Command "=" means goto track. Should be formatted as =00 or =32 etc. This also reports disk change and write protect status
14821512
case '=': if (gotoTrackX(true)) {
14831513
} else writeByteToUART('0');
1484-
break;
1514+
break;
1515+
1516+
case 'O': handleNoClickSeek();
1517+
break;
14851518

14861519
// Command "[" select LOWER disk side
14871520
case '[': digitalWrite(PIN_HEAD_SELECT,LOW);

0 commit comments

Comments
 (0)