forked from Makuna/NeoPixelBus
avr tested
This commit is contained in:
@@ -131,11 +131,7 @@ public:
|
|||||||
|
|
||||||
~NeoPixelBus()
|
~NeoPixelBus()
|
||||||
{
|
{
|
||||||
#if defined(NEOPIXEBUS_NO_ARRAY_NEW)
|
|
||||||
free(_pixels);
|
|
||||||
#else
|
|
||||||
delete[] _pixels;
|
delete[] _pixels;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -356,11 +352,7 @@ protected:
|
|||||||
|
|
||||||
void _initialize()
|
void _initialize()
|
||||||
{
|
{
|
||||||
#if defined(NEOPIXEBUS_NO_ARRAY_NEW)
|
|
||||||
_pixels = static_cast<T_EXPOSED_COLOR_OBJECT*>(malloc(_countPixels * sizeof(T_EXPOSED_COLOR_OBJECT)));
|
|
||||||
#else
|
|
||||||
_pixels = new T_EXPOSED_COLOR_OBJECT[_countPixels];
|
_pixels = new T_EXPOSED_COLOR_OBJECT[_countPixels];
|
||||||
#endif
|
|
||||||
ClearTo(0);
|
ClearTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,11 +408,11 @@ protected:
|
|||||||
|
|
||||||
void _shiftRight(uint16_t shiftCount, uint16_t first, uint16_t last)
|
void _shiftRight(uint16_t shiftCount, uint16_t first, uint16_t last)
|
||||||
{
|
{
|
||||||
uint16_t front = last - shiftCount;
|
uint16_t back = last - shiftCount;
|
||||||
|
|
||||||
while (first <= last)
|
while (first < last)
|
||||||
{
|
{
|
||||||
_pixels[last--] = _pixels[front--];
|
_pixels[last--] = _pixels[back--];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
40
src/internal/NeoUtil.cpp
Normal file
40
src/internal/NeoUtil.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoPixel library helper functions
|
||||||
|
|
||||||
|
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
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "NeoUtil.h"
|
||||||
|
|
||||||
|
#if defined(NEOPIXEBUS_NO_ARRAY_NEW)
|
||||||
|
void* operator new[](size_t size)
|
||||||
|
{
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete[](void* ptr)
|
||||||
|
{
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
#endif
|
@@ -57,6 +57,7 @@ License along with NeoPixel. If not, see
|
|||||||
#if defined(ARDUINO_AVR_DIGISPARK) || \
|
#if defined(ARDUINO_AVR_DIGISPARK) || \
|
||||||
defined(ARDUINO_AVR_DIGISPARKPRO)
|
defined(ARDUINO_AVR_DIGISPARKPRO)
|
||||||
#define NEOPIXEBUS_NO_ARRAY_NEW 1
|
#define NEOPIXEBUS_NO_ARRAY_NEW 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// some platforms do not define this standard progmem type for some reason
|
// some platforms do not define this standard progmem type for some reason
|
||||||
|
@@ -235,14 +235,15 @@ public:
|
|||||||
const T_COLOR_OBJECT* pixelEnd = pixel + countPixels;
|
const T_COLOR_OBJECT* pixelEnd = pixel + countPixels;
|
||||||
uint16_t stripCount = _pixelCount;
|
uint16_t stripCount = _pixelCount;
|
||||||
|
|
||||||
while (--stripCount)
|
while (stripCount--)
|
||||||
{
|
{
|
||||||
typename T_COLOR_FEATURE::ColorObject color = shader.Apply(*pixel);
|
typename T_COLOR_FEATURE::ColorObject color = shader.Apply(*pixel);
|
||||||
T_COLOR_FEATURE::applyPixelColor(sendData, T_COLOR_FEATURE::PixelSize, color);
|
T_COLOR_FEATURE::applyPixelColor(sendData, sendDataSize, color);
|
||||||
|
|
||||||
T_SPEED::send_data(sendData, T_COLOR_FEATURE::PixelSize, _port, _pinMask);
|
T_SPEED::send_data(sendData, T_COLOR_FEATURE::PixelSize, _port, _pinMask);
|
||||||
|
|
||||||
if (++pixel == pixelEnd)
|
pixel++;
|
||||||
|
if (pixel >= pixelEnd)
|
||||||
{
|
{
|
||||||
// restart at first
|
// restart at first
|
||||||
pixel = pixels;
|
pixel = pixels;
|
||||||
|
Reference in New Issue
Block a user