Skip to content

Commit 90a33c1

Browse files
committed
Fix pre-commit messages
1 parent 96b2068 commit 90a33c1

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

adafruit_floppy.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def _check_inpos(self) -> None:
137137
drive_says_track0 = not self._track0.value
138138
we_think_track0 = track == 0
139139
if drive_says_track0 != we_think_track0:
140-
raise RuntimeError(f"Drive lost position (target={track}, track0 sensor {drive_says_track0})")
140+
raise RuntimeError(
141+
f"Drive lost position (target={track}, track0 sensor {drive_says_track0})"
142+
)
141143

142144
@property
143145
def track(self) -> typing.Optional[int]:
@@ -217,7 +219,7 @@ def flux_readinto(self, buf: "circuitpython_typing.WritableBuffer") -> int:
217219
return floppyio.flux_readinto(buf, self._rddata, self._index)
218220

219221

220-
class FloppyBlockDevice:
222+
class FloppyBlockDevice: # pylint: disable=too-many-instance-attributes
221223
"""Wrap an MFMFloppy object into a block device suitable for `storage.VfsFat`
222224
223225
The default heads/sectors/tracks setting are for 3.5", 1.44MB floppies.
@@ -238,12 +240,20 @@ class FloppyBlockDevice:
238240
print(os.listdir("/floppy"))
239241
"""
240242

241-
def __init__(self, floppy, heads=2, sectors=18, tracks=80, flux_buffer=None, t1_nom_ns: float=1000):
243+
def __init__( # pylint: disable=too-many-arguments
244+
self,
245+
floppy,
246+
heads=2,
247+
sectors=18,
248+
tracks=80,
249+
flux_buffer=None,
250+
t1_nom_ns: float = 1000,
251+
):
242252
self.floppy = floppy
243253
self.heads = heads
244254
self.sectors = sectors
245255
self.tracks = tracks
246-
self.flux_buffer = flux_buffer or buffer(sectors * 12 * 512)
256+
self.flux_buffer = flux_buffer or bytearray(sectors * 12 * 512)
247257
self.track0side0_cache = memoryview(bytearray(sectors * 512))
248258
self.track0side0_validity = bytearray(sectors)
249259
self.track_cache = memoryview(bytearray(sectors * 512))
@@ -257,7 +267,6 @@ def __init__(self, floppy, heads=2, sectors=18, tracks=80, flux_buffer=None, t1_
257267
self.cached_track = -1
258268
self.cached_side = -1
259269

260-
261270
def deinit(self):
262271
"""Deinitialize this object"""
263272
self.floppy.deinit()
@@ -316,5 +325,13 @@ def _mfm_readinto(self, track_data, validity):
316325
for i in range(5):
317326
self.floppy.flux_readinto(self.flux_buffer)
318327
print("timing bins", self._t2_5_max, self._t3_5_max)
319-
n = floppyio.mfm_readinto(track_data, self.flux_buffer, self._t2_5_max, self._t3_5_max, validity, i==0)
320-
if n == self.sectors: break
328+
n = floppyio.mfm_readinto(
329+
track_data,
330+
self.flux_buffer,
331+
self._t2_5_max,
332+
self._t3_5_max,
333+
validity,
334+
i == 0,
335+
)
336+
if n == self.sectors:
337+
break

examples/floppy_vfs.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# memory fragmentation
1111
flux_buffer = bytearray(110000)
1212

13+
# pylint: disable=wrong-import-position
1314
import os
1415
import storage
1516
import board
@@ -22,7 +23,7 @@
2223
ST_TIME = 7
2324
SV_BFREE = 3
2425

25-
if hasattr(board, 'DENSITY'): # floppsy
26+
if hasattr(board, "DENSITY"): # floppsy
2627
floppy = adafruit_floppy.Floppy(
2728
densitypin=board.DENSITY,
2829
indexpin=board.INDEX,
@@ -39,6 +40,9 @@
3940
)
4041

4142
else:
43+
D24 = getattr(board, "D24") or getattr(board, "A4")
44+
D25 = getattr(board, "D25") or getattr(board, "A5")
45+
4246
floppy = adafruit_floppy.Floppy(
4347
densitypin=board.A1,
4448
indexpin=D25,
@@ -51,17 +55,12 @@
5155
rddatapin=board.D9,
5256
sidepin=board.D6,
5357
readypin=board.D5,
54-
flux_buffer=flux_buffer
58+
flux_buffer=flux_buffer,
5559
)
5660

5761
floppy.find_track0()
58-
print(sum(floppy._index.value for _ in range(100_000)))
59-
print(floppy.flux_readinto(flux_buffer))
60-
print(sum(flux_buffer))
6162

62-
f = adafruit_floppy.FloppyBlockDevice(floppy, sectors=18,
63-
flux_buffer=flux_buffer
64-
)
63+
f = adafruit_floppy.FloppyBlockDevice(floppy, sectors=18, flux_buffer=flux_buffer)
6564

6665
vfs = storage.VfsFat(f)
6766
storage.mount(vfs, "/floppy")

0 commit comments

Comments
 (0)