Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Garcia <danielgarcia@gmail.com>2016-06-08 20:48:16 +0300
committerDaniel Garcia <danielgarcia@gmail.com>2016-06-08 20:48:16 +0300
commited91a530681240ea8798e4cd7affa5c10576172c (patch)
treea3b8ff9b630637e6294476ba16338ebab9a64c6b
parent7a6a22387558fdefe5d93dfd9ee9ebf312aca87c (diff)
Enable 4-way parallel output on the ESP8266.
-rw-r--r--FastLED.cpp5
-rw-r--r--platforms/esp/8266/clockless_block_esp8266.h55
-rw-r--r--platforms/esp/8266/clockless_esp8266.h11
-rw-r--r--platforms/esp/8266/fastled_esp8266.h2
-rw-r--r--platforms/esp/8266/fastpin_esp8266.h7
5 files changed, 52 insertions, 28 deletions
diff --git a/FastLED.cpp b/FastLED.cpp
index 0bf2e0f7..d3ad5732 100644
--- a/FastLED.cpp
+++ b/FastLED.cpp
@@ -16,6 +16,9 @@ CLEDController *CLEDController::m_pHead = NULL;
CLEDController *CLEDController::m_pTail = NULL;
static uint32_t lastshow = 0;
+uint32_t _frame_cnt=0;
+uint32_t _retry_cnt=0;
+
// uint32_t CRGB::Squant = ((uint32_t)((__TIME__[4]-'0') * 28))<<16 | ((__TIME__[6]-'0')*50)<<8 | ((__TIME__[7]-'0')*28);
CFastLED::CFastLED() {
@@ -237,7 +240,7 @@ namespace __cxxabiv1
#ifndef ESP8266
extern "C" void __cxa_pure_virtual (void) {}
#endif
-
+
/* guard variables */
/* The ABI requires a 64-bit type. */
diff --git a/platforms/esp/8266/clockless_block_esp8266.h b/platforms/esp/8266/clockless_block_esp8266.h
index 0738323f..47973fdd 100644
--- a/platforms/esp/8266/clockless_block_esp8266.h
+++ b/platforms/esp/8266/clockless_block_esp8266.h
@@ -2,15 +2,20 @@
#define __INC_CLOCKLESS_BLOCK_ESP8266_H
#define FASTLED_HAS_BLOCKLESS 1
-#define PORTA_FIRST_PIN 0
#define PORT_MASK (((1<<LANES)-1) & 0x0000FFFFL)
#define MIN(X,Y) (((X)<(Y)) ? (X):(Y))
-#define USED_LANES (MIN(LANES,16))
-#define LAST_PIN (FIRST_PIN + USED_LANES - 1)
+#define USED_LANES (MIN(LANES,4))
+#define REAL_FIRST_PIN 12
+#define LAST_PIN (12 + USED_LANES - 1)
FASTLED_NAMESPACE_BEGIN
+#ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES
+extern uint32_t _frame_cnt;
+extern uint32_t _retry_cnt;
+#endif
+
template <uint8_t LANES, int FIRST_PIN, int T1, int T2, int T3, EOrder RGB_ORDER = GRB, int XTRA0 = 0, bool FLIP = false, int WAIT_TIME = 5>
class InlineBlockClocklessController : public CPixelLEDController<RGB_ORDER, LANES, PORT_MASK> {
typedef typename FastPin<FIRST_PIN>::port_ptr_t data_ptr_t;
@@ -28,6 +33,9 @@ public:
int cnt=FASTLED_INTERRUPT_RETRY_COUNT;
while(!showRGBInternal(pixels) && cnt--) {
os_intr_unlock();
+ #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES
+ _retry_cnt++;
+ #endif
delayMicroseconds(WAIT_TIME * 10);
os_intr_lock();
}
@@ -41,24 +49,14 @@ public:
}
template<int PIN> static void initPin() {
- if(PIN >= FIRST_PIN && PIN <= LAST_PIN) {
- FastPin<PIN>::setOutput();
+ if(PIN >= REAL_FIRST_PIN && PIN <= LAST_PIN) {
+ _ESPPIN<PIN, 1<<(PIN & 0xFF)>::setOutput();
+ // FastPin<PIN>::setOutput();
}
}
virtual void init() {
- // initPin<0>();
- // initPin<1>();
- // initPin<2>();
- // initPin<3>();
- // initPin<4>();
- // initPin<5>();
- // initPin<6>();
- // initPin<7>();
- // initPin<8>();
- // initPin<9>();
- // initPin<10>();
- // initPin<11>();
+ // Only supportd on pins 12-15
initPin<12>();
initPin<13>();
initPin<14>();
@@ -87,29 +85,31 @@ public:
register uint8_t scale = pixels.template getscale<PX>(pixels);
for(register uint32_t i = 0; i < USED_LANES; i++) {
- while((__clock_cycles() - last_mark) < (T1+T2+T3));
+ while((__clock_cycles() - last_mark) < (T1+T2+T3+6));
last_mark = __clock_cycles();
- *FastPin<FIRST_PIN>::sport() = PORT_MASK << FIRST_PIN;
+ *FastPin<FIRST_PIN>::sport() = PORT_MASK << REAL_FIRST_PIN;
+ uint32_t nword = ((uint32_t)(~b2.bytes[7-i]) & PORT_MASK) << REAL_FIRST_PIN;
while((__clock_cycles() - last_mark) < T1);
- *FastPin<FIRST_PIN>::cport() = ((uint32_t)(~b2.bytes[7-i]) & PORT_MASK) << FIRST_PIN;
+ *FastPin<FIRST_PIN>::cport() = nword;
while((__clock_cycles() - last_mark) < (T1+T2));
- *FastPin<FIRST_PIN>::cport() = PORT_MASK << FIRST_PIN;
+ *FastPin<FIRST_PIN>::cport() = PORT_MASK << REAL_FIRST_PIN;
b.bytes[i] = pixels.template loadAndScale<PX>(pixels,i,d,scale);
}
for(register uint32_t i = USED_LANES; i < 8; i++) {
- while((__clock_cycles() - last_mark) < (T1+T2+T3));
- last_mark = __clock_cycles() + (T1+T2+T3) + ESP_ADJUST;
- *FastPin<FIRST_PIN>::sport() = PORT_MASK << FIRST_PIN;
+ while((__clock_cycles() - last_mark) < (T1+T2+T3+6));
+ last_mark = __clock_cycles();
+ *FastPin<FIRST_PIN>::sport() = PORT_MASK << REAL_FIRST_PIN;
+ uint32_t nword = ((uint32_t)(~b2.bytes[7-i]) & PORT_MASK) << REAL_FIRST_PIN;
while((__clock_cycles() - last_mark) < T1);
- *FastPin<FIRST_PIN>::cport() = ((uint32_t)(~b2.bytes[7-i]) & PORT_MASK) << FIRST_PIN;
+ *FastPin<FIRST_PIN>::cport() = nword;
while((__clock_cycles() - last_mark) < (T1+T2));
- *FastPin<FIRST_PIN>::cport() = PORT_MASK << FIRST_PIN;
+ *FastPin<FIRST_PIN>::cport() = PORT_MASK << REAL_FIRST_PIN;
}
}
@@ -156,6 +156,9 @@ public:
};
os_intr_unlock();
+ #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES
+ _frame_cnt++;
+ #endif
return __clock_cycles() - _start;
}
};
diff --git a/platforms/esp/8266/clockless_esp8266.h b/platforms/esp/8266/clockless_esp8266.h
index 746e9613..20ae6412 100644
--- a/platforms/esp/8266/clockless_esp8266.h
+++ b/platforms/esp/8266/clockless_esp8266.h
@@ -2,6 +2,11 @@
FASTLED_NAMESPACE_BEGIN
+#ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES
+extern uint32_t _frame_cnt;
+extern uint32_t _retry_cnt;
+#endif
+
// Info on reading cycle counter from https://github.com/kbeckmann/nodemcu-firmware/blob/ws2812-dual/app/modules/ws2812.c
__attribute__ ((always_inline)) inline static uint32_t __clock_cycles() {
uint32_t cyc;
@@ -34,6 +39,9 @@ protected:
// mWait.wait();
int cnt = FASTLED_INTERRUPT_RETRY_COUNT;
while((showRGBInternal(pixels)==0) && cnt--) {
+ #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES
+ _retry_cnt++;
+ #endif
os_intr_unlock();
delayMicroseconds(WAIT_TIME);
os_intr_lock();
@@ -99,6 +107,9 @@ protected:
};
os_intr_unlock();
+ #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES
+ _frame_cnt++;
+ #endif
return __clock_cycles() - start;
}
};
diff --git a/platforms/esp/8266/fastled_esp8266.h b/platforms/esp/8266/fastled_esp8266.h
index 2c2e2f12..d209de97 100644
--- a/platforms/esp/8266/fastled_esp8266.h
+++ b/platforms/esp/8266/fastled_esp8266.h
@@ -4,4 +4,4 @@
#include "fastled_delay.h"
#include "fastpin_esp8266.h"
#include "clockless_esp8266.h"
-// #include "clockless_block_esp8266.h"
+#include "clockless_block_esp8266.h"
diff --git a/platforms/esp/8266/fastpin_esp8266.h b/platforms/esp/8266/fastpin_esp8266.h
index 5d4534f8..b8095b85 100644
--- a/platforms/esp/8266/fastpin_esp8266.h
+++ b/platforms/esp/8266/fastpin_esp8266.h
@@ -56,6 +56,8 @@ _DEFPIN_ESP8266(4,4); _DEFPIN_ESP8266(5,5);
_DEFPIN_ESP8266(12,12); _DEFPIN_ESP8266(13,13); _DEFPIN_ESP8266(14,14); _DEFPIN_ESP8266(15,15);
_DEFPIN_ESP8266(16,16);
+
+#define PORTA_FIRST_PIN 12
#elif defined(FASTLED_ESP8266_D1_PIN_ORDER)
#define MAX_PIN 15
_DEFPIN_ESP8266(0,3);
@@ -74,6 +76,9 @@ _DEFPIN_ESP8266(12,12);
_DEFPIN_ESP8266(13,14);
_DEFPIN_ESP8266(14,4);
_DEFPIN_ESP8266(15,5);
+
+#define PORTA_FIRST_PIN 12
+
#else // if defined(FASTLED_ESP8266_NODEMCU_PIN_ORDER)
#define MAX_PIN 10
@@ -82,6 +87,8 @@ _DEFPIN_ESP8266(0,16); _DEFPIN_ESP8266(1,5); _DEFPIN_ESP8266(2,4); _DEFPIN_ESP82
_DEFPIN_ESP8266(4,2); _DEFPIN_ESP8266(5,14); _DEFPIN_ESP8266(6,12); _DEFPIN_ESP8266(7,13);
_DEFPIN_ESP8266(8,15); _DEFPIN_ESP8266(9,3); _DEFPIN_ESP8266(10,1);
+#define PORTA_FIRST_PIN 6
+
// The rest of the pins - these are generally not available
// _DEFPIN_ESP8266(11,6);
// _DEFPIN_ESP8266(12,7); _DEFPIN_ESP8266(13,8); _DEFPIN_ESP8266(14,9); _DEFPIN_ESP8266(15,10);