You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If it's not intended to be able to read back the value previously set on an output pin, accessing the value property to read it should give an exception.
I think the problem arises because the esp-idf defines the return value of this routine in a surprising way, rather than returning the value currently driven onto the pin:
* @brief GPIO get input level
*
* @warning If the pad is not configured for input (or input and output) the returned value is always 0.
*
* @param hw Peripheral GPIO hardware instance address.
* @param gpio_num GPIO number. If you want to get the logic level of e.g. pin GPIO16, gpio_num should be GPIO_NUM_16 (16);
*
* @return
* - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1
FWIW, input behaves the same on both. It's conceptually an easier case to make that it's an error since the value is controlled by an external source:
>>> pin = DigitalInOut(any_gpio)
>>> pin.direction = Direction.INPUT
>>> pin.value
False
>>> pin.value = True
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: Cannot set value when direction is input.
addendum...
analog outputs don't allow reading the value:
>>> import board
>>> from analogio import AnalogOut
>>> a = AnalogOut(board.A0)
>>> a.value
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: unreadable attribute
Uh oh!
There was an error while loading. Please reload this page.
Is this a bug, or is it explicitly undefined behavior to read the value of an output?
PyPortal (alpha.3):
(the LED is ON)
vs.
Saola (alpha.3):
(the LED is ON)
[edited to explicitly show pin is set up in either case as an output]
The text was updated successfully, but these errors were encountered: