From 71a3decedf80aa8881e84b7127b298262c38f30c Mon Sep 17 00:00:00 2001 From: HerrNamenlos123 Date: Fri, 15 Jan 2021 22:55:52 +0100 Subject: [PATCH] Added destructor to disable buzzer at exit --- compLIB/Buzzer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compLIB/Buzzer.py b/compLIB/Buzzer.py index 2021301..67869dd 100644 --- a/compLIB/Buzzer.py +++ b/compLIB/Buzzer.py @@ -1,4 +1,5 @@ import RPi.GPIO as GPIO +import atexit GPIO.setwarnings(False) Buzzer_Pin = 17 @@ -15,4 +16,9 @@ class Buzzer: :param on: True if on, False if off :return: None """ - GPIO.output(Buzzer_Pin, on) \ No newline at end of file + GPIO.output(Buzzer_Pin, on) + +def exit(): + Buzzer.set(0) + +atexit.register(exit) \ No newline at end of file