RFE: RP2 port - machine.Pin.mode() #9403
Unanswered
DeeJay
asked this question in
Hardware & Peripherals
Replies: 1 comment 1 reply
-
In your project are you able to store in a variable somewhere the current mode of a pin, and then query that variable when you need to know the mode? I know that's not the best solution, but I'm wondering if it's possible to do it that way? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
(I know this is not the place to raise an Enhancement Request. This is simply to explore whether such a request via the GH repo would have any chance of success. )
I have a potential monitoring application for an RPi Pico board that needs to determine the mode in which a GPIO Pin is running.
machine.Pin.mode() is not implemented in the RP2 port.
I can use a workaround by parsing the output from machine.Pin(pin_id). But a simple call to a Pin.mode() method would be cleaner.
My practical knowledge of C and its integration with MicroPython is very limited.
I think that any changes would be needed only to ports/rp2/machine_pin,c
The API would be similar to that for pin.value() at line 457
The machine_pin_print() function seems to contain model code for determining the current mode ready for printing. Lines 213-250
There is a table of instance methods at line 586 that would need updating.
I could try to work up a PR based on these ideas. But it would probably be quicker, more efficient, and less painful (time-consuming) if someone already knowledgeable did it?
Any thoughts on whether this is worth pursuing and whether I should raise it as a formal GH Issue?
Thanks for listening - DJ
Beta Was this translation helpful? Give feedback.
All reactions