minor fixes
This commit is contained in:
parent
c7ed3f21c3
commit
d5b5f6387d
@ -72,7 +72,8 @@ class Interface_handler:
|
||||
GPIO.setup(self.Pin[pin].value,GPIO.OUT)
|
||||
elif protocol =="PWM":
|
||||
GPIO.setup(self.Pin[pin].value,GPIO.OUT)
|
||||
self.pwms[self.Pin[pin].value] = GPIO.PWM(self.Pin[pin].value,frequency)
|
||||
pwm = GPIO.PWM(self.Pin[pin].value,frequency)
|
||||
self.pwms[self.Pin[pin].value] = pwm
|
||||
else:
|
||||
raise NotImplementedError('the protocol of the device %s is not implemented' % device_name)
|
||||
|
||||
@ -102,11 +103,11 @@ class Interface_handler:
|
||||
for pin in self.xml_reader.get_port(device_name)["pins"]:
|
||||
if protocol in ["DO","DI"]:
|
||||
returnValues.update({
|
||||
pin : GPIO.input(self.Pin[pin].value)
|
||||
pin : str(GPIO.input(self.Pin[pin].value))
|
||||
})
|
||||
if protocol in ["PWM"]:
|
||||
elif protocol in ["PWM"]:
|
||||
returnValues.update({
|
||||
pin : self.pwm_dutycycles[self.Pin[pin].value]
|
||||
pin : str(self.pwm_dutycycles[self.Pin[pin].value])
|
||||
})
|
||||
else: #throw error for protocols without write functionality
|
||||
raise ValueError("you can not read from device %s" % device_name)
|
||||
@ -157,7 +158,7 @@ class Interface_handler:
|
||||
raise ValueError(str("pin %s is not a part of device %s",pin,device_name))
|
||||
dutycycle = int(output[pin])
|
||||
self.pwm_dutycycles[self.Pin[pin].value] = dutycycle
|
||||
if not dutycycle in range(1,100,1):
|
||||
if not dutycycle in range(0,100,1):
|
||||
raise TypeError("value must be a whole number between 0 and 100")
|
||||
self.pwms[self.Pin[pin].value].stop()
|
||||
self.pwms[self.Pin[pin].value].start(dutycycle)
|
||||
|
Loading…
x
Reference in New Issue
Block a user