Code: Select all
>>> class PinNew(machine.Pin):
... def __init__(self, *args,**kwargs):
... args=list(args)
... if type(args[0])==str:
... args[0]=pins[args[0]]
... print(args,kwargs)
... super().__init__(*args,**kwargs)
...
...
...
>>> PinNew(0)
(0,) {}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in __init__
TypeError: function takes 1 positional arguments but 2 were given
>>> PinNew("D0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert str to int
Wrapping around the Pin class works fine on the other hand:
Code: Select all
def Pin(*args,**kwargs):
... args=list(args)
... if type(args[0])==str:
... args[0]=pins[args[0]]
... return machine.Pin(*args,**kwargs)
...
...
>>> Pin(0)
Pin(0)
>>> Pin("D0")
Pin(16)
>>> Pin("D0",mode=machine.Pin.OUT)
Pin(16)
Or is it just the Pin class that is a bit weird?
I don't have the problem on the loboris fork of esp32.