diff --git a/freude.py b/freude.py index 2ce983f..82b6a02 100644 --- a/freude.py +++ b/freude.py @@ -1,9 +1,12 @@ import csv +# actually an arbitrary scaling factor steps_per_mm = 5 # starting from C3 = 130.81 Hz frequencies = [2**(i/12) * 130.81 for i in range(24)] -base_duration = 0.12 +bpm = 60 +# duration of 1/8th +base_duration = 60 / bpm / 8 with open("FREUDE.gcode", "w") as f: f.write("G21 ; set units to millimeters\n") @@ -18,5 +21,5 @@ with open("FREUDE.gcode", "w") as f: length = int(duration) * base_duration / 60 * feedrate position += -length if position > 100 else length f.write(f"G0 X{position:.6f} Y{position:.6f} F{feedrate} \n") - f.write("G4 P15 ; wait a bit\n") + f.write(f"G4 P{int(int(duration) * base_duration * 50)} ; wait a bit\n") f.write("G4 ; wait\n")