mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Rename LEDPattern constants to all caps
This commit is contained in:
@@ -297,10 +297,10 @@ LEDPattern LEDPattern::Gradient(GradientType type,
|
||||
auto bufLen = data.size();
|
||||
int ledsPerSegment = 0;
|
||||
switch (type) {
|
||||
case kContinuous:
|
||||
case GradientType::CONTINUOUS:
|
||||
ledsPerSegment = bufLen / numSegments;
|
||||
break;
|
||||
case kDiscontinuous:
|
||||
case GradientType::DISCONTINUOUS:
|
||||
ledsPerSegment = (bufLen - 1) / (numSegments - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -341,19 +341,19 @@ class LEDPattern {
|
||||
std::initializer_list<std::pair<double, wpi::util::Color>> steps);
|
||||
|
||||
/** Types of gradients. */
|
||||
enum GradientType {
|
||||
enum class GradientType {
|
||||
/**
|
||||
* A continuous gradient, where the gradient wraps around to allow for
|
||||
* seamless scrolling effects.
|
||||
*/
|
||||
kContinuous,
|
||||
CONTINUOUS,
|
||||
/**
|
||||
* A discontinuous gradient, where the first pixel is set to the first color
|
||||
* of the gradient and the final pixel is set to the last color of the
|
||||
* gradient. There is no wrapping effect, so scrolling effects will display
|
||||
* an obvious seam.
|
||||
*/
|
||||
kDiscontinuous
|
||||
DISCONTINUOUS
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ TEST(LEDPatternTest, SolidColor) {
|
||||
TEST(LEDPatternTest, EmptyGradientSetsToBlack) {
|
||||
std::array<wpi::util::Color, 0> colors;
|
||||
LEDPattern pattern =
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::kContinuous, colors);
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::CONTINUOUS, colors);
|
||||
std::array<AddressableLED::LEDData, 5> buffer;
|
||||
pattern.ApplyTo(buffer);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -61,7 +61,7 @@ TEST(LEDPatternTest, EmptyGradientSetsToBlack) {
|
||||
TEST(LEDPatternTest, SingleColorGradientSetsSolid) {
|
||||
std::array<wpi::util::Color, 1> colors{wpi::util::Color::YELLOW};
|
||||
LEDPattern pattern =
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::kContinuous, colors);
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::CONTINUOUS, colors);
|
||||
std::array<AddressableLED::LEDData, 5> buffer;
|
||||
pattern.ApplyTo(buffer);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -73,7 +73,7 @@ TEST(LEDPatternTest, Gradient2Colors) {
|
||||
std::array<wpi::util::Color, 2> colors{wpi::util::Color::YELLOW,
|
||||
wpi::util::Color::PURPLE};
|
||||
LEDPattern pattern =
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::kContinuous, colors);
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::CONTINUOUS, colors);
|
||||
std::array<AddressableLED::LEDData, 99> buffer;
|
||||
pattern.ApplyTo(buffer);
|
||||
AssertIndexColor(buffer, 0, wpi::util::Color::YELLOW);
|
||||
@@ -91,7 +91,7 @@ TEST(LEDPatternTest, DiscontinuousGradient2Colors) {
|
||||
std::array<wpi::util::Color, 2> colors{wpi::util::Color::YELLOW,
|
||||
wpi::util::Color::PURPLE};
|
||||
LEDPattern pattern =
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::kDiscontinuous, colors);
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::DISCONTINUOUS, colors);
|
||||
std::array<AddressableLED::LEDData, 99> buffer;
|
||||
pattern.ApplyTo(buffer);
|
||||
AssertIndexColor(buffer, 0, wpi::util::Color::YELLOW);
|
||||
@@ -106,7 +106,7 @@ TEST(LEDPatternTest, Gradient3Colors) {
|
||||
wpi::util::Color::PURPLE,
|
||||
wpi::util::Color::WHITE};
|
||||
LEDPattern pattern =
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::kContinuous, colors);
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::CONTINUOUS, colors);
|
||||
std::array<AddressableLED::LEDData, 99> buffer;
|
||||
pattern.ApplyTo(buffer);
|
||||
|
||||
@@ -132,7 +132,7 @@ TEST(LEDPatternTest, DiscontinuousGradient3Colors) {
|
||||
wpi::util::Color::PURPLE,
|
||||
wpi::util::Color::WHITE};
|
||||
LEDPattern pattern =
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::kDiscontinuous, colors);
|
||||
LEDPattern::Gradient(LEDPattern::GradientType::DISCONTINUOUS, colors);
|
||||
std::array<AddressableLED::LEDData, 101> buffer;
|
||||
pattern.ApplyTo(buffer);
|
||||
|
||||
|
||||
@@ -612,14 +612,14 @@ public interface LEDPattern {
|
||||
* A continuous gradient, where the gradient wraps around to allow for seamless scrolling
|
||||
* effects.
|
||||
*/
|
||||
kContinuous,
|
||||
CONTINUOUS,
|
||||
|
||||
/**
|
||||
* A discontinuous gradient, where the first pixel is set to the first color of the gradient and
|
||||
* the final pixel is set to the last color of the gradient. There is no wrapping effect, so
|
||||
* scrolling effects will display an obvious seam.
|
||||
*/
|
||||
kDiscontinuous
|
||||
DISCONTINUOUS
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -654,8 +654,8 @@ public interface LEDPattern {
|
||||
int bufLen = reader.getLength();
|
||||
int ledsPerSegment =
|
||||
switch (type) {
|
||||
case kContinuous -> bufLen / numSegments;
|
||||
case kDiscontinuous -> (bufLen - 1) / (numSegments - 1);
|
||||
case CONTINUOUS -> bufLen / numSegments;
|
||||
case DISCONTINUOUS -> (bufLen - 1) / (numSegments - 1);
|
||||
};
|
||||
|
||||
for (int led = 0; led < bufLen; led++) {
|
||||
|
||||
@@ -6,8 +6,8 @@ package org.wpilib.hardware.led;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.wpilib.hardware.led.LEDPattern.GradientType.kContinuous;
|
||||
import static org.wpilib.hardware.led.LEDPattern.GradientType.kDiscontinuous;
|
||||
import static org.wpilib.hardware.led.LEDPattern.GradientType.CONTINUOUS;
|
||||
import static org.wpilib.hardware.led.LEDPattern.GradientType.DISCONTINUOUS;
|
||||
import static org.wpilib.units.Units.Centimeters;
|
||||
import static org.wpilib.units.Units.Meters;
|
||||
import static org.wpilib.units.Units.MetersPerSecond;
|
||||
@@ -86,7 +86,7 @@ class LEDPatternTest {
|
||||
|
||||
@Test
|
||||
void gradient0SetsToBlack() {
|
||||
LEDPattern pattern = LEDPattern.gradient(kContinuous);
|
||||
LEDPattern pattern = LEDPattern.gradient(CONTINUOUS);
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(99);
|
||||
for (int i = 0; i < buffer.getLength(); i++) {
|
||||
buffer.setRGB(i, 127, 128, 129);
|
||||
@@ -101,7 +101,7 @@ class LEDPatternTest {
|
||||
|
||||
@Test
|
||||
void gradient1SetsToSolid() {
|
||||
LEDPattern pattern = LEDPattern.gradient(kContinuous, YELLOW);
|
||||
LEDPattern pattern = LEDPattern.gradient(CONTINUOUS, YELLOW);
|
||||
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(99);
|
||||
pattern.applyTo(buffer);
|
||||
@@ -113,7 +113,7 @@ class LEDPatternTest {
|
||||
|
||||
@Test
|
||||
void continuousGradient2Colors() {
|
||||
LEDPattern pattern = LEDPattern.gradient(kContinuous, YELLOW, PURPLE);
|
||||
LEDPattern pattern = LEDPattern.gradient(CONTINUOUS, YELLOW, PURPLE);
|
||||
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(99);
|
||||
pattern.applyTo(buffer);
|
||||
@@ -127,7 +127,7 @@ class LEDPatternTest {
|
||||
|
||||
@Test
|
||||
void discontinuousGradient2Colors() {
|
||||
LEDPattern pattern = LEDPattern.gradient(kDiscontinuous, YELLOW, PURPLE);
|
||||
LEDPattern pattern = LEDPattern.gradient(DISCONTINUOUS, YELLOW, PURPLE);
|
||||
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(99);
|
||||
pattern.applyTo(buffer);
|
||||
@@ -139,7 +139,7 @@ class LEDPatternTest {
|
||||
|
||||
@Test
|
||||
void gradient3Colors() {
|
||||
LEDPattern pattern = LEDPattern.gradient(kContinuous, YELLOW, PURPLE, WHITE);
|
||||
LEDPattern pattern = LEDPattern.gradient(CONTINUOUS, YELLOW, PURPLE, WHITE);
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(99);
|
||||
pattern.applyTo(buffer);
|
||||
|
||||
@@ -154,7 +154,7 @@ class LEDPatternTest {
|
||||
|
||||
@Test
|
||||
void discontinuousGradient3Colors() {
|
||||
LEDPattern pattern = LEDPattern.gradient(kDiscontinuous, YELLOW, PURPLE, WHITE);
|
||||
LEDPattern pattern = LEDPattern.gradient(DISCONTINUOUS, YELLOW, PURPLE, WHITE);
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(101);
|
||||
pattern.applyTo(buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user