Simple test
Ensure your device works with this simple test.
examples/floppy_simpletest.py
1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2# SPDX-FileCopyrightText: Copyright (c) 2022 Jeff Epler for Adafruit Industries
3#
4# SPDX-License-Identifier: Unlicense
5
6# On an Adafruit Feather M4 or Adafruit Feather RP2040 with Floppy Featherwing,
7# do some track-to-track seeking and flux reading.
8
9import board
10
11import adafruit_floppy
12
13D24 = getattr(board, "D24") or getattr(board, "A4")
14D25 = getattr(board, "D25") or getattr(board, "A5")
15
16floppy = adafruit_floppy.MFMFloppy(
17 densitypin=board.A1,
18 indexpin=D25,
19 selectpin=board.A0,
20 motorpin=board.A2,
21 directionpin=board.A3,
22 steppin=D24,
23 track0pin=board.D10,
24 protectpin=board.D11,
25 rddatapin=board.D9,
26 sidepin=board.D6,
27 readypin=board.D5,
28)
29
30floppy.selected = True
31floppy.spin = True
32print("Seek track 8")
33floppy.track = 8
34print("Seek track 0")
35floppy.track = 0
36print("Read partial track raw flux data")
37buf = bytearray(30000)
38n_read = floppy.flux_readinto(buf)
39print("read", n_read)
40buckets = [0] * 256
41for b in buf:
42 buckets[b] += 1
43oi = -1
44for i, bi in enumerate(buckets):
45 if bi > 10:
46 if i != oi + 1:
47 print("---")
48 oi = i
49 print(f"{i:3} {bi:5}")