@@ -665,22 +665,26 @@ writePort(port, value, bitmask): Write an 8 bit port.
665665#define PIN_TO_PWM (p ) PIN_TO_DIGITAL(p)
666666#define PIN_TO_SERVO (p ) ((p) - 2)
667667
668- // ESP8266 generic
668+ // ESP8266
669+ // note: boot mode GPIOs 0, 2 and 15 can be used as outputs, GPIOs 6-11 are in use for flash IO
669670#elif defined(ESP8266 )
670- #define TOTAL_ANALOG_PINS 0
671- #define TOTAL_PINS 17
672- #define VERSION_BLINK_PIN 4
673- // #define IS_PIN_DIGITAL(p) ((p) == 0 || (p) == 1 || (p) == 2 || (p) == 3 || (p) == 4 || (p) == 5 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 || (p) == 16) //for wifi dont protect serial pins because these things only have 2 pins otherwise
674- #define IS_PIN_DIGITAL (p ) ((p) == 0 || (p) == 2 || (p) == 4 || (p) == 5 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 || (p) == 16)
675- #define IS_PIN_ANALOG (p ) (false)
676- #define IS_PIN_PWM (p ) (false)
677- #define IS_PIN_SERVO (p ) ((p) >= 0 && (p) < MAX_SERVOS)
678- #define IS_PIN_I2C (p ) (false)
679- #define IS_PIN_SPI (p ) (false)
671+ #define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS
672+ #define TOTAL_PINS A0 + NUM_ANALOG_INPUTS
673+ #define PIN_SERIAL_RX 3
674+ #define PIN_SERIAL_TX 1
675+ #define IS_PIN_DIGITAL (p ) (((p) >= 0 && (p) <= 5) || ((p) >= 12 && (p) < A0))
676+ #define IS_PIN_ANALOG (p ) ((p) >= A0 && (p) < A0 + NUM_ANALOG_INPUTS)
677+ #define IS_PIN_PWM (p ) digitalPinHasPWM(p)
678+ #define IS_PIN_SERVO (p ) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS)
679+ #define IS_PIN_I2C (p ) ((p) == SDA || (p) == SCL)
680+ #define IS_PIN_SPI (p ) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
681+ #define IS_PIN_INTERRUPT (p ) (digitalPinToInterrupt(p) > NOT_AN_INTERRUPT)
682+ #define IS_PIN_SERIAL (p ) ((p) == PIN_SERIAL_RX || (p) == PIN_SERIAL_TX)
680683#define PIN_TO_DIGITAL (p ) (p)
681- #define PIN_TO_ANALOG (p ) ((p) - 17 )
684+ #define PIN_TO_ANALOG (p ) ((p) - A0 )
682685#define PIN_TO_PWM (p ) PIN_TO_DIGITAL(p)
683- #define PIN_TO_SERVO (p ) p
686+ #define PIN_TO_SERVO (p ) (p)
687+ #define DEFAULT_PWM_RESOLUTION 10
684688
685689
686690// anything else
@@ -697,6 +701,9 @@ writePort(port, value, bitmask): Write an 8 bit port.
697701#define IS_PIN_SERIAL (p ) 0
698702#endif
699703
704+ #ifndef DEFAULT_PWM_RESOLUTION
705+ #define DEFAULT_PWM_RESOLUTION 8
706+ #endif
700707
701708/*==============================================================================
702709 * readPort() - Read an 8 bit port
0 commit comments