diff --git a/library.json b/library.json index 1e24823..cd7b8e1 100644 --- a/library.json +++ b/library.json @@ -8,7 +8,7 @@ "type": "git", "url": "https://github.com/Makuna/NeoPixelBus" }, - "version": "2.4.0", + "version": "2.4.1", "frameworks": "arduino", "platforms": "*" } diff --git a/library.properties b/library.properties index b5c1414..c13fff4 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=NeoPixelBus by Makuna -version=2.4.0 +version=2.4.1 author=Michael C. Miller (makuna@live.com) maintainer=Michael C. Miller (makuna@live.com) sentence=A library that makes controlling NeoPixels (WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102) easy. diff --git a/src/internal/NeoEsp8266UartMethod.cpp b/src/internal/NeoEsp8266UartMethod.cpp index c7d0ff9..eb06812 100644 --- a/src/internal/NeoEsp8266UartMethod.cpp +++ b/src/internal/NeoEsp8266UartMethod.cpp @@ -29,10 +29,37 @@ License along with NeoPixel. If not, see #include extern "C" { -// #include #include -// #include -// #include +} + +const volatile uint8_t* ICACHE_RAM_ATTR NeoEsp8266UartContext::FillUartFifo(uint8_t uartNum, + const volatile uint8_t* pixels, + const volatile uint8_t* end) +{ + // Remember: UARTs send less significant bit (LSB) first so + // pushing ABCDEF byte will generate a 0FEDCBA1 signal, + // including a LOW(0) start & a HIGH(1) stop bits. + // Also, we have configured UART to invert logic levels, so: + const uint8_t _uartData[4] = { + 0b110111, // On wire: 1 000 100 0 [Neopixel reads 00] + 0b000111, // On wire: 1 000 111 0 [Neopixel reads 01] + 0b110100, // On wire: 1 110 100 0 [Neopixel reads 10] + 0b000100, // On wire: 1 110 111 0 [NeoPixel reads 11] + }; + uint8_t avail = (UART_TX_FIFO_SIZE - GetTxFifoLength(uartNum)) / 4; + if (end - pixels > avail) + { + end = pixels + avail; + } + while (pixels < end) + { + uint8_t subpix = *pixels++; + Enqueue(uartNum, _uartData[(subpix >> 6) & 0x3]); + Enqueue(uartNum, _uartData[(subpix >> 4) & 0x3]); + Enqueue(uartNum, _uartData[(subpix >> 2) & 0x3]); + Enqueue(uartNum, _uartData[subpix & 0x3]); + } + return pixels; } volatile NeoEsp8266UartInterruptContext* NeoEsp8266UartInterruptContext::s_uartInteruptContext[] = { nullptr, nullptr }; diff --git a/src/internal/NeoEsp8266UartMethod.h b/src/internal/NeoEsp8266UartMethod.h index bc307d0..2c88a7f 100644 --- a/src/internal/NeoEsp8266UartMethod.h +++ b/src/internal/NeoEsp8266UartMethod.h @@ -47,35 +47,9 @@ public: USF(uartNum) = value; } - static const volatile uint8_t* ICACHE_RAM_ATTR FillUartFifo(uint8_t uartNum, - const volatile uint8_t* pixels, - const volatile uint8_t* end) - { - // Remember: UARTs send less significant bit (LSB) first so - // pushing ABCDEF byte will generate a 0FEDCBA1 signal, - // including a LOW(0) start & a HIGH(1) stop bits. - // Also, we have configured UART to invert logic levels, so: - const uint8_t _uartData[4] = { - 0b110111, // On wire: 1 000 100 0 [Neopixel reads 00] - 0b000111, // On wire: 1 000 111 0 [Neopixel reads 01] - 0b110100, // On wire: 1 110 100 0 [Neopixel reads 10] - 0b000100, // On wire: 1 110 111 0 [NeoPixel reads 11] - }; - uint8_t avail = (UART_TX_FIFO_SIZE - GetTxFifoLength(uartNum)) / 4; - if (end - pixels > avail) - { - end = pixels + avail; - } - while (pixels < end) - { - uint8_t subpix = *pixels++; - Enqueue(uartNum, _uartData[(subpix >> 6) & 0x3]); - Enqueue(uartNum, _uartData[(subpix >> 4) & 0x3]); - Enqueue(uartNum, _uartData[(subpix >> 2) & 0x3]); - Enqueue(uartNum, _uartData[subpix & 0x3]); - } - return pixels; - } + static const volatile uint8_t* ICACHE_RAM_ATTR FillUartFifo(uint8_t uartNum, + const volatile uint8_t* pixels, + const volatile uint8_t* end); }; // this template method class is used to track the data being sent on the uart