User Tools

Site Tools


beeper

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
beeper [2024/03/16 17:14] – created tortebeeper [2025/01/21 12:27] (current) torte
Line 1: Line 1:
-===== Sovol KlipperScreen =====+{{page>redirect#this_wiki_has_moved}} 
 +https://torte71.github.io/InsideSovolKlipperScreen/beeper.html 
 +{{page>redirect#section}} 
 +---- 
 + 
 +===== Sovol KlipperScreen (Makerbase MKS KLIPAD50) =====
 ==== Beeper ==== ==== Beeper ====
  
-Based on solution by "Bastian" on https://forum.sovol3d.com +  * Beeper script: 
-  * https://forum.sovol3d.com/t/use-beeper-from-mks-sbc-which-pin/3606/5+    * Based on solution by "Bastian" on https://forum.sovol3d.com 
 +    * https://forum.sovol3d.com/t/use-beeper-from-mks-sbc-which-pin/3606/5 
 + 
 +  * Requires udev rule to change rights for gpio access 
 +    * Based on solution by "MikeDK" on https://forums.raspberrypi.com 
 +    * https://forums.raspberrypi.com/viewtopic.php?t=9667 
 + 
 +  * /etc/udev/rules.d/90-gpio.rules 
 +<code> 
 +SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:dialout /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'" 
 +SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:dialout /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'" 
 +</code> 
 + 
 +  * /home/mks/printer_data/config/printer.cfg: 
 +<code> 
 +[gcode_macro BEEP] 
 +gcode: 
 +  {% set beep_count = params.BC|default("3") %} 
 +  {% set beep_duration = params.BD|default("0.2") %} 
 +  {% set pause_duration = params.PD|default("1") %} 
 +  RUN_SHELL_COMMAND CMD=beep PARAMS='{beep_count} {beep_duration} {pause_duration}' 
 + 
 +[gcode_shell_command beep] 
 +command: bash /home/mks/printer_data/config/macro/macro-beep.sh 
 +timeout: 10 
 +verbose: False 
 +</code> 
 + 
 +  * /home/mks/printer_data/config/macros/macro_beep.sh: 
 +<code> 
 +#!/bin/bash 
 +# usage: beep.sh [BEEPCOUNT] [BEEPDURATION] [PAUSEDURATION] 
 + 
 +# Output raw passed parameters 
 +echo "Raw parameters: $@" 
 + 
 +# Default values 
 +BEEPCOUNT=${1:-3} 
 +BEEPDURATION=${2:-0.1} 
 +PAUSEDURATION=${3:-0.5} 
 + 
 +# Output all passed parameters 
 +echo "Beep count: $BEEPCOUNT, beep duration: $BEEPDURATION, pause duration: $PAUSEDURATION" 
 + 
 + 
 +# Function to play a beep 
 +play_beep() { 
 +    echo 1 > /sys/class/gpio/gpio82/value 
 +    sleep $BEEPDURATION 
 +    echo 0 > /sys/class/gpio/gpio82/value 
 +
 + 
 +# Play the beep for the specified count 
 +for (( i=0; i<BEEPCOUNT; i++ )); do 
 +    play_beep 
 +    sleep $PAUSEDURATION 
 +done 
 +</code>
  
 +----
 +Back to [[start]]
beeper.1710605680.txt.gz · Last modified: 2024/03/16 17:14 by torte