floppyio – Read flux transition information into the buffer.

Available on these boards
  • 0xCB Helios
  • 42. Keebs Frood
  • Adafruit Feather M4 CAN
  • Adafruit Feather RP2040
  • Adafruit Feather RP2040 CAN
  • Adafruit Feather RP2040 DVI
  • Adafruit Feather RP2040 Prop-Maker
  • Adafruit Feather RP2040 RFM
  • Adafruit Feather RP2040 Scorpio
  • Adafruit Feather RP2040 ThinkInk
  • Adafruit Feather RP2040 USB Host
  • Adafruit Floppsy RP2040
  • Adafruit Grand Central M4 Express
  • Adafruit Hallowing M4 Express
  • Adafruit ItsyBitsy RP2040
  • Adafruit KB2040
  • Adafruit Macropad RP2040
  • Adafruit Metro RP2040
  • Adafruit Monster M4SK
  • Adafruit PyPortal
  • Adafruit PyPortal Pynt
  • Adafruit PyPortal Titano
  • Adafruit QT Py RP2040
  • Adafruit QT2040 Trinkey
  • AloriumTech Evo M51
  • Arduino Nano RP2040 Connect
  • BBQ20KBD
  • BDMICRO VINA-D51
  • BLOK
  • COSMO-Pico
  • CP32-M4
  • Challenger NB RP2040 WiFi
  • Challenger RP2040 LTE
  • Challenger RP2040 LoRa
  • Challenger RP2040 SD/RTC
  • Challenger RP2040 SubGHz
  • Challenger RP2040 WiFi
  • Challenger RP2040 WiFi/BLE
  • CircuitBrains Deluxe
  • Cytron EDU PICO W
  • Cytron Maker Nano RP2040
  • Cytron Maker Pi RP2040
  • Cytron Maker Uno RP2040
  • Datanoise PicoADK
  • DynOSSAT-EDU-OBC
  • E-Fidget
  • ELECFREAKS PICO:ED
  • Electrolama minik
  • EncoderPad RP2040
  • Fig Pi
  • HEIA-FR Picomo V2
  • Hack Club Sprig
  • LILYGO T-DISPLAY
  • Maple Computing Elite-Pi
  • Melopero Shake RP2040
  • Oak Dev Tech BREAD2040
  • Oak Dev Tech Cast-Away RP2040
  • P1AM-200
  • Pajenicko PicoPad
  • Pimoroni Badger 2040
  • Pimoroni Badger 2040 W
  • Pimoroni Inky Frame 5.7
  • Pimoroni Inky Frame 7.3
  • Pimoroni Interstate 75
  • Pimoroni Keybow 2040
  • Pimoroni Motor 2040
  • Pimoroni PGA2040
  • Pimoroni Pico DV Base W
  • Pimoroni Pico LiPo (16MB)
  • Pimoroni Pico LiPo (4MB)
  • Pimoroni Pico dv Base
  • Pimoroni PicoSystem
  • Pimoroni Plasma 2040
  • Pimoroni Plasma 2040W
  • Pimoroni Servo 2040
  • Pimoroni Tiny 2040 (2MB)
  • Pimoroni Tiny 2040 (8MB)
  • PyCubedv04
  • PyCubedv04-MRAM
  • PyCubedv05
  • PyCubedv05-MRAM
  • PyKey 18 Numpad
  • PyKey 44 Ergo
  • PyKey 60
  • PyKey 87 TKL
  • RF.Guru RP2040
  • RP2.65-F
  • RP2040 Stamp
  • Raspberry Breadstick
  • Raspberry Pi Pico
  • Raspberry Pi Pico W
  • Robo HAT MM1 M4
  • SAM32v26
  • Seeeduino XIAO RP2040
  • Silicognition LLC M4-Shim
  • Silicognition LLC RP2040-Shim
  • SparkFun MicroMod RP2040 Processor
  • SparkFun MicroMod SAMD51 Processor
  • SparkFun Pro Micro RP2040
  • SparkFun Thing Plus - RP2040
  • SparkFun Thing Plus - SAMD51
  • TG-Boards' Datalore IP M4
  • The Open Book Feather
  • UARTLogger II
  • VCC-GND Studio YD RP2040
  • W5100S-EVB-Pico
  • W5500-EVB-Pico
  • Waveshare RP2040-GEEK
  • Waveshare RP2040-LCD-0.96
  • Waveshare RP2040-LCD-1.28
  • Waveshare RP2040-Plus (16MB)
  • Waveshare RP2040-Plus (4MB)
  • Waveshare RP2040-TOUCH-LCD-1.28
  • Waveshare RP2040-Tiny
  • Waveshare RP2040-Zero
  • WeAct Studio Pico
  • WeAct Studio Pico 16MB
  • Winterbloom Sol
  • WisdPi Ardu2040M
  • WisdPi Tiny RP2040
  • nullbits Bit-C PRO
  • splitkb.com Liatris
  • takayoshiotake Octave RP2040
  • uGame22

floppyio.flux_readinto(buffer: circuitpython_typing.WriteableBuffer, data: digitalio.DigitalInOut, index: digitalio.DigitalInOut, index_wait=0.22) int

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:
  • buffer – Read data into this buffer. Each element represents the time between successive zero-to-one transitions.

  • data – Pin on which the flux data appears

  • index – Pin on which the index pulse appears

  • index_wait – Time to wait, in seconds, for the index pulse

Returns:

The actual number of bytes of read

floppyio.mfm_readinto(buffer: circuitpython_typing.WriteableBuffer, flux: circuitpython_typing.ReadableBuffer, flux_t2_max: int, flux_t3_max: int, validity: bytearray | None = None, clear_validity: bool = True) int

Decode MFM flux into the buffer

The track is assumed to consist of 512-byte sectors.

The function returns the number of sectors successfully read. In addition, it updates the validity buffer with information about which sectors were read.

MFM encoding uses pulses of 3 widths, “T2”, “T3” and “T4”. A 1440KiB disk in standard MFM format has “T2” pulses of 2000ns, “T3” pulses of 3000ns, and “T4” pulses of 4000ns.

Parameters t2_max and t3_max are used to distinguish these pulses. A pulse with p <= t2_max is a “T2” pulse, a pulse with t2_max < p <= t3_max is a “T3” pulse, and a pulse with t3_max < p is a “T4” pulse.

The following code can convert a number in nanoseconds to a number of samples for a given sample rate:

   def ns_to_count(ns, samplerate):
       return round(ns * samplerate * 1e-9)

This means the following typical values are a good starting place for a 1.44MB floppy:
t2_max = ns_to_count(2500, samplerate) # Mid way between T2 and T3 length
t3_max = ns_to_count(3500, samplerate) # Mid way between T2 and T3 length
Parameters:
  • buffer – Read data into this buffer. Byte length must be a multiple of 512.

  • flux – Flux data from a previous flux_readinto call

  • t2_max – Maximum time of a flux cell in counts.

  • t3_max – Nominal time of a flux cell in counts.

  • validity – Optional bytearray. For each sector successfully read, the corresponding validity entry is set to 1 and previously valid sectors are not decoded.

  • clear_validity – If True, clear the validity information before decoding and attempt to decode all sectors.

Returns:

The actual number of sectors read

floppyio.samplerate: int

The approximate sample rate in Hz used by flux_readinto.