Skip to content

Commit

Permalink
drivers/generic/st77xx: Support use on platforms without machine.PWM.
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-anl committed Oct 17, 2024
1 parent 6dff116 commit eb85657
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions driver/generic/st77xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb85657

Please sign in to comment.