Revert "Merge pull request #22 from sticilface/Fork-In-Eye-UART"

This reverts commit da5a8b9213, reversing
changes made to 36cb67dac9.
This commit is contained in:
Makuna
2015-09-03 14:23:56 -07:00
parent 2652a9db21
commit db86f7dd6f
5 changed files with 13 additions and 214 deletions
+10 -119
View File
@@ -32,31 +32,12 @@ License along with NeoPixel. If not, see
#include "NeoPixelBus.h"
#if defined(ESP8266)
#ifdef ESPUARTWS2812
extern "C" {
#include "eagle_soc.h"
#include "uart_register.h"
#include <Arduino.h>
}
#define UART_INV_MASK (0x3f<<19)
#define UART 1
extern void ICACHE_RAM_ATTR send_pixels_UART(uint8_t* pixels, uint8_t* end, bool force);
#else
// due to linker overriding the ICACHE_RAM_ATTR for cpp files, these methods are
// moved into a C file so the attribute will be applied correctly
extern "C" void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixels, uint8_t* end, uint8_t pin);
extern "C" void ICACHE_RAM_ATTR send_pixels_400(uint8_t* pixels, uint8_t* end, uint8_t pin);
#endif
// due to linker overriding the ICACHE_RAM_ATTR for cpp files, these methods are
// moved into a C file so the attribute will be applied correctly
extern "C" void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixels, uint8_t* end, uint8_t pin);
extern "C" void ICACHE_RAM_ATTR send_pixels_400(uint8_t* pixels, uint8_t* end, uint8_t pin);
#endif
NeoPixelBus::NeoPixelBus(uint16_t n, uint8_t p, uint8_t t) :
_countPixels(n),
_sizePixels(n * 3),
@@ -65,11 +46,7 @@ NeoPixelBus::NeoPixelBus(uint16_t n, uint8_t p, uint8_t t) :
_activeAnimations(0),
_flagsPixels(t)
{
#ifndef ESPUARTWS2812
setPin(p);
#endif
_pixels = (uint8_t *)malloc(_sizePixels);
if (_pixels)
@@ -92,58 +69,17 @@ NeoPixelBus::~NeoPixelBus()
if (_animations)
free(_animations);
#ifndef ESPUARTWS2812
pinMode(_pin, INPUT);
#endif
}
void NeoPixelBus::Begin(void)
{
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW);
void NeoPixelBus::FillUart(void) {
uint8_t* p = _pixels;
uint8_t* end = p + _sizePixels;
send_pixels_UART(p, end, false);
Dirty();
}
void NeoPixelBus::Begin(void)
{
#ifdef ESPUARTWS2812
/* Serial rate is 4x 800KHz for WS2811 */
#ifdef INCLUDE_NEO_KHZ400_SUPPORT
if ((_flagsPixels & NEO_SPDMASK) == NEO_KHZ800)
{
// 800 Support
Serial1.begin(3200000, SERIAL_6N1, SERIAL_TX_ONLY);
} else {
// 400 Support
Serial1.begin(1600000, SERIAL_6N1, SERIAL_TX_ONLY);
}
#else
Serial1.begin(3200000, SERIAL_6N1, SERIAL_TX_ONLY);
#endif
CLEAR_PERI_REG_MASK(UART_CONF0(UART), UART_INV_MASK);
//SET_PERI_REG_MASK(UART_CONF0(UART), UART_TXD_INV);
SET_PERI_REG_MASK(UART_CONF0(UART), (BIT(22)));
#else
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW);
#endif
Dirty();
}
void NeoPixelBus::Show(void)
{
if (!_pixels)
@@ -175,9 +111,7 @@ void NeoPixelBus::Show(void)
// state, computes 'pin high' and 'pin low' values, and writes these back
// to the PORT register as needed.
#ifndef ESPUARTWS2812
noInterrupts(); // Need 100% focus on instruction timing
#endif
#ifdef __AVR__
@@ -790,55 +724,15 @@ void NeoPixelBus::Show(void)
if ((_flagsPixels & NEO_SPDMASK) == NEO_KHZ800)
{
#endif
#ifndef ESPUARTWS2812
// 800 KHz bitstream
send_pixels_800(p, end, _pin);
#else
send_pixels_UART(p, end, true);
// char buff[4];
// do
// {
// uint8_t subpix = *p++;
// buff[0] = data[(subpix >> 6) & 3];
// buff[1] = data[(subpix >> 4) & 3];
// buff[2] = data[(subpix >> 2) & 3];
// buff[3] = data[subpix & 3];
// Serial1.write(buff, sizeof(buff));
// } while (p < end);
#endif
#ifdef INCLUDE_NEO_KHZ400_SUPPORT
}
else
{
#ifndef ESPUARTWS2812
// 800 KHz bitstream
// 400 kHz bitstream
send_pixels_400(p, end, _pin);
#else
char buff[4];
do
{
uint8_t subpix = *p++;
buff[0] = data[(subpix >> 6) & 3];
buff[1] = data[(subpix >> 4) & 3];
buff[2] = data[(subpix >> 2) & 3];
buff[3] = data[subpix & 3];
Serial1.write(buff, sizeof(buff));
} while (p < end);
#endif
}
#endif
@@ -1079,10 +973,7 @@ void NeoPixelBus::Show(void)
#endif // end Architecture select
#ifndef ESPUARTWS2812
interrupts();
#endif
ResetDirty();
_endTime = micros(); // Save EOD time for latch on next call
}