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--README.md2
-rw-r--r--examples/NoisePlusPalette/NoisePlusPalette.ino2
-rw-r--r--src/fastspi.h7
-rw-r--r--src/noise.h6
-rw-r--r--src/pixeltypes.h10
-rw-r--r--src/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h2
-rw-r--r--src/platforms/esp/32/clockless_i2s_esp32.h2
-rwxr-xr-x[-rw-r--r--]src/platforms/esp/32/fastled_esp32.h4
-rw-r--r--src/platforms/esp/32/fastspi_esp32.h168
9 files changed, 196 insertions, 7 deletions
diff --git a/README.md b/README.md
index 831baea1..58e7e500 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ How quickly can you get up and running with the library? Here's a simple blink
## Supported LED chipsets
-Here's a list of all the LED chipsets are supported. More details on the led chipsets are included *TODO: Link to wiki page*
+Here's a list of all the LED chipsets are supported. More details on the led chipsets are included [on our wiki page](https://github.com/FastLED/FastLED/wiki/Chipset-reference)
* Adafruit's DotStars - AKA the APA102
* Adafruit's Neopixel - aka the WS2812B (also WS2811/WS2812/WS2813, also supported in lo-speed mode) - a 3 wire addressable led chipset
diff --git a/examples/NoisePlusPalette/NoisePlusPalette.ino b/examples/NoisePlusPalette/NoisePlusPalette.ino
index 4670cc38..aa360b7c 100644
--- a/examples/NoisePlusPalette/NoisePlusPalette.ino
+++ b/examples/NoisePlusPalette/NoisePlusPalette.ino
@@ -15,7 +15,7 @@ const bool kMatrixSerpentineLayout = true;
// This example combines two features of FastLED to produce a remarkable range of
// effects from a relatively small amount of code. This example combines FastLED's
-// color palette lookup functions with FastLED's Perlin/simplex noise generator, and
+// color palette lookup functions with FastLED's Perlin noise generator, and
// the combination is extremely powerful.
//
// You might want to look at the "ColorPalette" and "Noise" examples separately
diff --git a/src/fastspi.h b/src/fastspi.h
index aeb2ad01..ae084f84 100644
--- a/src/fastspi.h
+++ b/src/fastspi.h
@@ -13,7 +13,7 @@ FASTLED_NAMESPACE_BEGIN
#if defined(FASTLED_TEENSY3) && (F_CPU > 48000000)
#define DATA_RATE_MHZ(X) (((48000000L / 1000000L) / X))
#define DATA_RATE_KHZ(X) (((48000000L / 1000L) / X))
-#elif defined(FASTLED_TEENSY4) // && (ARM_HARDWARE_SPI)
+#elif defined(FASTLED_TEENSY4) || (defined(ESP32) && defined(FASTLED_ALL_PINS_HARDWARE_SPI))
// just use clocks
#define DATA_RATE_MHZ(X) (1000000 * (X))
#define DATA_RATE_KHZ(X) (1000 * (X))
@@ -54,6 +54,11 @@ template<uint8_t _DATA_PIN, uint8_t _CLOCK_PIN, uint32_t _SPI_CLOCK_DIVIDER>
class SPIOutput : public APOLLO3HardwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {};
#endif
+#if defined(ESP32) && defined(FASTLED_ALL_PINS_HARDWARE_SPI)
+template<uint8_t _DATA_PIN, uint8_t _CLOCK_PIN, uint32_t _SPI_CLOCK_DIVIDER>
+class SPIOutput : public ESP32SPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {};
+#endif
+
#if defined(SPI_DATA) && defined(SPI_CLOCK)
#if defined(FASTLED_TEENSY3) && defined(ARM_HARDWARE_SPI)
diff --git a/src/noise.h b/src/noise.h
index 7355e23e..8a0db3f4 100644
--- a/src/noise.h
+++ b/src/noise.h
@@ -9,11 +9,11 @@ FASTLED_NAMESPACE_BEGIN
/// Noise functions provided by the library.
///@defgroup Noise Noise functions
-///Simplex noise function definitions
+///Perlin noise function definitions
///@{
/// @name scaled 16 bit noise functions
///@{
-/// 16 bit, fixed point implementation of perlin's Simplex Noise. Coordinates are
+/// 16 bit, fixed point implementation of Perlin's noise. Coordinates are
/// 16.16 fixed point values, 32 bit integers with integral coordinates in the high 16
/// bits and fractional in the low 16 bits, and the function takes 1d, 2d, and 3d coordinate
/// values. These functions are scaled to return 0-65535
@@ -34,7 +34,7 @@ extern int16_t inoise16_raw(uint32_t x);
/// @name 8 bit scaled noise functions
///@{
-/// 8 bit, fixed point implementation of perlin's Simplex Noise. Coordinates are
+/// 8 bit, fixed point implementation of Perlin's noise. Coordinates are
/// 8.8 fixed point values, 16 bit integers with integral coordinates in the high 8
/// bits and fractional in the low 8 bits, and the function takes 1d, 2d, and 3d coordinate
/// values. These functions are scaled to return 0-255
diff --git a/src/pixeltypes.h b/src/pixeltypes.h
index 6e91723d..f28c2c67 100644
--- a/src/pixeltypes.h
+++ b/src/pixeltypes.h
@@ -353,6 +353,14 @@ struct CRGB {
}
/// return a CRGB object that is a scaled down version of this object
+ inline CRGB scale8 (uint8_t scaledown ) const
+ {
+ CRGB out = *this;
+ nscale8x3( out.r, out.g, out.b, scaledown);
+ return out;
+ }
+
+ /// return a CRGB object that is a scaled down version of this object
inline CRGB scale8 (const CRGB & scaledown ) const
{
CRGB out;
@@ -412,7 +420,7 @@ struct CRGB {
}
/// invert each channel
- inline CRGB operator- ()
+ inline CRGB operator- () const
{
CRGB retval;
retval.r = 255 - r;
diff --git a/src/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h b/src/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h
index a7bcddf0..efc875bc 100644
--- a/src/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h
+++ b/src/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h
@@ -17,6 +17,7 @@ class FlexibleInlineBlockClocklessController : public CPixelLEDController<RGB_OR
uint32_t m_nWriteMask;
uint8_t m_nOutBlocks;
uint32_t m_offsets[3];
+ uint32_t MS_COUNTER;
CMinWait<WAIT_TIME> mWait;
public:
@@ -40,6 +41,7 @@ public:
m_nLowBit = 33;
m_nHighBit = 0;
m_nWriteMask = 0;
+ MS_COUNTER = 0;
// setup the bits and data tracking for parallel output
switch(FIRST_PIN) {
diff --git a/src/platforms/esp/32/clockless_i2s_esp32.h b/src/platforms/esp/32/clockless_i2s_esp32.h
index 5c7979cf..6306ccd2 100644
--- a/src/platforms/esp/32/clockless_i2s_esp32.h
+++ b/src/platforms/esp/32/clockless_i2s_esp32.h
@@ -86,7 +86,9 @@
#pragma once
+#ifndef FASTLED_INTERNAL
#pragma message "NOTE: ESP32 support using I2S parallel driver. All strips must use the same chipset"
+#endif
FASTLED_NAMESPACE_BEGIN
diff --git a/src/platforms/esp/32/fastled_esp32.h b/src/platforms/esp/32/fastled_esp32.h
index edf27e7d..6e9a1c59 100644..100755
--- a/src/platforms/esp/32/fastled_esp32.h
+++ b/src/platforms/esp/32/fastled_esp32.h
@@ -2,6 +2,10 @@
#include "fastpin_esp32.h"
+#ifdef FASTLED_ALL_PINS_HARDWARE_SPI
+#include "fastspi_esp32.h"
+#endif
+
#ifdef FASTLED_ESP32_I2S
#include "clockless_i2s_esp32.h"
#else
diff --git a/src/platforms/esp/32/fastspi_esp32.h b/src/platforms/esp/32/fastspi_esp32.h
new file mode 100644
index 00000000..33d620fd
--- /dev/null
+++ b/src/platforms/esp/32/fastspi_esp32.h
@@ -0,0 +1,168 @@
+#pragma once
+#pragma message "ESP32 Hardware SPI support added"
+
+FASTLED_NAMESPACE_BEGIN
+
+/*
+ * ESP32 Hardware SPI Driver
+ *
+ * Copyright (c) 2020 Nick Wallace
+ * Derived from code for ESP8266 hardware SPI by Benoit Anastay.
+ *
+ * This hardware SPI implementation can drive clocked LEDs from either the
+ * VSPI or HSPI bus (aka SPI2 & SPI3). No support is provided for SPI1, because it is
+ * shared among devices and the cache for data (code) in the Flash as well as the PSRAM.
+ *
+ * To enable the hardware SPI driver, add the following line *before* including
+ * FastLED.h:
+ *
+ * #define FASTLED_ALL_PINS_HARDWARE_SPI
+ *
+ * This driver uses the VSPI bus by default (GPIO 18, 19, 23, & 5). To use the
+ * HSPI bus (GPIO 14, 12, 13, & 15) add the following line *before* including
+ * FastLED.h:
+ *
+ * #define FASTLED_ESP32_SPI_BUS HSPI
+ *
+ */
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef FASTLED_ESP32_SPI_BUS
+ #define FASTLED_ESP32_SPI_BUS VSPI
+#endif
+
+SPIClass ledSPI(FASTLED_ESP32_SPI_BUS);
+
+#if FASTLED_ESP32_SPI_BUS == VSPI
+ static uint8_t spiClk = 18;
+ static uint8_t spiMiso = 19;
+ static uint8_t spiMosi = 23;
+ static uint8_t spiCs = 5;
+#elif FASTLED_ESP32_SPI_BUS == HSPI
+ static uint8_t spiClk = 14;
+ static uint8_t spiMiso = 12;
+ static uint8_t spiMosi = 13;
+ static uint8_t spiCs = 15;
+#endif
+
+template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
+class ESP32SPIOutput {
+ Selectable *m_pSelect;
+
+public:
+ ESP32SPIOutput() { m_pSelect = NULL; }
+ ESP32SPIOutput(Selectable *pSelect) { m_pSelect = pSelect; }
+ void setSelect(Selectable *pSelect) { m_pSelect = pSelect; }
+
+ void init() {
+ // set the pins to output and make sure the select is released (which apparently means hi? This is a bit
+ // confusing to me)
+ ledSPI.begin(spiClk, spiMiso, spiMosi, spiCs);
+ release();
+ }
+
+ // stop the SPI output. Pretty much a NOP with software, as there's no registers to kick
+ static void stop() { }
+
+ // wait until the SPI subsystem is ready for more data to write. A NOP when bitbanging
+ static void wait() __attribute__((always_inline)) { }
+ static void waitFully() __attribute__((always_inline)) { wait(); }
+
+ static void writeByteNoWait(uint8_t b) __attribute__((always_inline)) { writeByte(b); }
+ static void writeBytePostWait(uint8_t b) __attribute__((always_inline)) { writeByte(b); wait(); }
+
+ static void writeWord(uint16_t w) __attribute__((always_inline)) { writeByte(w>>8); writeByte(w&0xFF); }
+
+ // naive writeByte implelentation, simply calls writeBit on the 8 bits in the byte.
+ static void writeByte(uint8_t b) {
+ ledSPI.transfer(b);
+ }
+
+public:
+
+ // select the SPI output (TODO: research whether this really means hi or lo. Alt TODO: move select responsibility out of the SPI classes
+ // entirely, make it up to the caller to remember to lock/select the line?)
+ void select() {
+ ledSPI.beginTransaction(SPISettings(SPI_SPEED, MSBFIRST, SPI_MODE0));
+ if(m_pSelect != NULL) { m_pSelect->select(); }
+ }
+
+ // release the SPI line
+ void release() {
+ if(m_pSelect != NULL) { m_pSelect->release(); }
+ ledSPI.endTransaction();
+ }
+
+ // Write out len bytes of the given value out over ledSPI. Useful for quickly flushing, say, a line of 0's down the line.
+ void writeBytesValue(uint8_t value, int len) {
+ select();
+ writeBytesValueRaw(value, len);
+ release();
+ }
+
+ static void writeBytesValueRaw(uint8_t value, int len) {
+ while(len--) {
+ ledSPI.transfer(value);
+ }
+ }
+
+ // write a block of len uint8_ts out. Need to type this better so that explicit casts into the call aren't required.
+ // note that this template version takes a class parameter for a per-byte modifier to the data.
+ template <class D> void writeBytes(register uint8_t *data, int len) {
+ select();
+ uint8_t *end = data + len;
+ while(data != end) {
+ writeByte(D::adjust(*data++));
+ }
+ D::postBlock(len);
+ release();
+ }
+
+ // default version of writing a block of data out to the SPI port, with no data modifications being made
+ void writeBytes(register uint8_t *data, int len) { writeBytes<DATA_NOP>(data, len); }
+
+ // write a single bit out, which bit from the passed in byte is determined by template parameter
+ template <uint8_t BIT> inline void writeBit(uint8_t b) {
+ ledSPI.transfer(b);
+ }
+
+ // write a block of uint8_ts out in groups of three. len is the total number of uint8_ts to write out. The template
+ // parameters indicate how many uint8_ts to skip at the beginning of each grouping, as well as a class specifying a per
+ // byte of data modification to be made. (See DATA_NOP above)
+ template <uint8_t FLAGS, class D, EOrder RGB_ORDER> __attribute__((noinline)) void writePixels(PixelController<RGB_ORDER> pixels) {
+ select();
+ int len = pixels.mLen;
+ while(pixels.has(1)) {
+ if(FLAGS & FLAG_START_BIT) {
+ writeBit<0>(1);
+ }
+ writeByte(D::adjust(pixels.loadAndScale0()));
+ writeByte(D::adjust(pixels.loadAndScale1()));
+ writeByte(D::adjust(pixels.loadAndScale2()));
+ pixels.advanceData();
+ pixels.stepDithering();
+ }
+ D::postBlock(len);
+ release();
+ }
+};
+
+FASTLED_NAMESPACE_END \ No newline at end of file