Therefore i need to turn on and off a pwm pulsed IR LED.
What i did so far:
Code: Select all
class IrLed(object):
def __init__(self, pinId, timerId, timerChannel, freq):
self._timer = pyb.Timer(timerId, freq=freq * 2)
self._timerChannel = timerChannel
self._pinId = pinId
def On(self):
self._timer.channel(self._timerChannel, pyb.Timer.OC_TOGGLE, pin=self._pinId)
def Off(self):
pyb.Pin(self._pinId, mode=pyb.Pin.OUT_OD, pull=pyb.Pin.PULL_DOWN)
irLed = IrLed(pyb.Pin.board.Y1, 8, 1, 56000)
Is there a way, to create the timer once in the init method and then switch the timer on and off?