From c74febefef79459d24ea8df80a63f6e71145d331 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 9 Apr 2023 10:02:49 -0700 Subject: [PATCH] Method File Cleanup (#683) --- src/NeoPixelBus.h | 41 +- src/internal/NeoMethods.h | 70 + .../{ => methods}/DotStarEsp32DmaSpiMethod.h | 0 .../{ => methods}/DotStarGenericMethod.h | 0 src/internal/{ => methods}/Esp32_i2s.c | 0 src/internal/{ => methods}/Esp32_i2s.h | 0 .../{ => methods}/Lpd6803GenericMethod.h | 0 .../{ => methods}/Lpd8806GenericMethod.h | 0 src/internal/{ => methods}/NeoArmMethod.h | 0 src/internal/{ => methods}/NeoAvrMethod.h | 0 .../{ => methods}/NeoEsp32I2sMethod.h | 0 .../{ => methods}/NeoEsp32I2sXMethod.h | 0 .../{ => methods}/NeoEsp32RmtMethod.cpp | 4 +- .../{ => methods}/NeoEsp32RmtMethod.h | 1882 ++++++++--------- .../{ => methods}/NeoEsp8266DmaMethod.h | 0 .../{ => methods}/NeoEsp8266I2sDmx512Method.h | 0 .../{ => methods}/NeoEsp8266I2sMethodCore.cpp | 2 +- .../{ => methods}/NeoEsp8266I2sMethodCore.h | 0 .../{ => methods}/NeoEsp8266UartMethod.cpp | 2 +- .../{ => methods}/NeoEsp8266UartMethod.h | 0 .../{ => methods}/NeoEspBitBangMethod.cpp | 0 .../{ => methods}/NeoEspBitBangMethod.h | 0 src/internal/{ => methods}/NeoNrf52xMethod.h | 0 src/internal/{ => methods}/NeoPixelAvr.c | 0 .../{ => methods}/P9813GenericMethod.h | 0 .../{ => methods}/Sm16716GenericMethod.h | 0 .../{ => methods}/Tlc5947GenericMethod.h | 0 .../{ => methods}/TwoWireBitBangImple.h | 0 .../{ => methods}/TwoWireBitBangImpleAvr.h | 0 src/internal/{ => methods}/TwoWireHspiImple.h | 0 src/internal/{ => methods}/TwoWireSpiImple.h | 0 .../{ => methods}/Ws2801GenericMethod.h | 0 32 files changed, 1016 insertions(+), 985 deletions(-) create mode 100644 src/internal/NeoMethods.h rename src/internal/{ => methods}/DotStarEsp32DmaSpiMethod.h (100%) rename src/internal/{ => methods}/DotStarGenericMethod.h (100%) rename src/internal/{ => methods}/Esp32_i2s.c (100%) rename src/internal/{ => methods}/Esp32_i2s.h (100%) rename src/internal/{ => methods}/Lpd6803GenericMethod.h (100%) rename src/internal/{ => methods}/Lpd8806GenericMethod.h (100%) rename src/internal/{ => methods}/NeoArmMethod.h (100%) rename src/internal/{ => methods}/NeoAvrMethod.h (100%) rename src/internal/{ => methods}/NeoEsp32I2sMethod.h (100%) rename src/internal/{ => methods}/NeoEsp32I2sXMethod.h (100%) rename src/internal/{ => methods}/NeoEsp32RmtMethod.cpp (99%) rename src/internal/{ => methods}/NeoEsp32RmtMethod.h (97%) rename src/internal/{ => methods}/NeoEsp8266DmaMethod.h (100%) rename src/internal/{ => methods}/NeoEsp8266I2sDmx512Method.h (100%) rename src/internal/{ => methods}/NeoEsp8266I2sMethodCore.cpp (98%) rename src/internal/{ => methods}/NeoEsp8266I2sMethodCore.h (100%) rename src/internal/{ => methods}/NeoEsp8266UartMethod.cpp (99%) rename src/internal/{ => methods}/NeoEsp8266UartMethod.h (100%) rename src/internal/{ => methods}/NeoEspBitBangMethod.cpp (100%) rename src/internal/{ => methods}/NeoEspBitBangMethod.h (100%) rename src/internal/{ => methods}/NeoNrf52xMethod.h (100%) rename src/internal/{ => methods}/NeoPixelAvr.c (100%) rename src/internal/{ => methods}/P9813GenericMethod.h (100%) rename src/internal/{ => methods}/Sm16716GenericMethod.h (100%) rename src/internal/{ => methods}/Tlc5947GenericMethod.h (100%) rename src/internal/{ => methods}/TwoWireBitBangImple.h (100%) rename src/internal/{ => methods}/TwoWireBitBangImpleAvr.h (100%) rename src/internal/{ => methods}/TwoWireHspiImple.h (100%) rename src/internal/{ => methods}/TwoWireSpiImple.h (100%) rename src/internal/{ => methods}/Ws2801GenericMethod.h (100%) diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index dc48e612..bf6344fd 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -39,47 +39,8 @@ const uint16_t PixelIndex_OutOfBounds = 0xffff; #include "internal/NeoColorFeatures.h" #include "internal/NeoTopologies.h" #include "internal/NeoBuffers.h" - #include "internal/NeoBusChannel.h" - -#include "internal/DotStarGenericMethod.h" -#include "internal/Lpd8806GenericMethod.h" -#include "internal/Lpd6803GenericMethod.h" -#include "internal/Ws2801GenericMethod.h" -#include "internal/P9813GenericMethod.h" -#include "internal/Tlc5947GenericMethod.h" -#include "internal/Sm16716GenericMethod.h" - -#if defined(ARDUINO_ARCH_ESP8266) - -#include "internal/NeoEsp8266DmaMethod.h" -#include "internal/NeoEsp8266I2sDmx512Method.h" -#include "internal/NeoEsp8266UartMethod.h" -#include "internal/NeoEspBitBangMethod.h" - -#elif defined(ARDUINO_ARCH_ESP32) - -#include "internal/NeoEsp32I2sMethod.h" -#include "internal/NeoEsp32RmtMethod.h" -#include "internal/NeoEspBitBangMethod.h" -#include "internal/DotStarEsp32DmaSpiMethod.h" -#include "internal/NeoEsp32I2sXMethod.h" - -#elif defined(ARDUINO_ARCH_NRF52840) // must be before __arm__ - -#include "internal/NeoNrf52xMethod.h" - -#elif defined(__arm__) // must be before ARDUINO_ARCH_AVR due to Teensy incorrectly having it set - -#include "internal/NeoArmMethod.h" - -#elif defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) - -#include "internal/NeoAvrMethod.h" - -#else -#error "Platform Currently Not Supported, please add an Issue at Github/Makuna/NeoPixelBus" -#endif +#include "internal/NeoMethods.h" template class NeoPixelBus diff --git a/src/internal/NeoMethods.h b/src/internal/NeoMethods.h new file mode 100644 index 00000000..d60260fc --- /dev/null +++ b/src/internal/NeoMethods.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------------------- +NeoMethods includes all the classes that describe pulse/data sending methods using +bitbang, SPI, or other platform specific hardware peripherl support. + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +// Generic Two Wire (clk and data) methods +// +#include "methods/DotStarGenericMethod.h" +#include "methods/Lpd8806GenericMethod.h" +#include "methods/Lpd6803GenericMethod.h" +#include "methods/Ws2801GenericMethod.h" +#include "methods/P9813GenericMethod.h" +#include "methods/Tlc5947GenericMethod.h" +#include "methods/Sm16716GenericMethod.h" + +// Platform specific and One Wire (data) methods +// +#if defined(ARDUINO_ARCH_ESP8266) + +#include "methods/NeoEsp8266DmaMethod.h" +#include "methods/NeoEsp8266I2sDmx512Method.h" +#include "methods/NeoEsp8266UartMethod.h" +#include "methods/NeoEspBitBangMethod.h" + +#elif defined(ARDUINO_ARCH_ESP32) + +#include "methods/NeoEsp32I2sMethod.h" +#include "methods/NeoEsp32RmtMethod.h" +#include "methods/NeoEspBitBangMethod.h" +#include "methods/DotStarEsp32DmaSpiMethod.h" +#include "methods/NeoEsp32I2sXMethod.h" + +#elif defined(ARDUINO_ARCH_NRF52840) // must be before __arm__ + +#include "methods/NeoNrf52xMethod.h" + +#elif defined(__arm__) // must be before ARDUINO_ARCH_AVR due to Teensy incorrectly having it set + +#include "methods/NeoArmMethod.h" + +#elif defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) + +#include "methods/NeoAvrMethod.h" + +#else +#error "Platform Currently Not Supported, please add an Issue at Github/Makuna/NeoPixelBus" +#endif diff --git a/src/internal/DotStarEsp32DmaSpiMethod.h b/src/internal/methods/DotStarEsp32DmaSpiMethod.h similarity index 100% rename from src/internal/DotStarEsp32DmaSpiMethod.h rename to src/internal/methods/DotStarEsp32DmaSpiMethod.h diff --git a/src/internal/DotStarGenericMethod.h b/src/internal/methods/DotStarGenericMethod.h similarity index 100% rename from src/internal/DotStarGenericMethod.h rename to src/internal/methods/DotStarGenericMethod.h diff --git a/src/internal/Esp32_i2s.c b/src/internal/methods/Esp32_i2s.c similarity index 100% rename from src/internal/Esp32_i2s.c rename to src/internal/methods/Esp32_i2s.c diff --git a/src/internal/Esp32_i2s.h b/src/internal/methods/Esp32_i2s.h similarity index 100% rename from src/internal/Esp32_i2s.h rename to src/internal/methods/Esp32_i2s.h diff --git a/src/internal/Lpd6803GenericMethod.h b/src/internal/methods/Lpd6803GenericMethod.h similarity index 100% rename from src/internal/Lpd6803GenericMethod.h rename to src/internal/methods/Lpd6803GenericMethod.h diff --git a/src/internal/Lpd8806GenericMethod.h b/src/internal/methods/Lpd8806GenericMethod.h similarity index 100% rename from src/internal/Lpd8806GenericMethod.h rename to src/internal/methods/Lpd8806GenericMethod.h diff --git a/src/internal/NeoArmMethod.h b/src/internal/methods/NeoArmMethod.h similarity index 100% rename from src/internal/NeoArmMethod.h rename to src/internal/methods/NeoArmMethod.h diff --git a/src/internal/NeoAvrMethod.h b/src/internal/methods/NeoAvrMethod.h similarity index 100% rename from src/internal/NeoAvrMethod.h rename to src/internal/methods/NeoAvrMethod.h diff --git a/src/internal/NeoEsp32I2sMethod.h b/src/internal/methods/NeoEsp32I2sMethod.h similarity index 100% rename from src/internal/NeoEsp32I2sMethod.h rename to src/internal/methods/NeoEsp32I2sMethod.h diff --git a/src/internal/NeoEsp32I2sXMethod.h b/src/internal/methods/NeoEsp32I2sXMethod.h similarity index 100% rename from src/internal/NeoEsp32I2sXMethod.h rename to src/internal/methods/NeoEsp32I2sXMethod.h diff --git a/src/internal/NeoEsp32RmtMethod.cpp b/src/internal/methods/NeoEsp32RmtMethod.cpp similarity index 99% rename from src/internal/NeoEsp32RmtMethod.cpp rename to src/internal/methods/NeoEsp32RmtMethod.cpp index f25d20d8..2ae34929 100644 --- a/src/internal/NeoEsp32RmtMethod.cpp +++ b/src/internal/methods/NeoEsp32RmtMethod.cpp @@ -28,8 +28,8 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #include -#include "NeoSettings.h" -#include "NeoBusChannel.h" +#include "../NeoSettings.h" +#include "../NeoBusChannel.h" #include "NeoEsp32RmtMethod.h" #ifdef ARDUINO_ARCH_ESP32 diff --git a/src/internal/NeoEsp32RmtMethod.h b/src/internal/methods/NeoEsp32RmtMethod.h similarity index 97% rename from src/internal/NeoEsp32RmtMethod.h rename to src/internal/methods/NeoEsp32RmtMethod.h index 3cf240ba..2a22163e 100644 --- a/src/internal/NeoEsp32RmtMethod.h +++ b/src/internal/methods/NeoEsp32RmtMethod.h @@ -1,941 +1,941 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for Esp32. - -A BIG thanks to Andreas Merkle for the investigation and implementation of -a workaround to the GCC bug that drops method attributes from template methods - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#pragma once - -#ifdef ARDUINO_ARCH_ESP32 - -/* General Reference documentation for the APIs used in this implementation -LOW LEVEL: (what is actually used) -DOCS: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/rmt.html -EXAMPLE: https://github.com/espressif/esp-idf/blob/826ff7186ae07dc81e960a8ea09ebfc5304bfb3b/examples/peripherals/rmt_tx/main/rmt_tx_main.c - -HIGHER LEVEL: -NO TRANSLATE SUPPORT so this was not used -NOTE: https://github.com/espressif/arduino-esp32/commit/50d142950d229b8fabca9b749dc4a5f2533bc426 -Esp32-hal-rmt.h -Esp32-hal-rmt.c -*/ - -extern "C" -{ -#include -} - -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) -#define NEOPIXELBUS_RMT_INT_FLAGS (ESP_INTR_FLAG_LOWMED) -#else -#define NEOPIXELBUS_RMT_INT_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1) -#endif - -class NeoEsp32RmtSpeed -{ -public: - // ClkDiv of 2 provides for good resolution and plenty of reset resolution; but - // a ClkDiv of 1 will provide enough space for the longest reset and does show - // little better pulse accuracy - const static uint8_t RmtClockDivider = 2; - - inline constexpr static uint32_t FromNs(uint32_t ns) - { - return ns / NsPerRmtTick; - } - -protected: - const static uint32_t RmtCpu = 80000000L; // 80 mhz RMT clock - const static uint32_t NsPerSecond = 1000000000L; - const static uint32_t RmtTicksPerSecond = (RmtCpu / RmtClockDivider); - const static uint32_t NsPerRmtTick = (NsPerSecond / RmtTicksPerSecond); // about 25 - - static void IRAM_ATTR _translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num, - const uint32_t rmtBit0, - const uint32_t rmtBit1, - const uint16_t rmtDurationReset); - -}; - -class NeoEsp32RmtSpeedBase : public NeoEsp32RmtSpeed -{ -public: - // this is used rather than the rmt_item32_t as you can't correctly initialize - // it as a static constexpr within the template - inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) - { - return (FromNs(nsLow) << 16) | (1 << 15) | (FromNs(nsHigh)); - } - - const static rmt_idle_level_t IdleLevel = RMT_IDLE_LEVEL_LOW; -}; - -class NeoEsp32RmtInvertedSpeedBase : public NeoEsp32RmtSpeed -{ -public: - // this is used rather than the rmt_item32_t as you can't correctly initialize - // it as a static constexpr within the template - inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) - { - return (FromNs(nsLow) << 16) | (1 << 31) | (FromNs(nsHigh)); - } - - const static rmt_idle_level_t IdleLevel = RMT_IDLE_LEVEL_HIGH; -}; - -class NeoEsp32RmtSpeedWs2811 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtSpeedWs2812x : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtSpeedSk6812 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -// normal is inverted signal -class NeoEsp32RmtSpeedTm1814 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -// normal is inverted signal -class NeoEsp32RmtSpeedTm1829 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 900); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 400); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -// normal is inverted signal -class NeoEsp32RmtSpeedTm1914 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtSpeed800Kbps : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtSpeed400Kbps : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(800, 1700); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1600, 900); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtSpeedApa106 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(350, 1350); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1350, 350); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtSpeedTx1812 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 600); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(600, 300); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeedWs2811 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeedWs2812x : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeedSk6812 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -// normal is inverted signal -class NeoEsp32RmtInvertedSpeedTm1814 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -// normal is inverted signal -class NeoEsp32RmtInvertedSpeedTm1829 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 900); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 400); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -// normal is inverted signal -class NeoEsp32RmtInvertedSpeedTm1914 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeed800Kbps : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeed400Kbps : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(800, 1700); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1600, 900); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeedApa106 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(350, 1350); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1350, 350); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtInvertedSpeedTx1812 : public NeoEsp32RmtInvertedSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 600); - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(600, 300); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us - - static void IRAM_ATTR Translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num); -}; - -class NeoEsp32RmtChannel0 -{ -public: - NeoEsp32RmtChannel0() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_0; -}; - -class NeoEsp32RmtChannel1 -{ -public: - NeoEsp32RmtChannel1() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_1; -}; - -class NeoEsp32RmtChannel2 -{ -public: - NeoEsp32RmtChannel2() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_2; -}; - -class NeoEsp32RmtChannel3 -{ -public: - NeoEsp32RmtChannel3() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_3; -}; - -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) - -class NeoEsp32RmtChannel4 -{ -public: - NeoEsp32RmtChannel4() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_4; -}; - -class NeoEsp32RmtChannel5 -{ -public: - NeoEsp32RmtChannel5() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_5; -}; - -class NeoEsp32RmtChannel6 -{ -public: - NeoEsp32RmtChannel6() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_6; -}; - -class NeoEsp32RmtChannel7 -{ -public: - NeoEsp32RmtChannel7() {}; - - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_7; -}; - -#endif - -// dynamic channel support -class NeoEsp32RmtChannelN -{ -public: - NeoEsp32RmtChannelN(NeoBusChannel channel) : - RmtChannelNumber(static_cast(channel)) - { - } - NeoEsp32RmtChannelN() = delete; // no default constructor - - const rmt_channel_t RmtChannelNumber; -}; - -template class NeoEsp32RmtMethodBase -{ -public: - typedef NeoNoSettings SettingsObject; - - NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : - _sizeData(pixelCount * elementSize + settingsSize), - _pin(pin) - { - construct(); - } - - NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize, NeoBusChannel channel) : - _sizeData(pixelCount* elementSize + settingsSize), - _pin(pin), - _channel(channel) - { - construct(); - } - - ~NeoEsp32RmtMethodBase() - { - // wait until the last send finishes before destructing everything - // arbitrary time out of 10 seconds - ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(_channel.RmtChannelNumber, 10000 / portTICK_PERIOD_MS)); - - ESP_ERROR_CHECK(rmt_driver_uninstall(_channel.RmtChannelNumber)); - - gpio_matrix_out(_pin, 0x100, false, false); - pinMode(_pin, INPUT); - - free(_dataEditing); - free(_dataSending); - } - - - bool IsReadyToUpdate() const - { - return (ESP_OK == rmt_wait_tx_done(_channel.RmtChannelNumber, 0)); - } - - void Initialize() - { - rmt_config_t config = {}; - - config.rmt_mode = RMT_MODE_TX; - config.channel = _channel.RmtChannelNumber; - config.gpio_num = static_cast(_pin); - config.mem_block_num = 1; - config.tx_config.loop_en = false; - - config.tx_config.idle_output_en = true; - config.tx_config.idle_level = T_SPEED::IdleLevel; - - config.tx_config.carrier_en = false; - config.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; - - config.clk_div = T_SPEED::RmtClockDivider; - - ESP_ERROR_CHECK(rmt_config(&config)); - ESP_ERROR_CHECK(rmt_driver_install(_channel.RmtChannelNumber, 0, NEOPIXELBUS_RMT_INT_FLAGS)); - ESP_ERROR_CHECK(rmt_translator_init(_channel.RmtChannelNumber, T_SPEED::Translate)); - } - - void Update(bool maintainBufferConsistency) - { - // wait for not actively sending data - // this will time out at 10 seconds, an arbitrarily long period of time - // and do nothing if this happens - if (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(_channel.RmtChannelNumber, 10000 / portTICK_PERIOD_MS))) - { - // now start the RMT transmit with the editing buffer before we swap - ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_write_sample(_channel.RmtChannelNumber, _dataEditing, _sizeData, false)); - - if (maintainBufferConsistency) - { - // copy editing to sending, - // this maintains the contract that "colors present before will - // be the same after", otherwise GetPixelColor will be inconsistent - memcpy(_dataSending, _dataEditing, _sizeData); - } - - // swap so the user can modify without affecting the async operation - std::swap(_dataSending, _dataEditing); - } - } - - bool AlwaysUpdate() - { - // this method requires update to be called only if changes to buffer - return false; - } - - uint8_t* getData() const - { - return _dataEditing; - }; - - size_t getDataSize() const - { - return _sizeData; - } - - void applySettings([[maybe_unused]] const SettingsObject& settings) - { - } - -private: - const size_t _sizeData; // Size of '_data*' buffers - const uint8_t _pin; // output pin number - const T_CHANNEL _channel; // holds instance for multi channel support - - // Holds data stream which include LED color values and other settings as needed - uint8_t* _dataEditing; // exposed for get and set - uint8_t* _dataSending; // used for async send using RMT - - - void construct() - { - _dataEditing = static_cast(malloc(_sizeData)); - // data cleared later in Begin() - - _dataSending = static_cast(malloc(_sizeData)); - // no need to initialize it, it gets overwritten on every send - } -}; - -// normal -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNSk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNApa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtN800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtN400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsMethod; - -#if !defined(CONFIG_IDF_TARGET_ESP32C3) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsMethod; - -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2816Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsMethod; - -#endif // !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) -#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) - -// inverted -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNSk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNApa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtN800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtN400KbpsInvertedMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsInvertedMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsInvertedMethod; - -#if !defined(CONFIG_IDF_TARGET_ESP32C3) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsInvertedMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsInvertedMethod; - -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsInvertedMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsInvertedMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsInvertedMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2816InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsInvertedMethod; - -#endif // !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) -#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) - - -#if defined(NEOPIXEL_ESP32_RMT_DEFAULT) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) - -// Normally I2s method is the default, defining NEOPIXEL_ESP32_RMT_DEFAULT -// will switch to use RMT as the default method -// The ESP32S2 & ESP32C3 will always defualt to RMT - -#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) - -// RMT channel 1 method is the default method for Esp32S2 & Esp32C3 -typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2813Method; -typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2812xMethod; -typedef NeoEsp32Rmt1800KbpsMethod NeoWs2812Method; -typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2811Method; -typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2816Method; -typedef NeoEsp32Rmt1Sk6812Method NeoSk6812Method; -typedef NeoEsp32Rmt1Tm1814Method NeoTm1814Method; -typedef NeoEsp32Rmt1Tm1829Method NeoTm1829Method; -typedef NeoEsp32Rmt1Tm1914Method NeoTm1914Method; -typedef NeoEsp32Rmt1Sk6812Method NeoLc8812Method; -typedef NeoEsp32Rmt1Apa106Method NeoApa106Method; -typedef NeoEsp32Rmt1Tx1812Method NeoTx1812Method; - -typedef NeoEsp32Rmt1Ws2812xMethod Neo800KbpsMethod; -typedef NeoEsp32Rmt1400KbpsMethod Neo400KbpsMethod; - -typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2813InvertedMethod; -typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2812xInvertedMethod; -typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2811InvertedMethod; -typedef NeoEsp32Rmt1800KbpsInvertedMethod NeoWs2812InvertedMethod; -typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2816InvertedMethod; -typedef NeoEsp32Rmt1Sk6812InvertedMethod NeoSk6812InvertedMethod; -typedef NeoEsp32Rmt1Tm1814InvertedMethod NeoTm1814InvertedMethod; -typedef NeoEsp32Rmt1Tm1829InvertedMethod NeoTm1829InvertedMethod; -typedef NeoEsp32Rmt1Tm1914InvertedMethod NeoTm1914InvertedMethod; -typedef NeoEsp32Rmt1Sk6812InvertedMethod NeoLc8812InvertedMethod; -typedef NeoEsp32Rmt1Apa106InvertedMethod NeoApa106InvertedMethod; -typedef NeoEsp32Rmt1Tx1812InvertedMethod NeoTx1812InvertedMethod; - -typedef NeoEsp32Rmt1Ws2812xInvertedMethod Neo800KbpsInvertedMethod; -typedef NeoEsp32Rmt1400KbpsInvertedMethod Neo400KbpsInvertedMethod; - -#else // defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) - -// RMT channel 6 method is the default method for Esp32 -typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2813Method; -typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2812xMethod; -typedef NeoEsp32Rmt6800KbpsMethod NeoWs2812Method; -typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2811Method; -typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2816Method; -typedef NeoEsp32Rmt6Sk6812Method NeoSk6812Method; -typedef NeoEsp32Rmt6Tm1814Method NeoTm1814Method; -typedef NeoEsp32Rmt6Tm1829Method NeoTm1829Method; -typedef NeoEsp32Rmt6Tm1914Method NeoTm1914Method; -typedef NeoEsp32Rmt6Sk6812Method NeoLc8812Method; -typedef NeoEsp32Rmt6Apa106Method NeoApa106Method; -typedef NeoEsp32Rmt6Tx1812Method NeoTx1812Method; - -typedef NeoEsp32Rmt6Ws2812xMethod Neo800KbpsMethod; -typedef NeoEsp32Rmt6400KbpsMethod Neo400KbpsMethod; - -typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2813InvertedMethod; -typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2812xInvertedMethod; -typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2811InvertedMethod; -typedef NeoEsp32Rmt6800KbpsInvertedMethod NeoWs2812InvertedMethod; -typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2816InvertedMethod; -typedef NeoEsp32Rmt6Sk6812InvertedMethod NeoSk6812InvertedMethod; -typedef NeoEsp32Rmt6Tm1814InvertedMethod NeoTm1814InvertedMethod; -typedef NeoEsp32Rmt6Tm1829InvertedMethod NeoTm1829InvertedMethod; -typedef NeoEsp32Rmt6Tm1914InvertedMethod NeoTm1914InvertedMethod; -typedef NeoEsp32Rmt6Sk6812InvertedMethod NeoLc8812InvertedMethod; -typedef NeoEsp32Rmt6Apa106InvertedMethod NeoApa106InvertedMethod; -typedef NeoEsp32Rmt6Tx1812InvertedMethod NeoTx1812InvertedMethod; - -typedef NeoEsp32Rmt6Ws2812xInvertedMethod Neo800KbpsInvertedMethod; -typedef NeoEsp32Rmt6400KbpsInvertedMethod Neo400KbpsInvertedMethod; - -#endif // defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) - -#endif // defined(NEOPIXEL_ESP32_RMT_DEFAULT) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) - -#endif +/*------------------------------------------------------------------------- +NeoPixel library helper functions for Esp32. + +A BIG thanks to Andreas Merkle for the investigation and implementation of +a workaround to the GCC bug that drops method attributes from template methods + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#ifdef ARDUINO_ARCH_ESP32 + +/* General Reference documentation for the APIs used in this implementation +LOW LEVEL: (what is actually used) +DOCS: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/rmt.html +EXAMPLE: https://github.com/espressif/esp-idf/blob/826ff7186ae07dc81e960a8ea09ebfc5304bfb3b/examples/peripherals/rmt_tx/main/rmt_tx_main.c + +HIGHER LEVEL: +NO TRANSLATE SUPPORT so this was not used +NOTE: https://github.com/espressif/arduino-esp32/commit/50d142950d229b8fabca9b749dc4a5f2533bc426 +Esp32-hal-rmt.h +Esp32-hal-rmt.c +*/ + +extern "C" +{ +#include +} + +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) +#define NEOPIXELBUS_RMT_INT_FLAGS (ESP_INTR_FLAG_LOWMED) +#else +#define NEOPIXELBUS_RMT_INT_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1) +#endif + +class NeoEsp32RmtSpeed +{ +public: + // ClkDiv of 2 provides for good resolution and plenty of reset resolution; but + // a ClkDiv of 1 will provide enough space for the longest reset and does show + // little better pulse accuracy + const static uint8_t RmtClockDivider = 2; + + inline constexpr static uint32_t FromNs(uint32_t ns) + { + return ns / NsPerRmtTick; + } + +protected: + const static uint32_t RmtCpu = 80000000L; // 80 mhz RMT clock + const static uint32_t NsPerSecond = 1000000000L; + const static uint32_t RmtTicksPerSecond = (RmtCpu / RmtClockDivider); + const static uint32_t NsPerRmtTick = (NsPerSecond / RmtTicksPerSecond); // about 25 + + static void IRAM_ATTR _translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num, + const uint32_t rmtBit0, + const uint32_t rmtBit1, + const uint16_t rmtDurationReset); + +}; + +class NeoEsp32RmtSpeedBase : public NeoEsp32RmtSpeed +{ +public: + // this is used rather than the rmt_item32_t as you can't correctly initialize + // it as a static constexpr within the template + inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) + { + return (FromNs(nsLow) << 16) | (1 << 15) | (FromNs(nsHigh)); + } + + const static rmt_idle_level_t IdleLevel = RMT_IDLE_LEVEL_LOW; +}; + +class NeoEsp32RmtInvertedSpeedBase : public NeoEsp32RmtSpeed +{ +public: + // this is used rather than the rmt_item32_t as you can't correctly initialize + // it as a static constexpr within the template + inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) + { + return (FromNs(nsLow) << 16) | (1 << 31) | (FromNs(nsHigh)); + } + + const static rmt_idle_level_t IdleLevel = RMT_IDLE_LEVEL_HIGH; +}; + +class NeoEsp32RmtSpeedWs2811 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedWs2812x : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedSk6812 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1814 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1829 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 900); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 400); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1914 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeed800Kbps : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeed400Kbps : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(800, 1700); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1600, 900); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedApa106 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(350, 1350); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1350, 350); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedTx1812 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 600); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(600, 300); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedWs2811 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedWs2812x : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedSk6812 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1814 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1829 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 900); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 400); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1914 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeed800Kbps : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeed400Kbps : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(800, 1700); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1600, 900); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedApa106 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(350, 1350); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1350, 350); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedTx1812 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 600); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(600, 300); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtChannel0 +{ +public: + NeoEsp32RmtChannel0() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_0; +}; + +class NeoEsp32RmtChannel1 +{ +public: + NeoEsp32RmtChannel1() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_1; +}; + +class NeoEsp32RmtChannel2 +{ +public: + NeoEsp32RmtChannel2() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_2; +}; + +class NeoEsp32RmtChannel3 +{ +public: + NeoEsp32RmtChannel3() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_3; +}; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) + +class NeoEsp32RmtChannel4 +{ +public: + NeoEsp32RmtChannel4() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_4; +}; + +class NeoEsp32RmtChannel5 +{ +public: + NeoEsp32RmtChannel5() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_5; +}; + +class NeoEsp32RmtChannel6 +{ +public: + NeoEsp32RmtChannel6() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_6; +}; + +class NeoEsp32RmtChannel7 +{ +public: + NeoEsp32RmtChannel7() {}; + + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_7; +}; + +#endif + +// dynamic channel support +class NeoEsp32RmtChannelN +{ +public: + NeoEsp32RmtChannelN(NeoBusChannel channel) : + RmtChannelNumber(static_cast(channel)) + { + } + NeoEsp32RmtChannelN() = delete; // no default constructor + + const rmt_channel_t RmtChannelNumber; +}; + +template class NeoEsp32RmtMethodBase +{ +public: + typedef NeoNoSettings SettingsObject; + + NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _pin(pin) + { + construct(); + } + + NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize, NeoBusChannel channel) : + _sizeData(pixelCount* elementSize + settingsSize), + _pin(pin), + _channel(channel) + { + construct(); + } + + ~NeoEsp32RmtMethodBase() + { + // wait until the last send finishes before destructing everything + // arbitrary time out of 10 seconds + ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(_channel.RmtChannelNumber, 10000 / portTICK_PERIOD_MS)); + + ESP_ERROR_CHECK(rmt_driver_uninstall(_channel.RmtChannelNumber)); + + gpio_matrix_out(_pin, 0x100, false, false); + pinMode(_pin, INPUT); + + free(_dataEditing); + free(_dataSending); + } + + + bool IsReadyToUpdate() const + { + return (ESP_OK == rmt_wait_tx_done(_channel.RmtChannelNumber, 0)); + } + + void Initialize() + { + rmt_config_t config = {}; + + config.rmt_mode = RMT_MODE_TX; + config.channel = _channel.RmtChannelNumber; + config.gpio_num = static_cast(_pin); + config.mem_block_num = 1; + config.tx_config.loop_en = false; + + config.tx_config.idle_output_en = true; + config.tx_config.idle_level = T_SPEED::IdleLevel; + + config.tx_config.carrier_en = false; + config.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; + + config.clk_div = T_SPEED::RmtClockDivider; + + ESP_ERROR_CHECK(rmt_config(&config)); + ESP_ERROR_CHECK(rmt_driver_install(_channel.RmtChannelNumber, 0, NEOPIXELBUS_RMT_INT_FLAGS)); + ESP_ERROR_CHECK(rmt_translator_init(_channel.RmtChannelNumber, T_SPEED::Translate)); + } + + void Update(bool maintainBufferConsistency) + { + // wait for not actively sending data + // this will time out at 10 seconds, an arbitrarily long period of time + // and do nothing if this happens + if (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(_channel.RmtChannelNumber, 10000 / portTICK_PERIOD_MS))) + { + // now start the RMT transmit with the editing buffer before we swap + ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_write_sample(_channel.RmtChannelNumber, _dataEditing, _sizeData, false)); + + if (maintainBufferConsistency) + { + // copy editing to sending, + // this maintains the contract that "colors present before will + // be the same after", otherwise GetPixelColor will be inconsistent + memcpy(_dataSending, _dataEditing, _sizeData); + } + + // swap so the user can modify without affecting the async operation + std::swap(_dataSending, _dataEditing); + } + } + + bool AlwaysUpdate() + { + // this method requires update to be called only if changes to buffer + return false; + } + + uint8_t* getData() const + { + return _dataEditing; + }; + + size_t getDataSize() const + { + return _sizeData; + } + + void applySettings([[maybe_unused]] const SettingsObject& settings) + { + } + +private: + const size_t _sizeData; // Size of '_data*' buffers + const uint8_t _pin; // output pin number + const T_CHANNEL _channel; // holds instance for multi channel support + + // Holds data stream which include LED color values and other settings as needed + uint8_t* _dataEditing; // exposed for get and set + uint8_t* _dataSending; // used for async send using RMT + + + void construct() + { + _dataEditing = static_cast(malloc(_sizeData)); + // data cleared later in Begin() + + _dataSending = static_cast(malloc(_sizeData)); + // no need to initialize it, it gets overwritten on every send + } +}; + +// normal +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNSk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNApa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtN800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtN400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32C3) + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2816Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsMethod; + +#endif // !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) +#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) + +// inverted +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNSk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNApa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtNTx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtN800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtN400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsInvertedMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32C3) + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsInvertedMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2816InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsInvertedMethod; + +#endif // !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) +#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) + + +#if defined(NEOPIXEL_ESP32_RMT_DEFAULT) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) + +// Normally I2s method is the default, defining NEOPIXEL_ESP32_RMT_DEFAULT +// will switch to use RMT as the default method +// The ESP32S2 & ESP32C3 will always defualt to RMT + +#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) + +// RMT channel 1 method is the default method for Esp32S2 & Esp32C3 +typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2813Method; +typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2812xMethod; +typedef NeoEsp32Rmt1800KbpsMethod NeoWs2812Method; +typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2811Method; +typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2816Method; +typedef NeoEsp32Rmt1Sk6812Method NeoSk6812Method; +typedef NeoEsp32Rmt1Tm1814Method NeoTm1814Method; +typedef NeoEsp32Rmt1Tm1829Method NeoTm1829Method; +typedef NeoEsp32Rmt1Tm1914Method NeoTm1914Method; +typedef NeoEsp32Rmt1Sk6812Method NeoLc8812Method; +typedef NeoEsp32Rmt1Apa106Method NeoApa106Method; +typedef NeoEsp32Rmt1Tx1812Method NeoTx1812Method; + +typedef NeoEsp32Rmt1Ws2812xMethod Neo800KbpsMethod; +typedef NeoEsp32Rmt1400KbpsMethod Neo400KbpsMethod; + +typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoEsp32Rmt1800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoEsp32Rmt1Ws2812xInvertedMethod NeoWs2816InvertedMethod; +typedef NeoEsp32Rmt1Sk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoEsp32Rmt1Tm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoEsp32Rmt1Tm1829InvertedMethod NeoTm1829InvertedMethod; +typedef NeoEsp32Rmt1Tm1914InvertedMethod NeoTm1914InvertedMethod; +typedef NeoEsp32Rmt1Sk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoEsp32Rmt1Apa106InvertedMethod NeoApa106InvertedMethod; +typedef NeoEsp32Rmt1Tx1812InvertedMethod NeoTx1812InvertedMethod; + +typedef NeoEsp32Rmt1Ws2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoEsp32Rmt1400KbpsInvertedMethod Neo400KbpsInvertedMethod; + +#else // defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) + +// RMT channel 6 method is the default method for Esp32 +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2813Method; +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2812xMethod; +typedef NeoEsp32Rmt6800KbpsMethod NeoWs2812Method; +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2811Method; +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2816Method; +typedef NeoEsp32Rmt6Sk6812Method NeoSk6812Method; +typedef NeoEsp32Rmt6Tm1814Method NeoTm1814Method; +typedef NeoEsp32Rmt6Tm1829Method NeoTm1829Method; +typedef NeoEsp32Rmt6Tm1914Method NeoTm1914Method; +typedef NeoEsp32Rmt6Sk6812Method NeoLc8812Method; +typedef NeoEsp32Rmt6Apa106Method NeoApa106Method; +typedef NeoEsp32Rmt6Tx1812Method NeoTx1812Method; + +typedef NeoEsp32Rmt6Ws2812xMethod Neo800KbpsMethod; +typedef NeoEsp32Rmt6400KbpsMethod Neo400KbpsMethod; + +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoEsp32Rmt6800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2816InvertedMethod; +typedef NeoEsp32Rmt6Sk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoEsp32Rmt6Tm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoEsp32Rmt6Tm1829InvertedMethod NeoTm1829InvertedMethod; +typedef NeoEsp32Rmt6Tm1914InvertedMethod NeoTm1914InvertedMethod; +typedef NeoEsp32Rmt6Sk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoEsp32Rmt6Apa106InvertedMethod NeoApa106InvertedMethod; +typedef NeoEsp32Rmt6Tx1812InvertedMethod NeoTx1812InvertedMethod; + +typedef NeoEsp32Rmt6Ws2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoEsp32Rmt6400KbpsInvertedMethod Neo400KbpsInvertedMethod; + +#endif // defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) + +#endif // defined(NEOPIXEL_ESP32_RMT_DEFAULT) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) + +#endif diff --git a/src/internal/NeoEsp8266DmaMethod.h b/src/internal/methods/NeoEsp8266DmaMethod.h similarity index 100% rename from src/internal/NeoEsp8266DmaMethod.h rename to src/internal/methods/NeoEsp8266DmaMethod.h diff --git a/src/internal/NeoEsp8266I2sDmx512Method.h b/src/internal/methods/NeoEsp8266I2sDmx512Method.h similarity index 100% rename from src/internal/NeoEsp8266I2sDmx512Method.h rename to src/internal/methods/NeoEsp8266I2sDmx512Method.h diff --git a/src/internal/NeoEsp8266I2sMethodCore.cpp b/src/internal/methods/NeoEsp8266I2sMethodCore.cpp similarity index 98% rename from src/internal/NeoEsp8266I2sMethodCore.cpp rename to src/internal/methods/NeoEsp8266I2sMethodCore.cpp index 308081b8..e47e0bfa 100644 --- a/src/internal/NeoEsp8266I2sMethodCore.cpp +++ b/src/internal/methods/NeoEsp8266I2sMethodCore.cpp @@ -25,7 +25,7 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #include -#include "NeoUtil.h" +#include "../NeoUtil.h" #include "NeoEsp8266I2sMethodCore.h" #ifdef ARDUINO_ARCH_ESP8266 diff --git a/src/internal/NeoEsp8266I2sMethodCore.h b/src/internal/methods/NeoEsp8266I2sMethodCore.h similarity index 100% rename from src/internal/NeoEsp8266I2sMethodCore.h rename to src/internal/methods/NeoEsp8266I2sMethodCore.h diff --git a/src/internal/NeoEsp8266UartMethod.cpp b/src/internal/methods/NeoEsp8266UartMethod.cpp similarity index 99% rename from src/internal/NeoEsp8266UartMethod.cpp rename to src/internal/methods/NeoEsp8266UartMethod.cpp index 1b3bbcc4..ee74d472 100644 --- a/src/internal/NeoEsp8266UartMethod.cpp +++ b/src/internal/methods/NeoEsp8266UartMethod.cpp @@ -27,7 +27,7 @@ License along with NeoPixel. If not, see #ifdef ARDUINO_ARCH_ESP8266 #include -#include "NeoSettings.h" +#include "../NeoSettings.h" #include "NeoEsp8266UartMethod.h" #include extern "C" diff --git a/src/internal/NeoEsp8266UartMethod.h b/src/internal/methods/NeoEsp8266UartMethod.h similarity index 100% rename from src/internal/NeoEsp8266UartMethod.h rename to src/internal/methods/NeoEsp8266UartMethod.h diff --git a/src/internal/NeoEspBitBangMethod.cpp b/src/internal/methods/NeoEspBitBangMethod.cpp similarity index 100% rename from src/internal/NeoEspBitBangMethod.cpp rename to src/internal/methods/NeoEspBitBangMethod.cpp diff --git a/src/internal/NeoEspBitBangMethod.h b/src/internal/methods/NeoEspBitBangMethod.h similarity index 100% rename from src/internal/NeoEspBitBangMethod.h rename to src/internal/methods/NeoEspBitBangMethod.h diff --git a/src/internal/NeoNrf52xMethod.h b/src/internal/methods/NeoNrf52xMethod.h similarity index 100% rename from src/internal/NeoNrf52xMethod.h rename to src/internal/methods/NeoNrf52xMethod.h diff --git a/src/internal/NeoPixelAvr.c b/src/internal/methods/NeoPixelAvr.c similarity index 100% rename from src/internal/NeoPixelAvr.c rename to src/internal/methods/NeoPixelAvr.c diff --git a/src/internal/P9813GenericMethod.h b/src/internal/methods/P9813GenericMethod.h similarity index 100% rename from src/internal/P9813GenericMethod.h rename to src/internal/methods/P9813GenericMethod.h diff --git a/src/internal/Sm16716GenericMethod.h b/src/internal/methods/Sm16716GenericMethod.h similarity index 100% rename from src/internal/Sm16716GenericMethod.h rename to src/internal/methods/Sm16716GenericMethod.h diff --git a/src/internal/Tlc5947GenericMethod.h b/src/internal/methods/Tlc5947GenericMethod.h similarity index 100% rename from src/internal/Tlc5947GenericMethod.h rename to src/internal/methods/Tlc5947GenericMethod.h diff --git a/src/internal/TwoWireBitBangImple.h b/src/internal/methods/TwoWireBitBangImple.h similarity index 100% rename from src/internal/TwoWireBitBangImple.h rename to src/internal/methods/TwoWireBitBangImple.h diff --git a/src/internal/TwoWireBitBangImpleAvr.h b/src/internal/methods/TwoWireBitBangImpleAvr.h similarity index 100% rename from src/internal/TwoWireBitBangImpleAvr.h rename to src/internal/methods/TwoWireBitBangImpleAvr.h diff --git a/src/internal/TwoWireHspiImple.h b/src/internal/methods/TwoWireHspiImple.h similarity index 100% rename from src/internal/TwoWireHspiImple.h rename to src/internal/methods/TwoWireHspiImple.h diff --git a/src/internal/TwoWireSpiImple.h b/src/internal/methods/TwoWireSpiImple.h similarity index 100% rename from src/internal/TwoWireSpiImple.h rename to src/internal/methods/TwoWireSpiImple.h diff --git a/src/internal/Ws2801GenericMethod.h b/src/internal/methods/Ws2801GenericMethod.h similarity index 100% rename from src/internal/Ws2801GenericMethod.h rename to src/internal/methods/Ws2801GenericMethod.h