diff --git a/l293d/gpio/micropython.py b/l293d/gpio/micropython.py index 7af9a81..c7e958c 100644 --- a/l293d/gpio/micropython.py +++ b/l293d/gpio/micropython.py @@ -1,4 +1,6 @@ +import machine + from l293d.driver import v_print @@ -13,9 +15,9 @@ class GPIO(object): BOARD = "BOARD" BCM = "BCM" - class PWM(object): - def __init__(self, pin_num, freq): - self.pin = GPIO._GPIO__pins[pin_num] + class PwmObject(object): + def __init__(self, pin, freq): + self.pin = pin self.pwm = machine.PWM(self.pin) self.pwm.freq(freq) @@ -23,7 +25,11 @@ def start(self, duty): self.pwm.duty(duty) def stop(self): - self.pwn.deinit() + self.pwm.deinit() + + @classmethod + def PWM(cls, pin, freq): + return cls.PwmObject(cls.__pins[pin], freq) @classmethod def setwarnings(cls, warn):