115 int16_t
begin(uint8_t
pin, uint8_t numberOfLEDs, uint16_t userBufferIndex)
118 _numLEDS = numberOfLEDs;
119 _userBufferIndex = userBufferIndex;
121 uint8_t tx[8] = { 200,
_pin,12,
SW_LE16(userBufferIndex),_numLEDS,0x55 };
122 return (
_sw.sendPacket(tx));
131 int16_t
write(uint8_t led, uint32_t color)
133 uint8_t tx[8] = { 201,
_pin,12,led,
SW_LE32(color) };
141 return _sw.sendPacket(tx);
145 int16_t
write(uint8_t led, int16_t color)
147 return write(led, (uint32_t)color);
151 int16_t
write(uint8_t led, int32_t color)
153 return write(led, (uint32_t)color);
159 return write((uint8_t)led, (uint32_t)color);
170 int16_t
write(uint8_t led, uint8_t length, uint32_t colors[])
172 for (
int i = 0; i < length; ++i)
175 write((uint8_t)(led + i),(uint32_t) colors[i]);
196 uint8_t tx[8] = { 203,
_pin,12,frame,led,(uint8_t)((color >>16 ) & 0xFF),(uint8_t)((color >> 8) & 0xFF),(uint8_t)( color & 0xFF) };
197 return _sw.sendPacket(tx);
221 for (
int i = 0; i < _numLEDS; ++i)
242 uint8_t tx[8] = { 205,
_pin,12,frame,
SW_LE16(delay_mS),0x55,0x55 };
243 return (
_sw.sendPacket(tx));
255 uint8_t tx[8] = { 204,
_pin,12,
SW_LE16(index),numberOfFrames,0x55,0x55 };
256 return (
_sw.sendPacket(tx));
267 uint8_t tx[8] = { 202,
_pin,12,_numLEDS,0x55,0x55,0x55,0x55 };
269 int16_t result =
_sw.sendPacket(tx,rx);
272 return (rx[3] + rx[4] * 256);
289 uint8_t tx[8] = { 206,
_pin,12,(uint8_t)mode,0x55,0x55,0x55,0x55 };
290 return _sw.sendPacket(tx);
302 int16_t
barGraph(uint8_t sourcePin, uint32_t offRGB, uint32_t onRGB, uint16_t min, uint16_t max)
304 uint8_t tx[8] = { 206,
_pin,12,3,sourcePin,0x55,0x55,0x55 };
306 result =
_sw.sendPacket(tx);
if (result < 0) {
return result; }
307 result =
write((uint8_t)0,(uint32_t) offRGB);
if (result < 0) {
return result; }
308 result =
write((uint8_t)1, (uint32_t)onRGB);
if (result < 0) {
return result; }
311 return _sw.sendPacket(minMax);
327 return barGraph((uint8_t) sourcePin, offRGB, onRGB, min, max);
334 uint8_t _numLEDS = 0;
335 uint16_t _userBufferIndex=0;
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
#define SW_LE32(_a)
Convert a uint32_t to four bytes in little endian format for array initialization.
SerialWombatDataSource
A list of Serial Wombat public data sources.
@ ws2812ModeAnimation
Multiple arrays with delays are uploaded by the host and displayed over time by the Serial Wombat chi...
@ ws2812ModeBuffered
Standard buffered mode. Colors are uploaded by the host.
@ ws2812ModeChase
A single lit LED cycles through all of the LEDs.
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
int16_t writeAnimationLED(uint8_t frame, uint8_t led, int32_t color)
An overload color is interpreted as an int32_t rather than uint32_t.
int16_t write(uint8_t led, int16_t color)
An overload for Write in case write(x,0); is interpreted as an int16_t rather than uint32_t.
SerialWombatWS2812(SerialWombatChip &serialWombat)
Constructor for SerialWombatWS2812 class.
int16_t writeAnimationUserBufferIndex(uint16_t index, uint8_t numberOfFrames)
set the location in UserBuffer where the animation array will be stored and number of frames
int16_t writeAnimationLED(uint8_t frame, uint8_t led, int16_t color)
An overload color is interpreted as an int16_t rather than uint32_t.
int16_t write(int led, int color)
An overload for Write in case write(x,0); is interpreted as an int32_t rather than uint32_t.
bool swapRG
Swap the Red and Green byte values. Set this to true for WS2811 chips which reverse the red and green...
int16_t write(uint8_t led, uint8_t length, uint32_t colors[])
int16_t barGraph(SerialWombatDataSource sourcePin, uint32_t offRGB, uint32_t onRGB, uint16_t min, uint16_t max)
Display a bargraph using the configured ws2812 class.
int16_t writeAnimationFrame(uint8_t frame, uint32_t colors[])
Store an array of colors for an entire animation frame.
int16_t readBufferSize()
returns the number of bytes of UserBuffer required to service the configured number of LEDs
int16_t writeMode(SWWS2812Mode mode)
Sets the mode of the WS2812 LED Driver.
int16_t write(uint8_t led, uint32_t color)
Set an LED color.
int16_t barGraph(uint8_t sourcePin, uint32_t offRGB, uint32_t onRGB, uint16_t min, uint16_t max)
Display a bargraph using the configured ws2812 class.
int16_t begin(uint8_t pin, uint8_t numberOfLEDs, uint16_t userBufferIndex)
Initialize a WS2812 LED driver object.
int16_t write(uint8_t led, int32_t color)
An overload for Write in case write(x,0); is interpreted as an int32_t rather than uint32_t.
int16_t writeAnimationLED(uint8_t frame, uint8_t led, uint32_t color)
int16_t writeAnimationFrameDelay(uint8_t frame, uint16_t delay_mS)
Set how long an animation frame should be displayed before moving to the next frame.