Add Color classes for use with AddressableLED (#2127)

Both floating point and 8-bit integer classes are included, as well as a wide selection of color constants.

Co-authored-by: Austin Shalit <austinshalit@gmail.com>
This commit is contained in:
Prateek Machiraju
2019-12-30 01:01:20 -05:00
committed by Peter Johnson
parent 96348e835a
commit e874ba9313
7 changed files with 1938 additions and 6 deletions

View File

@@ -15,6 +15,8 @@
#include <wpi/ArrayRef.h>
#include "frc/ErrorBase.h"
#include "util/Color.h"
#include "util/Color8Bit.h"
namespace frc {
@@ -54,6 +56,28 @@ class AddressableLED : public ErrorBase {
* @param v the v value [0-255]
*/
void SetHSV(int h, int s, int v);
/*
* Sets a specific LED in the buffer.
*
* @param color The color of the LED
*/
void SetLED(const Color& color) {
this->r = color.red * 255;
this->g = color.green * 255;
this->b = color.blue * 255;
}
/*
* Sets a specific LED in the buffer.
*
* @param color The color of the LED
*/
void SetLED(const Color8Bit& color) {
this->r = color.red;
this->g = color.green;
this->b = color.blue;
}
};
/**