fix crash on init caused by the previous change (2/2)
This commit is contained in:
parent
187cb354ca
commit
5e10ebc2ac
1 changed files with 6 additions and 2 deletions
6
fand.py
6
fand.py
|
@ -49,8 +49,12 @@ class PWM:
|
||||||
# acquire a duty cycle file descriptor
|
# acquire a duty cycle file descriptor
|
||||||
self.f_dc = open(self.ch_base + "duty_cycle", "w")
|
self.f_dc = open(self.ch_base + "duty_cycle", "w")
|
||||||
|
|
||||||
# set 0 duty cycle so period can be freely set
|
# Set 0 duty cycle so period can be freely set even if the channel was used before.
|
||||||
|
# This may fail: ignore.
|
||||||
|
try:
|
||||||
self.set_duty_cycle(0)
|
self.set_duty_cycle(0)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
# set period & polarity
|
# set period & polarity
|
||||||
with open(self.ch_base + "period", "w") as f:
|
with open(self.ch_base + "period", "w") as f:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue