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
Hardware: ESP8266 - all boards
Core Version: 2.1.0
Description
The macro digitalPinHasPWM(p) from variants/.../pins_arduino.h has a similar problem as A0 from issue #1766.
digitalPinHasPWM returns true for pins 1 to 17 with an Adafruit Huzzah board. But it should return true for 0 to 16 (or even better 0 to 5 and 12 to 16, because you should not do PWM on your flash IOs). The reason is that the macro is intended to return a boolean (0/1) result but current macro returns NOT_A_PIN for pin 17 but that resolves to -1 and that is true but should be false and it otherwise returns the pin number and for pin 0 that is false but should be true.
With the macro digitalPinToInterrupt the case is a little bit different. It should return the number of the external interrupt for a specific pin to be used with attachInterrupt(). With AVR architecture this results in 0 for pin 2 and 1 for pin 3 and otherwise NOT_AN_INTERRUPT (-1) for all other pins being an offset for the interrupt vector address of INT0. For the ESP8266 the current solution seems to return the right values but the macro should be defined using the constant NOT_AN_INTERRUPT instead of NOT_A_PIN.
@igrr
Tested by replacing the variants folder of the 2.1.0 release with the version of commit 0f719e8 using an Adafruit Huzzah board. The result for digitalPinHasPWM is now as expected: pins 0,1,2,3,4,5,12,13,14,15,16
Basic Infos
Hardware
Hardware: ESP8266 - all boards
Core Version: 2.1.0
Description
The macro
digitalPinHasPWM(p)
from variants/.../pins_arduino.h has a similar problem as A0 from issue #1766.digitalPinHasPWM
returns true for pins 1 to 17 with an Adafruit Huzzah board. But it should return true for 0 to 16 (or even better 0 to 5 and 12 to 16, because you should not do PWM on your flash IOs). The reason is that the macro is intended to return a boolean (0/1) result but current macro returnsNOT_A_PIN
for pin 17 but that resolves to -1 and that is true but should be false and it otherwise returns the pin number and for pin 0 that is false but should be true.With the macro
digitalPinToInterrupt
the case is a little bit different. It should return the number of the external interrupt for a specific pin to be used withattachInterrupt()
. With AVR architecture this results in 0 for pin 2 and 1 for pin 3 and otherwiseNOT_AN_INTERRUPT
(-1) for all other pins being an offset for the interrupt vector address of INT0. For the ESP8266 the current solution seems to return the right values but the macro should be defined using the constantNOT_AN_INTERRUPT
instead ofNOT_A_PIN
.Possible Solution
in all variants of pins_arduino.h
This issue blocks firmata/arduino#278.
The text was updated successfully, but these errors were encountered: