not working

This commit is contained in:
Andrew Melvin
2015-08-27 07:30:16 +01:00
parent e620850707
commit cf00e8a41b
4 changed files with 55 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ License along with NeoPixel. If not, see
#define UART_INV_MASK (0x3f<<19)
#define UART 1
extern void ICACHE_RAM_ATTR send_pixels_UART(uint8_t* pixels, uint8_t* end);
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
@@ -98,6 +98,17 @@ NeoPixelBus::~NeoPixelBus()
}
void NeoPixelBus::FillUart(void) {
uint8_t* p = _pixels;
uint8_t* end = p + _sizePixels;
send_pixels_UART(p, end, false);
}
void NeoPixelBus::Begin(void)
{
@@ -785,21 +796,21 @@ void NeoPixelBus::Show(void)
send_pixels_800(p, end, _pin);
#else
send_pixels_UART(p, end);
send_pixels_UART(p, end,true);
char buff[4];
// char buff[4];
do
{
uint8_t subpix = *p++;
// 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));
// 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);
// } while (p < end);
#endif

View File

@@ -61,7 +61,7 @@ public:
{
ClearTo(c.R, c.G, c.B);
}
void FillUart();
bool IsDirty()
{
return (_flagsPixels & NEO_DIRTY);

View File

@@ -33,21 +33,33 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
const char data[4] = { 0b00110111, 0b00000111, 0b00110100, 0b00000100 };
void ICACHE_RAM_ATTR send_pixels_UART(uint8_t* pixels, uint8_t* end)
void ICACHE_RAM_ATTR send_pixels_UART(uint8_t* pixels, uint8_t* end, bool force)
{
char buff[4];
uint8_t count = 0;
static uint8_t* position = NULL;
if (position != NULL && !force ) {
pixels = position;
} else if (position == NULL && !force ) {
return;
}
do
{
uint8_t subpix = *pixels++;
position = pixels;
count++;
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 (pixels < end);
} while (pixels < end || count < 156 );
if ( pixels == end) { position = NULL; }
}

View File

@@ -1,8 +1,8 @@
#include <NeoPixelBus.h>
#define pixelCount 4
#define pixelCount 300
NeoPixelBus strip = NeoPixelBus(pixelCount, 8);
NeoPixelBus strip = NeoPixelBus(pixelCount, 2);
uint16_t effectState = 0;
@@ -13,6 +13,7 @@ void setup()
SetRandomSeed();
}
uint32_t update_strip_time;
void loop()
{
@@ -33,6 +34,18 @@ void loop()
strip.Show();
delay(31); // ~30hz change cycle
}
if ( (millis() - update_strip_time > 30) ) {
strip.UpdateAnimations();
strip.Show(); // takes 6ms with 200, take 12ms with 400 ----> so 100 takes 3ms.
// one LED takes 30uS of nointeruppts, 100 takes 3ms.
update_strip_time = millis();
}
strip.FillUart();
}