ensure that there are no duplicate pwms set up for a single GPIO

This commit is contained in:
p.loedige 2021-01-06 18:22:53 +01:00
parent e3422e8073
commit 338cbf567a
2 changed files with 4 additions and 1 deletions

2
app.py
View File

@ -44,7 +44,7 @@ def xml_transfer():
shutil.move(str(dir + '/XML/config.xml'),str(dir + '/XML/config_old.xml'))
shutil.move('/tmp/aped_device/config.xml',str(dir + '/XML/config.xml'))
xml_reader.set_root(str(dir + '/XML/config.xml'))
interface_handler = Interface_handler(xml_reader)
interface_handler.init_gpio()
else:
SyntaxError('the config.xml has invalid content')
return {'error': ''}

View File

@ -57,6 +57,9 @@ class Interface_handler:
def init_gpio(self):
"""initialises the GPIO pins
"""
for pwm in self.pwms:
if pwm != None:
pwm.stop()
GPIO.setmode(GPIO.BOARD)
for device_name in self.xml_reader.get_device_names():
port_info = self.xml_reader.get_port(device_name)