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
The usecase for this is that you can pass analogRead(0) and then read the first ADC/analog input pin A0. This was the original analogRead() API, passing pin numbers instead of ADC channel numbers was later added, and even though passing pin numbers is a better API, there is a lot of code out there that uses channel numbers, so both must be supported.
The reason it is present in analogRead and not analogWrite is because the latter has nothing to do with the ADC (and it is not even actually analog, just PWM).
I agree this situation sucks, but I think pin maps just have to deal with it / work around it, unfortunately...
Yes we can particularly well guess the reasons that lead to that.
Alas I was afraid the reason was about lots of existing code doing both.
I remove my PR 😭
This code is found in
uint32_t analogRead(uint32_t pin)
:The pin passed as an argument is deliberately changed if it doesn't fulfill a certain requirement.
This seems inappropriate:
pin
always refer to an index ing_APinDescription
and never something else,analogRead
but not in inanalogWrite
PIO_DIGITAL
toPIO_ANALOG
ing_APinDescription[2]
analogRead(2)
it doesanalogRead(17)
Imo it's really worth removing these 3 lines.
The text was updated successfully, but these errors were encountered: