Skip to content

Aiq0/floppy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Floppy

Floppy is project build to play with embedded Linux on Raspberry Pi Zero as part of Embedded Linux course on Comenius University.

This project builds minimal Linux system with support for controlling floppy drives' stepper motors to play music with controls over WiFi / Serial. The system is built using Buildroot.

Prerequisites

  • Raspberry Pi Zero 2 W
  • floppy drive(s) + some 5V DC power source (~0.9A per drive should be sufficient)
  • some jumper cables
  • Linux with docker installed
  • this repository cloned: git clone --recurse-submodules git@github.com:Aiq0/floppy.git

Wiring

Floppy drive pinout

Connect floppy drive 5V (right) & GND (center) to you 5V DC power source and connect GND to Pi. Also connect Drive Select (6th from left in top row) with GND (bottom row). Then connect Direction (9th from left top) and Step (10th from left top) to any unused GPIO pins on Pi.

Configuration

Edit build/config/floppy.conf and specify the GPIO pins you used.

You can also edit build/config/hostapd.conf to change WiFi SSID and password.

Building

docker build -t floppy-builder .
docker run --rm -it -v ./build:/build -v ./output:/output floppy-builder

This will create image in build/buildroot/output/images/sdcard.img. Then copy that image to Pi's SD card (make sure to replace /dev/sdX with CORRECT drive):

dd if=sdcard.img of=/dev/sdX bs=4M status=progress

Controls

Web

Connect to WiFi network specified in build/config/hostapd.conf and open http://192.168.9.1/.

Shell

Connect via SSH over WiFi or over serial. Default username is root without password.

To play a song, use:

floppy < /songs/your-song

Song format

Songs are plain text files where each line represents a note command:

channel offset duration frequency

  • channel - floppy drive number (starting from 0, max number of drives you set in floppy.conf)
  • offset - time in seconds from start when to play the note
  • duration - time in seconds how long to play the note
  • frequency - frequency of the note in Hz

Important

Make sure that the offset and duration values are such that notes do not overlap in one channel and that lines are sorted by offset (at least per channel).

Song ends when all notes are played.

Example

0   0.0    2.0   130.81
0   2.0    2.0   146.83
0   4.0    2.0   164.81
0   6.0    2.0   174.61
0   8.0    2.0   196.00
0   10.0   2.0   220.00
0   12.0   2.0   246.94
0   14.0   2.0   261.63

1   1.0    2.0   261.63
1   3.0    2.0   246.94
1   5.0    2.0   220.00
1   7.0    2.0   196.00
1   9.0    2.0   174.61
1   11.0   2.0   164.81
1   13.0   2.0   146.83
1   15.0   2.0   130.81

Convert from MIDI

You can use scripts/midi.py (requires uv or python3 and miditoolkit installed) to convert MIDI files to this format:

./scripts/midi.py input.mid "Trumpet:transposition=-12" "Strings:transposition=-24" > song

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Contributors