aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authors-holst <mail@s-holst.de>2021-07-21 00:00:11 +0900
committerGitHub <noreply@github.com>2021-07-20 11:00:11 -0400
commitc20a830e637171fa95d7956d48ce12b9d3e2cbb2 (patch)
tree6e4b5ad24ad67be30a39cfd877d622f4def2b4e6 /config
parent103dcf27ffd7cf1c4f70868c2ba1828ee4fbe37a (diff)
downloadkutter-c20a830e637171fa95d7956d48ce12b9d3e2cbb2.tar.gz
kutter-c20a830e637171fa95d7956d48ce12b9d3e2cbb2.tar.xz
kutter-c20a830e637171fa95d7956d48ce12b9d3e2cbb2.zip
config: Fix M300 beeper example. (#4480)
The M300 example macro now sets the PWM cycle time to generate the requested frequency. 'scale' did not have the desired effect. Duty cycle is now fixed at 0.5. All S parameter values less than 1 generate a 1Hz 'tone' to avoid division-by-zero. Signed-off-by: Stefan Holst <mail@s-holst.de>
Diffstat (limited to 'config')
-rw-r--r--config/sample-macros.cfg6
1 files changed, 2 insertions, 4 deletions
diff --git a/config/sample-macros.cfg b/config/sample-macros.cfg
index 0eb049ac..fcb144e0 100644
--- a/config/sample-macros.cfg
+++ b/config/sample-macros.cfg
@@ -72,9 +72,7 @@ value: 0
shutdown_value: 0
# Disable at emergency shutdown (no PWM would be available anyway).
cycle_time: 0.001
-# PWM frequency : 0.001 = 1ms will give a base tone of 1kHz
-scale: 1000
-# PWM parameter will be in the range of (0-1000 Hz).
+# Default PWM frequency : 0.001 = 1ms will give a tone of 1kHz
# Although not pitch perfect.
[gcode_macro M300]
@@ -83,7 +81,7 @@ gcode:
{% set S = params.S|default(1000)|int %}
# Use a 10ms duration is P is omitted.
{% set P = params.P|default(100)|int %}
- SET_PIN PIN=BEEPER_pin VALUE={S}
+ SET_PIN PIN=BEEPER_pin VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=BEEPER_pin VALUE=0