From eb85657fb1b6b90de49e67ac46c9e8ae259c3892 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Sat, 5 Nov 2022 13:07:00 +1100 Subject: [PATCH] drivers/generic/st77xx: Support use on platforms without machine.PWM. --- driver/generic/st77xx.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/driver/generic/st77xx.py b/driver/generic/st77xx.py index d500e7064..3c36f7ffa 100644 --- a/driver/generic/st77xx.py +++ b/driver/generic/st77xx.py @@ -196,9 +196,10 @@ def __init__(self, *, cs, dc, spi, res, suppRes, bl=None, model=None, suppModel= self.cs,self.dc,self.rst=[(machine.Pin(p,machine.Pin.OUT) if isinstance(p,int) else p) for p in (cs,dc,rst)] self.bl=bl - if isinstance(self.bl,int): self.bl=machine.PWM(machine.Pin(self.bl,machine.Pin.OUT)) - elif isinstance(self.bl,machine.Pin): self.bl=machine.PWM(self.bl) - assert isinstance(self.bl,(machine.PWM,type(None))) + if hasattr(machine, "PWM"): + if isinstance(self.bl,int): self.bl=machine.PWM(machine.Pin(self.bl,machine.Pin.OUT)) + elif isinstance(self.bl,machine.Pin): self.bl=machine.PWM(self.bl) + assert isinstance(self.bl,(machine.PWM,type(None))) self.set_backlight(10) # set some backlight self.rot=rot