adafruit_floppy¶
Interface with old floppy drives.
Author(s): Jeff Epler
- class adafruit_floppy.Floppy(*, densitypin: Pin, indexpin: Pin, selectpin: Pin, motorpin: Pin, directionpin: Pin, steppin: Pin, track0pin: Pin, protectpin: Pin, rddatapin: Pin, sidepin: Pin, readypin: Pin, wrdatapin: Pin | None = None, wrgatepin: Pin | None = None, floppydirectionpin: Pin | None = None)¶
Interface with floppy disk drive hardware
- find_track0()¶
Move the head out until the ‘track0’ signal becomes False
If successful, sets the internal track number to 0.
If unsuccsessful, sets the internatl track number to None and raises an exception.
- flux_readinto(buf: circuitpython_typing.WritableBuffer) int ¶
Read flux transition information into the buffer.
The function returns when the buffer has filled, or when the index input indicates that one full revolution of data has been recorded. Due to technical limitations, this process may not be interruptible by KeyboardInterrupt.
- Parameters:
buf – Read data into this buffer. Each element represents the time between successive zero-to-one transitions.
- Returns:
The actual number of bytes of read
- class adafruit_floppy.FloppyBlockDevice(floppy, heads=2, sectors=18, tracks=80, flux_buffer=None, t1_nom_ns: float = 1000)¶
Wrap an MFMFloppy object into a block device suitable for
storage.VfsFat
The default heads/sectors/tracks setting are for 3.5”, 1.44MB floppies.
In the current implementation, the floppy is read-only.
A cache is used for track 0 on cylinder 0 and for the last track accessed.
Example:
import storage import adafruit_floppy floppy = adafruit_floppy.Floppy(...) block_device = adafruit_floppy.FloppyBlockDevice(floppy) vfs = storage.VfsFat(f) storage.mount(vfs, '/floppy') print(os.listdir("/floppy"))
- count()¶
Return the floppy capacity in 512-byte units
- deinit()¶
Deinitialize this object
- readblocks(start_block, buf)¶
Read a number of blocks from the flopppy
- sync()¶
Write out any pending data to disk (does nothing)
- writeblocks(start, buf)¶
Write to the floppy (always raises an exception)