Error "Expecting a Pin" for a Pin derived object #10237
-
I am running this class from Thonny
I am getting the following error when I try to create a PWM object (Pico running micropython 1.19.1):
What am I doing wrong? Thanks in advance for any hint. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You're not doing anything wrong, it's just that these APIs were not designed to handle this case -- It would actually be possible to make this work (although it needs to be fixed in many places across each of the ports), and I'd argue that what you're doing should work. Perhaps raise a feature request? (FWIW, the way to fix this, on Pico at least, is in |
Beta Was this translation helpful? Give feedback.
You're not doing anything wrong, it's just that these APIs were not designed to handle this case --
machine.PWM()
needs to be given something that is exactly aPin
. Internally it checks the equivalent oftype(p) == machine.Pin
, not isinstance(p, machine.Pin)`.It would actually be possible to make this work (although it needs to be fixed in many places across each of the ports), and I'd argue that what you're doing should work. Perhaps raise a feature request?
(FWIW, the way to fix this, on Pico at least, is in
mp_hal_get_pin_obj
to usemp_obj_cast_to_native_base()
rather thanmp_obj_is_type
.)