From c9e1acd72050eacd9115de42434e576bc53c0674 Mon Sep 17 00:00:00 2001 From: Tony DiCola Date: Wed, 8 Jul 2015 19:02:43 -0700 Subject: [PATCH 1/4] Doc update to mention support in Adafruit's NeoPixel library. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3a43e519b..64ab42892 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,7 @@ Libraries that don't rely on low-level access to AVR registers should work well. - [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)). - [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library.git) - [DHT11](https://github.com/adafruit/DHT-sensor-library) - Download latest v1.1.0 library and no changes are necessary. Older versions should initialize DHT as follows: ```DHT dht(DHTPIN, DHTTYPE, 15);``` +- [NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) - Adafruit's NeoPixel libray, now with support for the ESP8266 (use version 1.0.2 or higher from Arduino's library manager). - [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with esp8266. - [PubSubClient](https://github.com/Imroy/pubsubclient) MQTT library by @Imroy. - [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with esp8266. From c77f11906cf3220989019df70cee66ce4ad65f37 Mon Sep 17 00:00:00 2001 From: h4rm0n1c Date: Fri, 10 Jul 2015 21:14:40 +0800 Subject: [PATCH 2/4] digitalWrite cleanup and more compliant with behavior on AVR I rewrote digitalWrite because the existing version was breaking functionality as compared to how it behaves on the AVR,. specifically, I could not use digitalWrite for a library that works fine on the AVR. Instead I had to resort to fiddling with GPOC and GPOS and bit masks, but this rewrite made all of that unnecessary, for whatever reason, it just works better. This version borrows a little from the AVR library in the sense that the same logic is applied to determine whether a pin should be high or low as the AVR version, and yes, it does appear to make a difference. --- cores/esp8266/core_esp8266_wiring_digital.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cores/esp8266/core_esp8266_wiring_digital.c b/cores/esp8266/core_esp8266_wiring_digital.c index 5654e5f12..7ed1dcb26 100644 --- a/cores/esp8266/core_esp8266_wiring_digital.c +++ b/cores/esp8266/core_esp8266_wiring_digital.c @@ -77,13 +77,16 @@ extern void __pinMode(uint8_t pin, uint8_t mode) { } extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) { - val &= 0x01; - if(pin < 16){ - if(val) GPOS = (1 << pin); - else GPOC = (1 << pin); - } else if(pin == 16){ - if(val) GP16O |= 1; - else GP16O &= ~1; + if(val == LOW) { + GP16O &= ~1; + } else { + GP16O |= 1; + } + if(val == LOW) { + GPOC = digitalPinToBitMask(pin); + } else { + GPOS = digitalPinToBitMask(pin); + } } } From d0137574d006c475b6b423db35417ecca39422e0 Mon Sep 17 00:00:00 2001 From: h4rm0n1c Date: Fri, 10 Jul 2015 22:04:58 +0800 Subject: [PATCH 3/4] Update core_esp8266_wiring_digital.c Ugh, I don't know how that happened. --- cores/esp8266/core_esp8266_wiring_digital.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cores/esp8266/core_esp8266_wiring_digital.c b/cores/esp8266/core_esp8266_wiring_digital.c index 7ed1dcb26..2df6952c6 100644 --- a/cores/esp8266/core_esp8266_wiring_digital.c +++ b/cores/esp8266/core_esp8266_wiring_digital.c @@ -77,11 +77,13 @@ extern void __pinMode(uint8_t pin, uint8_t mode) { } extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) { + if (pin == 16) { if(val == LOW) { GP16O &= ~1; } else { GP16O |= 1; } + } else if ((pin >= 0) && (pin <= 15)) { if(val == LOW) { GPOC = digitalPinToBitMask(pin); } else { From 8e699b426ba10fdc694bbc6706970e7b30f6b24c Mon Sep 17 00:00:00 2001 From: h4rm0n1c Date: Fri, 10 Jul 2015 22:24:49 +0800 Subject: [PATCH 4/4] Update core_esp8266_wiring_digital.c --- cores/esp8266/core_esp8266_wiring_digital.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/cores/esp8266/core_esp8266_wiring_digital.c b/cores/esp8266/core_esp8266_wiring_digital.c index 2df6952c6..5be065af5 100644 --- a/cores/esp8266/core_esp8266_wiring_digital.c +++ b/cores/esp8266/core_esp8266_wiring_digital.c @@ -77,18 +77,12 @@ extern void __pinMode(uint8_t pin, uint8_t mode) { } extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) { - if (pin == 16) { - if(val == LOW) { - GP16O &= ~1; - } else { - GP16O |= 1; - } - } else if ((pin >= 0) && (pin <= 15)) { - if(val == LOW) { - GPOC = digitalPinToBitMask(pin); - } else { - GPOS = digitalPinToBitMask(pin); - } + if(pin < 16){ + if(val) GPOS = (1 << pin); + else GPOC = (1 << pin); + } else if(pin == 16){ + if(val) GP16O |= 1; + else GP16O &= ~1; } }