QUERY · ISSUE
Pin toggle function does not exist in ESP32.
enhancementport-esp32
Port, board and/or hardware
esp32
MicroPython version
MicroPython v1.24.1 on 2024-11-29; Generic ESP32 module with ESP32
Reproduction
from machine import Pin
p=Pin(2, Pin.OUT)
p.toggle()
Expected behaviour
Toggling the pin :D
Observed behaviour
the toggle function is not implemented.
So I do:
p.value(not p.value())
But from the docs I thought it was implemented.
It would be nice to have it, for code clarity but also for speed.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
CANDIDATE · PULL REQUEST
Adding Pin.toggle() to docs
docs
Pin.toggle() works with the pyboard and the Raspberry Pi Pico (RP2040), so I am adding the method to the documentation.
Apparently it is not working with the ESP32 port #8789, so feel free to move it under this section:
The following methods are not part of the core Pin API and only implemented on certain ports.