mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add methods for getting color of an LED (#2366)
Also fix rounding in Color.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,12 +9,17 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import edu.wpi.first.wpilibj.util.Color;
|
||||
import edu.wpi.first.wpilibj.util.Color8Bit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
class AddressableLEDBufferTest {
|
||||
@@ -51,4 +56,26 @@ class AddressableLEDBufferTest {
|
||||
arguments(120, 255, 128, 0, 0, 128) // Navy
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getColorTest() {
|
||||
AddressableLEDBuffer buffer = new AddressableLEDBuffer(4);
|
||||
final Color8Bit denimColor8Bit = new Color8Bit(Color.kDenim);
|
||||
final Color8Bit firstBlueColor8Bit = new Color8Bit(Color.kFirstBlue);
|
||||
final Color8Bit firstRedColor8Bit = new Color8Bit(Color.kFirstRed);
|
||||
|
||||
buffer.setLED(0, Color.kFirstBlue);
|
||||
buffer.setLED(1, denimColor8Bit);
|
||||
buffer.setLED(2, Color.kFirstRed);
|
||||
buffer.setLED(3, Color.kFirstBlue);
|
||||
|
||||
assertTrue(buffer.getLED(0).equals(Color.kFirstBlue));
|
||||
assertTrue(buffer.getLED(1).equals(Color.kDenim));
|
||||
assertTrue(buffer.getLED(2).equals(Color.kFirstRed));
|
||||
assertTrue(buffer.getLED(3).equals(Color.kFirstBlue));
|
||||
assertTrue(buffer.getLED8Bit(0).equals(firstBlueColor8Bit));
|
||||
assertTrue(buffer.getLED8Bit(1).equals(denimColor8Bit));
|
||||
assertTrue(buffer.getLED8Bit(2).equals(firstRedColor8Bit));
|
||||
assertTrue(buffer.getLED8Bit(3).equals(firstBlueColor8Bit));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user