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:
-rw-r--r--PORTING.md2
-rw-r--r--README.md4
-rw-r--r--library.json1
-rw-r--r--src/lib8tion/math8.h89
-rw-r--r--src/platforms/esp/32/clockless_rmt_esp32.cpp6
-rw-r--r--src/platforms/esp/32/led_sysdefs_esp32.h11
6 files changed, 79 insertions, 34 deletions
diff --git a/PORTING.md b/PORTING.md
index beb4e6c6..ef361016 100644
--- a/PORTING.md
+++ b/PORTING.md
@@ -41,7 +41,7 @@ The ```HAS_HARDWARE_PIN_SUPPORT``` define tells the rest of the FastLED library
## Porting fastpin.h
-The heart of the FastLED library is the fast pin accesss. This is a templated class that provides 1-2 cycle pin access, bypassing digital write and other such things. As such, this will usually be the first bit of the library that you will want to port when moving to a new platform. Once you have FastPIN up and running then you can do some basic work like testing toggles or running bit-bang'd SPI output.
+The heart of the FastLED library is the fast pin access. This is a templated class that provides 1-2 cycle pin access, bypassing digital write and other such things. As such, this will usually be the first bit of the library that you will want to port when moving to a new platform. Once you have FastPIN up and running then you can do some basic work like testing toggles or running bit-bang'd SPI output.
There's two low level FastPin classes. There's the base FastPIN template class, and then there is FastPinBB which is for bit-banded access on those MCUs that support bitbanding. Note that the bitband class is optional and primarily useful in the implementation of other functionality internal to the platform. This file is also where you would do the pin to port/bit mapping defines.
diff --git a/README.md b/README.md
index 58e7e500..52067b20 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ HL1606, and "595"-style shift registers are no longer supported by the library.
## Supported platforms
-Right now the library is supported on a variety of arduino compatable platforms. If it's ARM or AVR and uses the arduino software (or a modified version of it to build) then it is likely supported. Note that we have a long list of upcoming platforms to support, so if you don't see what you're looking for here, ask, it may be on the roadmap (or may already be supported). N.B. at the moment we are only supporting the stock compilers that ship with the arduino software. Support for upgraded compilers, as well as using AVR studio and skipping the arduino entirely, should be coming in a near future release.
+Right now the library is supported on a variety of arduino compatible platforms. If it's ARM or AVR and uses the arduino software (or a modified version of it to build) then it is likely supported. Note that we have a long list of upcoming platforms to support, so if you don't see what you're looking for here, ask, it may be on the roadmap (or may already be supported). N.B. at the moment we are only supporting the stock compilers that ship with the arduino software. Support for upgraded compilers, as well as using AVR studio and skipping the arduino entirely, should be coming in a near future release.
* Arduino & compatibles - straight up arduino devices, uno, duo, leonardo, mega, nano, etc...
* Arduino Yún
@@ -82,7 +82,7 @@ What types of platforms are we thinking about supporting in the future? Here's
## What about that name?
-Wait, what happend to FastSPI_LED and FastSPI_LED2? The library was initially named FastSPI_LED because it was focused on very fast and efficient SPI access. However, since then, the library has expanded to support a number of LED chipsets that don't use SPI, as well as a number of math and utility functions for LED processing across the board. We decided that the name FastLED more accurately represents the totality of what the library provides, everything fast, for LEDs.
+Wait, what happened to FastSPI_LED and FastSPI_LED2? The library was initially named FastSPI_LED because it was focused on very fast and efficient SPI access. However, since then, the library has expanded to support a number of LED chipsets that don't use SPI, as well as a number of math and utility functions for LED processing across the board. We decided that the name FastLED more accurately represents the totality of what the library provides, everything fast, for LEDs.
## For more information
diff --git a/library.json b/library.json
index 9e330204..fdcde146 100644
--- a/library.json
+++ b/library.json
@@ -38,6 +38,7 @@
"homepage": "http://fastled.io",
"frameworks": "arduino",
"platforms": "atmelavr, atmelsam, freescalekinetis, nordicnrf51, nxplpc, ststm32, teensy, espressif8266, espressif32, nordicnrf52",
+ "headers": "FastLED.h",
"export": {
"exclude": [
"docs",
diff --git a/src/lib8tion/math8.h b/src/lib8tion/math8.h
index a83b1ad2..f95697bd 100644
--- a/src/lib8tion/math8.h
+++ b/src/lib8tion/math8.h
@@ -469,32 +469,77 @@ LIB8STATIC uint8_t sqrt16(uint16_t x)
#if (FASTLED_BLEND_FIXED == 1)
LIB8STATIC uint8_t blend8( uint8_t a, uint8_t b, uint8_t amountOfB)
{
-#if BLEND8_C == 1
+
+ // The BLEND_FIXED formula is
+ //
+ // result = ( A*(amountOfA) + B*(amountOfB) )/ 256
+ //
+ // …where amountOfA = 255-amountOfB.
+ //
+ // This formula will never return 255, which is why the BLEND_FIXED + SCALE8_FIXED version is
+ //
+ // result = ( A*(amountOfA) + A + B*(amountOfB) + B ) / 256
+ //
+ // We can rearrange this formula for some great optimisations.
+ //
+ // result = ( A*(amountOfA) + A + B*(amountOfB) + B ) / 256
+ // = ( A*(255-amountOfB) + A + B*(amountOfB) + B ) / 256
+ // = ( A*(256-amountOfB) + B*(amountOfB) + B ) / 256
+ // = ( A*256 + B + B*(amountOfB) - A*(amountOfB) ) / 256 // this is the version used in SCALE8_FIXED AVR below
+ // = ( A*256 + B + (B-A)*(amountOfB) ) / 256 // this is the version used in SCALE8_FIXED C below
+
uint16_t partial;
uint8_t result;
-
+
+#if BLEND8_C == 1
+
+# if (FASTLED_SCALE8_FIXED == 1)
+ partial = (a << 8) | b; // A*256 + B
+
+ // on many platforms this compiles to a single multiply of (B-A) * amountOfB
+ partial += (b * amountOfB);
+ partial -= (a * amountOfB);
+
+# else
uint8_t amountOfA = 255 - amountOfB;
-
+
+ // on the other hand, this compiles to two multiplies, and gives the "wrong" answer :]
partial = (a * amountOfA);
-#if (FASTLED_SCALE8_FIXED == 1)
- partial += a;
- //partial = add8to16( a, partial);
-#endif
-
partial += (b * amountOfB);
-#if (FASTLED_SCALE8_FIXED == 1)
- partial += b;
- //partial = add8to16( b, partial);
-#endif
+# endif
result = partial >> 8;
return result;
#elif BLEND8_AVRASM == 1
- uint16_t partial;
- uint8_t result;
+# if (FASTLED_SCALE8_FIXED == 1)
+
+ // 1 or 2 cycles depending on how the compiler optimises
+ partial = (a << 8) | b;
+
+ // 7 cycles
+ asm volatile (
+ " mul %[a], %[amountOfB] \n\t"
+ " sub %A[partial], r0 \n\t"
+ " sbc %B[partial], r1 \n\t"
+ " mul %[b], %[amountOfB] \n\t"
+ " add %A[partial], r0 \n\t"
+ " adc %B[partial], r1 \n\t"
+ " clr __zero_reg__ \n\t"
+ : [partial] "+r" (partial)
+ : [amountOfB] "r" (amountOfB),
+ [a] "r" (a),
+ [b] "r" (b)
+ : "r0", "r1"
+ );
+
+# else
+
+ // non-SCALE8-fixed version
+
+ // 7 cycles
asm volatile (
/* partial = b * amountOfB */
" mul %[b], %[amountOfB] \n\t"
@@ -510,30 +555,22 @@ LIB8STATIC uint8_t blend8( uint8_t a, uint8_t b, uint8_t amountOfB)
" adc %B[partial], r1 \n\t"
" clr __zero_reg__ \n\t"
-
-#if (FASTLED_SCALE8_FIXED == 1)
- /* partial += a */
- " add %A[partial], %[a] \n\t"
- " adc %B[partial], __zero_reg__ \n\t"
-
- // partial += b
- " add %A[partial], %[b] \n\t"
- " adc %B[partial], __zero_reg__ \n\t"
-#endif
-
+
: [partial] "=r" (partial),
[amountOfB] "+a" (amountOfB)
: [a] "a" (a),
[b] "a" (b)
: "r0", "r1"
);
+
+# endif
result = partial >> 8;
return result;
#else
-#error "No implementation for blend8 available."
+# error "No implementation for blend8 available."
#endif
}
diff --git a/src/platforms/esp/32/clockless_rmt_esp32.cpp b/src/platforms/esp/32/clockless_rmt_esp32.cpp
index 9c89fcb4..0f8ad9b3 100644
--- a/src/platforms/esp/32/clockless_rmt_esp32.cpp
+++ b/src/platforms/esp/32/clockless_rmt_esp32.cpp
@@ -463,9 +463,9 @@ void IRAM_ATTR ESP32RMTController::fillNext(bool check_time)
{
uint32_t now = __clock_cycles();
if (check_time) {
- if (mLastFill != 0 and now > mLastFill) {
- uint32_t delta = (now - mLastFill);
- if (delta > mMaxCyclesPerFill) {
+ if (mLastFill != 0) {
+ int32_t delta = (now - mLastFill);
+ if (delta > (int32_t)mMaxCyclesPerFill) {
// Serial.print(delta);
// Serial.print(" BAIL ");
// Serial.println(mCur);
diff --git a/src/platforms/esp/32/led_sysdefs_esp32.h b/src/platforms/esp/32/led_sysdefs_esp32.h
index f93f528b..cf1aa4dc 100644
--- a/src/platforms/esp/32/led_sysdefs_esp32.h
+++ b/src/platforms/esp/32/led_sysdefs_esp32.h
@@ -8,10 +8,17 @@
#if CONFIG_IDF_TARGET_ARCH_RISCV
#define FASTLED_RISCV
+#else
+#define FASTLED_XTENSA
#endif
-#if CONFIG_IDF_TARGET_ARCH_XTENSA || CONFIG_XTENSA_IMPL
-#define FASTLED_XTENSA
+// Handling for older versions of ESP32 Arduino core
+#if !defined(ESP_IDF_VERSION)
+// Older versions of ESP_IDF only supported ESP32
+#define CONFIG_IDF_TARGET_ESP32 1
+// Define missing version macros. Hard code older version 3.0 since actual version is unknown
+#define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
+#define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(3, 0, 0)
#endif
// Use system millis timer