From 070cb5bfb404156b804068ad0f1543d51a622b1b Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 17 Sep 2024 13:53:44 -0700 Subject: [PATCH] Cleanup --- .../methods/ESP/ESP32/NeoEsp32RmtMethod.h | 713 +++--------------- .../methods/ESP/ESP32/NeoEsp32RmtSpeed.h | 240 ++++++ 2 files changed, 342 insertions(+), 611 deletions(-) create mode 100644 src/internal/methods/ESP/ESP32/NeoEsp32RmtSpeed.h diff --git a/src/internal/methods/ESP/ESP32/NeoEsp32RmtMethod.h b/src/internal/methods/ESP/ESP32/NeoEsp32RmtMethod.h index 669dfa9..7bfc351 100644 --- a/src/internal/methods/ESP/ESP32/NeoEsp32RmtMethod.h +++ b/src/internal/methods/ESP/ESP32/NeoEsp32RmtMethod.h @@ -1,9 +1,6 @@ /*------------------------------------------------------------------------- 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, @@ -44,6 +41,7 @@ Esp32-hal-rmt.c */ #include +#include "NeoEsp32RmtSpeed.h" extern void AddLog(uint32_t loglevel, PGM_P formatP, ...); @@ -57,78 +55,88 @@ extern "C" #define RMT_LED_STRIP_RESOLUTION_HZ 40000000 // 40MHz resolution - setting of the "old" driver -typedef struct { +struct led_strip_encoder_config_t +{ uint32_t resolution; /*!< Encoder resolution, in Hz */ -} led_strip_encoder_config_t; +}; -typedef struct { +struct rmt_led_strip_encoder_t +{ rmt_encoder_t base; - rmt_encoder_t *bytes_encoder; - rmt_encoder_t *copy_encoder; + rmt_encoder_t* bytes_encoder; + rmt_encoder_t* copy_encoder; int state; rmt_symbol_word_t reset_code; -} rmt_led_strip_encoder_t; +}; -static size_t rmt_encode_led_strip(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state) +static size_t rmt_encode_led_strip(rmt_encoder_t* encoder, rmt_channel_handle_t channel, const void* primary_data, size_t data_size, rmt_encode_state_t* ret_state) { - rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base); + rmt_led_strip_encoder_t* led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base); rmt_encoder_handle_t bytes_encoder = led_encoder->bytes_encoder; rmt_encoder_handle_t copy_encoder = led_encoder->copy_encoder; rmt_encode_state_t session_state = RMT_ENCODING_RESET; rmt_encode_state_t state = RMT_ENCODING_RESET; size_t encoded_symbols = 0; - switch (led_encoder->state) { + + switch (led_encoder->state) + { case 0: // send RGB data encoded_symbols += bytes_encoder->encode(bytes_encoder, channel, primary_data, data_size, &session_state); - if (session_state & RMT_ENCODING_COMPLETE) { + if (session_state & RMT_ENCODING_COMPLETE) + { led_encoder->state = 1; // switch to next state when current encoding session finished } - if (session_state & RMT_ENCODING_MEM_FULL) { + if (session_state & RMT_ENCODING_MEM_FULL) + { // static_cast(static_cast(a) | static_cast(b)); state = static_cast(static_cast(state) | static_cast(RMT_ENCODING_MEM_FULL)); goto out; // yield if there's no free space for encoding artifacts } - // fall-through + // fall-through case 1: // send reset code encoded_symbols += copy_encoder->encode(copy_encoder, channel, &led_encoder->reset_code, - sizeof(led_encoder->reset_code), &session_state); - if (session_state & RMT_ENCODING_COMPLETE) { + sizeof(led_encoder->reset_code), &session_state); + if (session_state & RMT_ENCODING_COMPLETE) + { led_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session state = static_cast(static_cast(state) | static_cast(RMT_ENCODING_COMPLETE)); } - if (session_state & RMT_ENCODING_MEM_FULL) { + if (session_state & RMT_ENCODING_MEM_FULL) + { state = static_cast(static_cast(state) | static_cast(RMT_ENCODING_MEM_FULL)); goto out; // yield if there's no free space for encoding artifacts } } + out: *ret_state = state; return encoded_symbols; } -static esp_err_t rmt_del_led_strip_encoder(rmt_encoder_t *encoder) +static esp_err_t rmt_del_led_strip_encoder(rmt_encoder_t* encoder) { - rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base); + rmt_led_strip_encoder_t* led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base); rmt_del_encoder(led_encoder->bytes_encoder); rmt_del_encoder(led_encoder->copy_encoder); delete led_encoder; return ESP_OK; } -static esp_err_t rmt_led_strip_encoder_reset(rmt_encoder_t *encoder) +static esp_err_t rmt_led_strip_encoder_reset(rmt_encoder_t* encoder) { - rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base); + rmt_led_strip_encoder_t* led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base); rmt_encoder_reset(led_encoder->bytes_encoder); rmt_encoder_reset(led_encoder->copy_encoder); led_encoder->state = RMT_ENCODING_RESET; return ESP_OK; } -static esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder, uint32_t bit0, uint32_t bit1) +static esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t* config, rmt_encoder_handle_t* ret_encoder, uint32_t bit0, uint32_t bit1) { const char* TAG = "TEST_RMT"; //TODO: Remove later + esp_err_t ret = ESP_OK; - rmt_led_strip_encoder_t *led_encoder = NULL; + rmt_led_strip_encoder_t* led_encoder = NULL; uint32_t reset_ticks = config->resolution / 1000000 * 50 / 2; // reset code duration defaults to 50us rmt_bytes_encoder_config_t bytes_encoder_config; rmt_copy_encoder_config_t copy_encoder_config = {}; @@ -157,331 +165,37 @@ static esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *con led_encoder->reset_code = reset_code_config; *ret_encoder = &led_encoder->base; return ret; + err: // AddLog(2,"RMT:could not init led decoder"); - if (led_encoder) { - if (led_encoder->bytes_encoder) { + if (led_encoder) + { + if (led_encoder->bytes_encoder) + { rmt_del_encoder(led_encoder->bytes_encoder); } - if (led_encoder->copy_encoder) { + if (led_encoder->copy_encoder) + { rmt_del_encoder(led_encoder->copy_encoder); } delete led_encoder; } + return ret; } #define NEOPIXELBUS_RMT_INT_FLAGS (ESP_INTR_FLAG_LOWMED) -class NeoEsp32RmtSpeed -{ -public: -// next section is probably not needed anymore for IDF 5.1 - // 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 -// end of deprecated section - -}; - -class NeoEsp32RmtSpeedBase : public NeoEsp32RmtSpeed -{ -public: - // this is used rather than the rmt_symbol_word_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)); - } -}; - -class NeoEsp32RmtInvertedSpeedBase : public NeoEsp32RmtSpeed -{ -public: - // this is used rather than the rmt_symbol_word_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)); - } -}; - -class NeoEsp32RmtSpeedWs2811 : public NeoEsp32RmtSpeedBase -{ -public: - const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); // TODO: DRAM_ATTR debatable everywhere - const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); - const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us -}; - -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 -}; - -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 -}; - -// 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 -}; - -// 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 -}; - -// 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 -}; - -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 -}; - -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 -}; - -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 -}; - -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 -}; - -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 -}; - -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 -}; - -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 -}; - -// 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 -}; - -// 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 -}; - -// 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 -}; - -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 -}; - -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 -}; - -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 -}; - -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 -}; - -class NeoEsp32RmtChannel0 -{ -public: - NeoEsp32RmtChannel0() {}; - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -class NeoEsp32RmtChannel1 -{ -public: - NeoEsp32RmtChannel1() {}; - - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -#if !defined(CONFIG_IDF_TARGET_ESP32C6) // C6 only 2 RMT channels ?? -class NeoEsp32RmtChannel2 -{ -public: - NeoEsp32RmtChannel2() {}; - - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -class NeoEsp32RmtChannel3 -{ -public: - NeoEsp32RmtChannel3() {}; - -protected: - rmt_channel_handle_t RmtChannelNumber = NULL; -}; -#endif // !defined(CONFIG_IDF_TARGET_ESP32C6) -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6) - -class NeoEsp32RmtChannel4 -{ -public: - NeoEsp32RmtChannel4() {}; - - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -class NeoEsp32RmtChannel5 -{ -public: - NeoEsp32RmtChannel5() {}; - - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -class NeoEsp32RmtChannel6 -{ -public: - NeoEsp32RmtChannel6() {}; - - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -class NeoEsp32RmtChannel7 -{ -public: - NeoEsp32RmtChannel7() {}; - - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -#endif - -// dynamic channel support -class NeoEsp32RmtChannelN -{ -public: - NeoEsp32RmtChannelN(NeoBusChannel channel) : - RmtChannelNumber(RmtChannelNumber) - { - RmtChannelNumber = NULL; - }; - NeoEsp32RmtChannelN() = delete; // no default constructor - rmt_channel_handle_t RmtChannelNumber = NULL; -}; - -template class NeoEsp32RmtMethodBase +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) : + NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize, NeoBusChannel channel = 0) : _sizeData(pixelCount* elementSize + settingsSize), _pin(pin), - _channel(channel) + _channel(NULL) { construct(); } @@ -491,8 +205,8 @@ public: // wait until the last send finishes before destructing everything // arbitrary time out of 10 seconds - ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_tx_wait_all_done(_channel.RmtChannelNumber, 10000 / portTICK_PERIOD_MS)); - ESP_ERROR_CHECK( rmt_del_channel(_channel.RmtChannelNumber)); + ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_tx_wait_all_done(_channel, 10000 / portTICK_PERIOD_MS)); + ESP_ERROR_CHECK(rmt_del_channel(_channel)); gpio_matrix_out(_pin, 0x100, false, false); pinMode(_pin, INPUT); @@ -504,7 +218,7 @@ public: bool IsReadyToUpdate() const { - return (ESP_OK == rmt_tx_wait_all_done(_channel.RmtChannelNumber, 0)); + return (ESP_OK == rmt_tx_wait_all_done(_channel, 0)); } void Initialize() @@ -519,7 +233,7 @@ public: config.flags.invert_out = false; // do not invert output signal config.flags.with_dma = false; // do not need DMA backend - ret += rmt_new_tx_channel(&config,&_channel.RmtChannelNumber); + ret += rmt_new_tx_channel(&config, &_channel); led_strip_encoder_config_t encoder_config = {}; encoder_config.resolution = RMT_LED_STRIP_RESOLUTION_HZ; @@ -528,7 +242,7 @@ public: ret += rmt_new_led_strip_encoder(&encoder_config, &_led_encoder, T_SPEED::RmtBit0, T_SPEED::RmtBit1); // ESP_LOGI(TAG, "Enable RMT TX channel"); - ret += rmt_enable(_channel.RmtChannelNumber); + ret += rmt_enable(_channel); // if (ret) { // AddLog(2,"RMT: initialized with error code: %u on pin: %u",ret, _pin); // } @@ -541,11 +255,11 @@ public: // 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_tx_wait_all_done(_channel.RmtChannelNumber, 10000 / portTICK_PERIOD_MS))) + if (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_tx_wait_all_done(_channel, 10000 / portTICK_PERIOD_MS))) { // AddLog(2,"__ %u", _sizeData); // now start the RMT transmit with the editing buffer before we swap - esp_err_t ret = rmt_transmit(_channel.RmtChannelNumber, _led_encoder, _dataEditing, _sizeData, &_tx_config); // 3 for _sizeData + esp_err_t ret = rmt_transmit(_channel, _led_encoder, _dataEditing, _sizeData, &_tx_config); // 3 for _sizeData // AddLog(2,"rmt_transmit: %u", ret); if (maintainBufferConsistency) { @@ -562,8 +276,8 @@ public: bool AlwaysUpdate() { - // this method requires update to be called only if changes to buffer - return false; + // this method requires update to be called only if changes to buffer + return false; } uint8_t* getData() const @@ -577,8 +291,7 @@ public: } void applySettings(const SettingsObject& settings) - { - } + {} private: const size_t _sizeData; // Size of '_data*' buffers @@ -586,13 +299,12 @@ private: rmt_transmit_config_t _tx_config = {}; rmt_encoder_handle_t _led_encoder = nullptr; - - T_CHANNEL _channel; // holds instance for multi channel support + rmt_channel_handle_t _channel = nullptr; // 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 + uint8_t* _dataEditing; // exposed for get and set + uint8_t* _dataSending; // used for async send using RMT void construct() @@ -607,215 +319,31 @@ private: }; // normal -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2812xMethod; -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 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 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) && !defined(CONFIG_IDF_TARGET_ESP32C6) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xMethod; -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 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) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xMethod; -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 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 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 NeoEsp32Rmt7Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1829Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1914Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tx1812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXWs2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXWs2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXSk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTm1829Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTm1914Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXApa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTx1812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtX800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtX400KbpsMethod; #endif // !defined(CONFIG_IDF_TARGET_ESP32S2) #endif // !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C3) // inverted -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32RmtNWs2812xInvertedMethod; -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 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 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) && !defined(CONFIG_IDF_TARGET_ESP32C6) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xInvertedMethod; -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 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) - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xInvertedMethod; -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 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 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 NeoEsp32Rmt7Sk6812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1829InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1914InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tx1812InvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsInvertedMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXWs2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXWs2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXSk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTm1829InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTm1914InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXApa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtXTx1812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtX800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32RmtX400KbpsInvertedMethod; #endif // !defined(CONFIG_IDF_TARGET_ESP32S2) #endif // !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6) @@ -827,73 +355,36 @@ typedef NeoEsp32RmtMethodBase. +-------------------------------------------------------------------------*/ + +#pragma once + +class NeoEsp32RmtSpeed +{ +public: + // next section is probably not needed anymore for IDF 5.1 + // 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 + // end of deprecated section + +}; + +class NeoEsp32RmtSpeedBase : public NeoEsp32RmtSpeed +{ +public: + // this is used rather than the rmt_symbol_word_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)); + } +}; + +class NeoEsp32RmtInvertedSpeedBase : public NeoEsp32RmtSpeed +{ +public: + // this is used rather than the rmt_symbol_word_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)); + } +}; + +class NeoEsp32RmtSpeedWs2811 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(300, 950); + const static uint32_t RmtBit1 = Item32Val(900, 350); + const static uint16_t RmtDurationReset = FromNs(300000); // 300us +}; + +class NeoEsp32RmtSpeedWs2812x : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(400, 850); + const static uint32_t RmtBit1 = Item32Val(800, 450); + const static uint16_t RmtDurationReset = FromNs(300000); // 300us +}; + +class NeoEsp32RmtSpeedSk6812 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(400, 850); + const static uint32_t RmtBit1 = Item32Val(800, 450); + const static uint16_t RmtDurationReset = FromNs(80000); // 80us +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1814 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(360, 890); + const static uint32_t RmtBit1 = Item32Val(720, 530); + const static uint16_t RmtDurationReset = FromNs(200000); // 200us +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1829 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(300, 900); + const static uint32_t RmtBit1 = Item32Val(800, 400); + const static uint16_t RmtDurationReset = FromNs(200000); // 200us +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1914 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(360, 890); + const static uint32_t RmtBit1 = Item32Val(720, 530); + const static uint16_t RmtDurationReset = FromNs(200000); // 200us +}; + +class NeoEsp32RmtSpeed800Kbps : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(400, 850); + const static uint32_t RmtBit1 = Item32Val(800, 450); + const static uint16_t RmtDurationReset = FromNs(50000); // 50us +}; + +class NeoEsp32RmtSpeed400Kbps : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(800, 1700); + const static uint32_t RmtBit1 = Item32Val(1600, 900); + const static uint16_t RmtDurationReset = FromNs(50000); // 50us +}; + +class NeoEsp32RmtSpeedApa106 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(350, 1350); + const static uint32_t RmtBit1 = Item32Val(1350, 350); + const static uint16_t RmtDurationReset = FromNs(50000); // 50us +}; + +class NeoEsp32RmtSpeedTx1812 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(300, 600); + const static uint32_t RmtBit1 = Item32Val(600, 300); + const static uint16_t RmtDurationReset = FromNs(80000); // 80us +}; + +class NeoEsp32RmtInvertedSpeedWs2811 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(300, 950); + const static uint32_t RmtBit1 = Item32Val(900, 350); + const static uint16_t RmtDurationReset = FromNs(300000); // 300us +}; + +class NeoEsp32RmtInvertedSpeedWs2812x : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(400, 850); + const static uint32_t RmtBit1 = Item32Val(800, 450); + const static uint16_t RmtDurationReset = FromNs(300000); // 300us +}; + +class NeoEsp32RmtInvertedSpeedSk6812 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(400, 850); + const static uint32_t RmtBit1 = Item32Val(800, 450); + const static uint16_t RmtDurationReset = FromNs(80000); // 80us +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1814 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(360, 890); + const static uint32_t RmtBit1 = Item32Val(720, 530); + const static uint16_t RmtDurationReset = FromNs(200000); // 200us +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1829 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(300, 900); + const static uint32_t RmtBit1 = Item32Val(800, 400); + const static uint16_t RmtDurationReset = FromNs(200000); // 200us +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1914 : public NeoEsp32RmtSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(360, 890); + const static uint32_t RmtBit1 = Item32Val(720, 530); + const static uint16_t RmtDurationReset = FromNs(200000); // 200us +}; + +class NeoEsp32RmtInvertedSpeed800Kbps : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(400, 850); + const static uint32_t RmtBit1 = Item32Val(800, 450); + const static uint16_t RmtDurationReset = FromNs(50000); // 50us +}; + +class NeoEsp32RmtInvertedSpeed400Kbps : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(800, 1700); + const static uint32_t RmtBit1 = Item32Val(1600, 900); + const static uint16_t RmtDurationReset = FromNs(50000); // 50us +}; + +class NeoEsp32RmtInvertedSpeedApa106 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(350, 1350); + const static uint32_t RmtBit1 = Item32Val(1350, 350); + const static uint16_t RmtDurationReset = FromNs(50000); // 50us +}; + +class NeoEsp32RmtInvertedSpeedTx1812 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static uint32_t RmtBit0 = Item32Val(300, 600); + const static uint32_t RmtBit1 = Item32Val(600, 300); + const static uint16_t RmtDurationReset = FromNs(80000); // 80us +}; + +#endif