Skip to content

Commit 3934502

Browse files
andrewleechpi-anl
andauthored
drivers/generic/st77xx: Support use on platforms without machine.PWM. (#358)
Co-authored-by: Andrew Leech <[email protected]>
1 parent 73ec992 commit 3934502

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

driver/generic/st77xx.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ def __init__(self, *, cs, dc, spi, res, suppRes, bl=None, model=None, suppModel=
196196

197197
self.cs,self.dc,self.rst=[(machine.Pin(p,machine.Pin.OUT) if isinstance(p,int) else p) for p in (cs,dc,rst)]
198198
self.bl=bl
199-
if isinstance(self.bl,int): self.bl=machine.PWM(machine.Pin(self.bl,machine.Pin.OUT))
200-
elif isinstance(self.bl,machine.Pin): self.bl=machine.PWM(self.bl)
201-
assert isinstance(self.bl,(machine.PWM,type(None)))
199+
if hasattr(machine, "PWM"):
200+
if isinstance(self.bl,int): self.bl=machine.PWM(machine.Pin(self.bl,machine.Pin.OUT))
201+
elif isinstance(self.bl,machine.Pin): self.bl=machine.PWM(self.bl)
202+
assert isinstance(self.bl,(machine.PWM,type(None)))
202203
self.set_backlight(10) # set some backlight
203204

204205
self.rot=rot

0 commit comments

Comments
 (0)