Serial Wombat Arduino Library
SerialWombatWS2812.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 Copyright 2021 Broadwell Consulting Inc.
4 
5 Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11 
12 The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14 
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #include <stdint.h>
24 #include "SerialWombat.h"
25 
26 
31 };
32 
86 
88 {
89 public:
92  SerialWombatWS2812(SerialWombatChip& serialWombat);
93 
108  int16_t begin(uint8_t pin, uint8_t numberOfLEDs, uint16_t userBufferIndex);
113  int16_t write(uint8_t led, uint32_t color);
114 
116  int16_t write(uint8_t led, int16_t color);
118  int16_t write(uint8_t led, int32_t color);
119 
126  int16_t write(uint8_t led, uint8_t length, uint32_t colors[]);
133  int16_t writeAnimationLED(uint8_t frame, uint8_t led, uint32_t color);
135  int16_t writeAnimationLED(uint8_t frame, uint8_t led, int16_t color);
137  int16_t writeAnimationLED(uint8_t frame, uint8_t led, int32_t color);
143  int16_t writeAnimationFrame(uint8_t frame, uint32_t colors[]);
148  int16_t writeAnimationFrameDelay(uint8_t frame, uint16_t delay_mS);
149 
155  int16_t writeAnimationUserBufferIndex(uint16_t index, uint8_t numberOfFrames);
156 
161  int16_t readBufferSize();
162 
163 
166  int16_t writeMode(SWWS2812Mode mode);
167 
175  int16_t barGraph(uint8_t sourcePin, uint32_t offRGB, uint32_t onRGB, uint16_t min, uint16_t max);
176 private:
177  uint8_t _numLEDS = 0;
178  uint16_t _userBufferIndex=0;
179 };
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:272
ws2812ModeChase
@ ws2812ModeChase
A single lit LED cycles through all of the LEDs.
Definition: SerialWombatWS2812.h:30
SWWS2812Mode
SWWS2812Mode
Definition: SerialWombatWS2812.h:27
ws2812ModeBuffered
@ ws2812ModeBuffered
Standard buffered mode. Colors are uploaded by the host.
Definition: SerialWombatWS2812.h:28
SerialWombatWS2812::writeAnimationLED
int16_t writeAnimationLED(uint8_t frame, uint8_t led, uint32_t color)
set the color of one LED in an animation frame
Definition: SerialWombatWS2812.cpp:51
SerialWombatWS2812::write
int16_t write(uint8_t led, uint32_t color)
Set an LED color.
Definition: SerialWombatWS2812.cpp:18
SerialWombatWS2812::barGraph
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.
Definition: SerialWombatWS2812.cpp:118
SerialWombat.h
SerialWombatWS2812::writeAnimationUserBufferIndex
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
Definition: SerialWombatWS2812.cpp:88
SerialWombatWS2812::writeAnimationFrame
int16_t writeAnimationFrame(uint8_t frame, uint32_t colors[])
Store an array of colors for an entire animation frame.
Definition: SerialWombatWS2812.cpp:67
ws2812ModeAnimation
@ ws2812ModeAnimation
Multiple arrays with delays are uploaded by the host and displayed over time by the Serial Wombat chi...
Definition: SerialWombatWS2812.h:29
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombat.h:799
SerialWombatWS2812::SerialWombatWS2812
SerialWombatWS2812(SerialWombatChip &serialWombat)
Constructor for SerialWombatWS2812 class.
Definition: SerialWombatWS2812.cpp:4
SerialWombatWS2812
A Class representing a WS2812 or compatible RGB LED string connected to a Serial Wombat pin.
Definition: SerialWombatWS2812.h:87
SerialWombatPin::pin
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
Definition: SerialWombat.h:861
SerialWombatWS2812::writeMode
int16_t writeMode(SWWS2812Mode mode)
Sets the mode of the WS2812 LED Driver.
Definition: SerialWombatWS2812.cpp:112
SerialWombatWS2812::readBufferSize
int16_t readBufferSize()
returns the number of bytes of UserBuffer required to service the configured number of LEDs
Definition: SerialWombatWS2812.cpp:94
SerialWombatWS2812::begin
int16_t begin(uint8_t pin, uint8_t numberOfLEDs, uint16_t userBufferIndex)
Initialize a WS2812 LED driver object.
Definition: SerialWombatWS2812.cpp:8
SerialWombatWS2812::writeAnimationFrameDelay
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.
Definition: SerialWombatWS2812.cpp:82