-
Notifications
You must be signed in to change notification settings - Fork 0
/
tunes__settings.cfg
507 lines (390 loc) · 13 KB
/
tunes__settings.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
[include tunes_nokia_ringtone.cfg]
# [include tunes_pink_panter.cfg]
# [include tunes_packman.cfg]
# [include tunes_startrek.cfg]
# [include tunes_starwars.cfg]
# [include tunes_thelionsleeps.cfg]
# [include tunes_imperialmarch.cfg]
# [include tunes_happybirthday.cfg]
# If you are going to use some of the "well known tunes" in this repository, uncomment the ones you copied above.
#############################################################################################################################
#
# This file contains 4 sections to configure notes for music:
# - Section 1: Set the time base for notes and pauses
# - Section 2: Settings for duration of tones
# - Section 3: All 88 notes on a full piano keyboard translated to Cycle times
# - Section 4: Macro for controlling buzzer directly
#
# Tunes are defined in separate files and need to be in include statements on the top of this file (pls see examples above)
# On top of the printer.cfg file needs to be this file i.e.:
#
# [include tunes__settings.cfg]
#
# Please see NOKIA RINGTONE example tune for explanation of 'how to make tunes'.
#
# Using the buzzer pin from EXP1_1 being PE8 to connect a buzzer / speaker there
# Put settings below in printer.cfg to make buzzer work
#
# #########################################################################################################################
# # BUZZER / SPEAKER
# #########################################################################################################################
#
# [pwm_cycle_time buzzer]
# pin: PE8 # output_pin
# value: 0.0
# shutdown_value: 0.0
# cycle_time: 0.001
#
#############################################################################################################################
#############################################################################################################################
# Section 1: Set the time base for notes and pauses
#############################################################################################################################
[gcode_macro time_base]
variable_tune_time_base: 1.0 ### At value 1 a full note is 1024 miliseconds, the variable works as a multiplier
gcode:
M115 ### Get Version/Basically a Nop, but you need it to make this work...
# #For debugging
# [gcode_macro test_time_base]
# gcode:
# M118 The value of test_time_base is {printer["gcode_macro time_base"].tune_time_base}
#############################################################################################################################
# Section 2: Settings for duration of tones
#############################################################################################################################
[gcode_macro _D_80]
description: Octuple note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 8192}
[gcode_macro _D_40]
description: Quadriple note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 4096}
[gcode_macro _D_20]
description: Double note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 2048}
[gcode_macro _D_01]
description: Full note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 1024}
[gcode_macro _D_02]
description: Half note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 512}
[gcode_macro _D_04]
description: One 4th note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 256}
[gcode_macro _D_08]
description: One 8th note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 128}
[gcode_macro _D_16]
description: One 16th note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 64}
[gcode_macro _D_32]
description: One 32th note
gcode:
G4 P{printer["gcode_macro time_base"].tune_time_base * 32}
#############################################################################################################################
# Section 3: All 88 notes on a full piano keyboard translated to Cycle times
# With thanks to Robson Couto, who developped the original data: https://github.com/robsoncouto
# He did an amazing job...!!!
#############################################################################################################################
[gcode_macro _NOTE_B0]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.032258 VALUE=0.5
[gcode_macro _NOTE_C1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.030303 VALUE=0.5
[gcode_macro _NOTE_CS1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.028571 VALUE=0.5
[gcode_macro _NOTE_D1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.027027 VALUE=0.5
[gcode_macro _NOTE_DS1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.025641 VALUE=0.5
[gcode_macro _NOTE_E1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.024390 VALUE=0.5
[gcode_macro _NOTE_F1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.022727 VALUE=0.5
[gcode_macro _NOTE_FS1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.021739 VALUE=0.5
[gcode_macro _NOTE_G1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.020408 VALUE=0.5
[gcode_macro _NOTE_GS1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.019231 VALUE=0.5
[gcode_macro _NOTE_A1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.018182 VALUE=0.5
[gcode_macro _NOTE_AS1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.017241 VALUE=0.5
[gcode_macro _NOTE_B1]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.016129 VALUE=0.5
[gcode_macro _NOTE_C2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.015385 VALUE=0.5
[gcode_macro _NOTE_CS2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.014493 VALUE=0.5
[gcode_macro _NOTE_D2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.013699 VALUE=0.5
[gcode_macro _NOTE_DS2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.012821 VALUE=0.5
[gcode_macro _NOTE_E2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.012195 VALUE=0.5
[gcode_macro _NOTE_F2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.011494 VALUE=0.5
[gcode_macro _NOTE_FS2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.010753 VALUE=0.5
[gcode_macro _NOTE_G2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.010204 VALUE=0.5
[gcode_macro _NOTE_GS2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.009615 VALUE=0.5
[gcode_macro _NOTE_A2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.009091 VALUE=0.5
[gcode_macro _NOTE_AS2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.008547 VALUE=0.5
[gcode_macro _NOTE_B2]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.008130 VALUE=0.5
[gcode_macro _NOTE_C3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.007634 VALUE=0.5
[gcode_macro _NOTE_CS3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.007194 VALUE=0.5
[gcode_macro _NOTE_D3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.006803 VALUE=0.5
[gcode_macro _NOTE_DS3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.006410 VALUE=0.5
[gcode_macro _NOTE_E3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.006061 VALUE=0.5
[gcode_macro _NOTE_F3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.005714 VALUE=0.5
[gcode_macro _NOTE_FS3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.005405 VALUE=0.5
[gcode_macro _NOTE_G3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.005102 VALUE=0.5
[gcode_macro _NOTE_GS3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.004808 VALUE=0.5
[gcode_macro _NOTE_A3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.004545 VALUE=0.5
[gcode_macro _NOTE_AS3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.004291 VALUE=0.5
[gcode_macro _NOTE_B3]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.004049 VALUE=0.5
[gcode_macro _NOTE_C4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.003817 VALUE=0.5
[gcode_macro _NOTE_CS4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.003613 VALUE=0.5
[gcode_macro _NOTE_D4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.003401 VALUE=0.5
[gcode_macro _NOTE_DS4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.003215 VALUE=0.5
[gcode_macro _NOTE_E4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.003030 VALUE=0.5
[gcode_macro _NOTE_F4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002865 VALUE=0.5
[gcode_macro _NOTE_FS4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002703 VALUE=0.5
[gcode_macro _NOTE_G4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002551 VALUE=0.5
[gcode_macro _NOTE_GS4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002410 VALUE=0.5
[gcode_macro _NOTE_A4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002273 VALUE=0.5
[gcode_macro _NOTE_AS4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002146 VALUE=0.5
[gcode_macro _NOTE_B4]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.002025 VALUE=0.5
[gcode_macro _NOTE_C5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001913 VALUE=0.5
[gcode_macro _NOTE_CS5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001805 VALUE=0.5
[gcode_macro _NOTE_D5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001703 VALUE=0.5
[gcode_macro _NOTE_DS5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001607 VALUE=0.5
[gcode_macro _NOTE_E5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001516 VALUE=0.5
[gcode_macro _NOTE_F5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001433 VALUE=0.5
[gcode_macro _NOTE_FS5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001351 VALUE=0.5
[gcode_macro _NOTE_G5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001276 VALUE=0.5
[gcode_macro _NOTE_GS5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001204 VALUE=0.5
[gcode_macro _NOTE_A5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001136 VALUE=0.5
[gcode_macro _NOTE_AS5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001073 VALUE=0.5
[gcode_macro _NOTE_B5]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.001012 VALUE=0.5
[gcode_macro _NOTE_C6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000955 VALUE=0.5
[gcode_macro _NOTE_CS6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000902 VALUE=0.5
[gcode_macro _NOTE_D6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000851 VALUE=0.5
[gcode_macro _NOTE_DS6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000803 VALUE=0.5
[gcode_macro _NOTE_E6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000758 VALUE=0.5
[gcode_macro _NOTE_F6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000716 VALUE=0.5
[gcode_macro _NOTE_FS6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000676 VALUE=0.5
[gcode_macro _NOTE_G6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000638 VALUE=0.5
[gcode_macro _NOTE_GS6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000602 VALUE=0.5
[gcode_macro _NOTE_A6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000568 VALUE=0.5
[gcode_macro _NOTE_AS6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000536 VALUE=0.5
[gcode_macro _NOTE_B6]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000506 VALUE=0.5
[gcode_macro _NOTE_C7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000478 VALUE=0.5
[gcode_macro _NOTE_CS7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000451 VALUE=0.5
[gcode_macro _NOTE_D7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000426 VALUE=0.5
[gcode_macro _NOTE_DS7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000402 VALUE=0.5
[gcode_macro _NOTE_E7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000379 VALUE=0.5
[gcode_macro _NOTE_F7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000358 VALUE=0.5
[gcode_macro _NOTE_FS7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000338 VALUE=0.5
[gcode_macro _NOTE_G7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000319 VALUE=0.5
[gcode_macro _NOTE_GS7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000301 VALUE=0.5
[gcode_macro _NOTE_A7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000284 VALUE=0.5
[gcode_macro _NOTE_AS7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000268 VALUE=0.5
[gcode_macro _NOTE_B7]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000253 VALUE=0.5
[gcode_macro _NOTE_C8]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000239 VALUE=0.5
[gcode_macro _NOTE_CS8]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000226 VALUE=0.5
[gcode_macro _NOTE_D8]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000213 VALUE=0.5
[gcode_macro _NOTE_DS8]
gcode:
SET_PIN PIN=buzzer CYCLE_TIME=0.000201 VALUE=0.5
#############################################################################################################################
# Section 4: Macro for controlling buzzer directly
#############################################################################################################################
#BUZZER Macro is to use the Buzzer
[gcode_macro BUZZER]
gcode:
{% set frequency = params.F|default(2000)|int %}
{% set duration = params.D|default(1.0)|float %}
{% set volume = params.V|default(0.5)|float %}
# Ensure volume is within 0.0 to 0.9
{% if volume > 0.9 %}
{% set volume = 0.9 %}
{% elif volume < 0.0 %}
{% set volume = 0.0 %}
{% endif %}
# Calculate the cycle time based on the frequency
{% set buzz_cycle_time = 1.0 / frequency %}
# Debugging messages to verify the parameters (Optional)
# Debugging messages to verify the parameters
# {action_respond_info("Frequency: " ~ frequency)}
# {action_respond_info("Cycle time: " ~ buzz_cycle_time)}
# {action_respond_info("Volume: " ~ volume)}
# {action_respond_info("Duration: " ~ duration)}
# Set the cycle time first to adjust the frequency
SET_PIN PIN=buzzer CYCLE_TIME={buzz_cycle_time} VALUE={volume}
# Play the buzzer for the specified duration
G4 P{duration * 1000} # Delay for the duration in milliseconds
# Turn off the buzzer
SET_PIN PIN=buzzer VALUE=0
M400 # Wait for moves to finish