|
| 1 | +package frc.robot.controllers; |
| 2 | + |
| 3 | +import edu.wpi.first.wpilibj.util.Color; |
| 4 | +import edu.wpi.first.wpilibj.util.Color8Bit; |
| 5 | + |
| 6 | +public class ControllerCommandFactory { |
| 7 | + public static byte[] setLEDRGB(int index, int r, int g, int b) { |
| 8 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Single, (byte) index, ControllerDataProtocol.LightingValue.LedBaseColor, (byte) r, (byte) g, (byte) b}; |
| 9 | + } |
| 10 | + |
| 11 | + public static byte[] setLEDBaseColor(int index, Color8Bit color) { |
| 12 | + return setLEDRGB(index, color.red, color.green, color.blue); |
| 13 | + } |
| 14 | + |
| 15 | + public static byte[] setLEDBaseColor(int index, Color color) { |
| 16 | + return setLEDBaseColor(index, new Color8Bit(color)); |
| 17 | + } |
| 18 | + |
| 19 | + public static byte[] setLEDHSB(int index, float h, float s, float b) { |
| 20 | + java.awt.Color outColor = java.awt.Color.getHSBColor(h, s, b); |
| 21 | + return setLEDRGB(index, outColor.getRed(), outColor.getGreen(), outColor.getBlue()); |
| 22 | + } |
| 23 | + |
| 24 | + public static byte[] setLEDHSB(int index, int h, int s, int b) { |
| 25 | + return setLEDHSB(index, h/360f, s/255f, b/255f); |
| 26 | + } |
| 27 | + |
| 28 | + public static byte[] setLEDRangeRGB(int startLED, int endLED, int r, int g, int b) { |
| 29 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Multiple, (byte) startLED, (byte) endLED, ControllerDataProtocol.LightingValue.LedBaseColor, (byte) r, (byte) g, (byte) b}; |
| 30 | + } |
| 31 | + |
| 32 | + public static byte[] setLEDRangeBaseColor(int startLED, int endLED, Color8Bit color) { |
| 33 | + return setLEDRangeRGB(startLED, endLED, color.red, color.green, color.blue); |
| 34 | + } |
| 35 | + |
| 36 | + public static byte[] setLEDRangeBaseColor(int startLED, int endLED, Color color) { |
| 37 | + return setLEDRangeBaseColor(startLED, endLED, new Color8Bit(color)); |
| 38 | + } |
| 39 | + |
| 40 | + public static byte[] setLEDRangeHSB(int startLED, int endLED, float h, float s, float b) { |
| 41 | + java.awt.Color outColor = java.awt.Color.getHSBColor(h, s, b); |
| 42 | + return setLEDRangeRGB(startLED, endLED, outColor.getRed(), outColor.getGreen(), outColor.getBlue()); |
| 43 | + } |
| 44 | + |
| 45 | + public static byte[] setLEDRangeHSB(int startLED, int endLED, int h, int s, int b) { |
| 46 | + return setLEDRangeHSB(startLED, endLED, h/360f, s/255f, b/255f); |
| 47 | + } |
| 48 | + |
| 49 | + public static byte[] setLEDSectionRGB(int section, int r, int g, int b) { |
| 50 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Section, (byte) section, ControllerDataProtocol.LightingValue.LedBaseColor, (byte) r, (byte) g, (byte) b}; |
| 51 | + } |
| 52 | + |
| 53 | + public static byte[] setLEDSectionBaseColor(int section, Color8Bit color) { |
| 54 | + return setLEDSectionRGB(section, color.red, color.green, color.blue); |
| 55 | + } |
| 56 | + |
| 57 | + public static byte[] setLEDSectionBaseColor(int section, Color color) { |
| 58 | + return setLEDSectionBaseColor(section, new Color8Bit(color)); |
| 59 | + } |
| 60 | + |
| 61 | + public static byte[] setLEDSectionHSB(int section, float h, float s, float b) { |
| 62 | + java.awt.Color outColor = java.awt.Color.getHSBColor(h, s, b); |
| 63 | + return setLEDSectionRGB(section, outColor.getRed(), outColor.getGreen(), outColor.getBlue()); |
| 64 | + } |
| 65 | + |
| 66 | + public static byte[] setLEDSectionHSB(int section, int h, int s, int b) { |
| 67 | + return setLEDSectionHSB(section, h/360f, s/255f, b/255f); |
| 68 | + } |
| 69 | + |
| 70 | + public static byte[] setAllLEDRGB(int r, int g, int b) { |
| 71 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.All, ControllerDataProtocol.LightingValue.LedBaseColor, (byte) r, (byte) g, (byte) b}; |
| 72 | + } |
| 73 | + |
| 74 | + public static byte[] setAllLEDBaseColor(Color8Bit color) { |
| 75 | + return setAllLEDRGB(color.red, color.green, color.blue); |
| 76 | + } |
| 77 | + |
| 78 | + public static byte[] setAllLEDBaseColor(Color color) { |
| 79 | + return setAllLEDBaseColor(new Color8Bit(color)); |
| 80 | + } |
| 81 | + |
| 82 | + public static byte[] setAllLEDHSB(float h, float s, float b) { |
| 83 | + java.awt.Color outColor = java.awt.Color.getHSBColor(h, s, b); |
| 84 | + return setAllLEDRGB(outColor.getRed(), outColor.getGreen(), outColor.getBlue()); |
| 85 | + } |
| 86 | + |
| 87 | + public static byte[] setAllLEDHSB(int h, int s, int b) { |
| 88 | + return setAllLEDHSB(h/360f, s/255f, b/255f); |
| 89 | + } |
| 90 | + |
| 91 | + |
| 92 | + public static byte[] setLEDEffect(int index, int effect) { |
| 93 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Single, (byte) index, ControllerDataProtocol.LightingValue.LedEffect, (byte) effect}; |
| 94 | + } |
| 95 | + |
| 96 | + public static byte[] setLEDRangeEffect(int startLED, int endLED, int effect) { |
| 97 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Multiple, (byte) startLED, (byte) endLED, ControllerDataProtocol.LightingValue.LedEffect, (byte) effect}; |
| 98 | + } |
| 99 | + |
| 100 | + public static byte[] setLEDSectionEffect(int section, int effect) { |
| 101 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Section, (byte) section, ControllerDataProtocol.LightingValue.LedEffect, (byte) effect}; |
| 102 | + } |
| 103 | + |
| 104 | + public static byte[] setAllLEDEffect(int effect) { |
| 105 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.All, ControllerDataProtocol.LightingValue.LedEffect, (byte) effect}; |
| 106 | + } |
| 107 | + |
| 108 | + public static byte[] setLEDRangeEffectSpaced(int startLED, int endLED, int effect) { |
| 109 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Multiple, (byte) startLED, (byte) endLED, ControllerDataProtocol.LightingValue.LedEffectSpaced, (byte) effect}; |
| 110 | + } |
| 111 | + |
| 112 | + public static byte[] setLEDSectionEffectSpaced(int section, int effect) { |
| 113 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Section, (byte) section, ControllerDataProtocol.LightingValue.LedEffectSpaced, (byte) effect}; |
| 114 | + } |
| 115 | + |
| 116 | + public static byte[] setAllLEDEffectSpaced(int effect) { |
| 117 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.All, ControllerDataProtocol.LightingValue.LedEffectSpaced, (byte) effect}; |
| 118 | + } |
| 119 | + |
| 120 | + |
| 121 | + public static byte[] setLEDOffset(int index, int offset) { |
| 122 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Single, (byte) index, ControllerDataProtocol.LightingValue.LedOffset, (byte) offset}; |
| 123 | + } |
| 124 | + |
| 125 | + public static byte[] setLEDRangeOffset(int startLED, int endLED, int offset) { |
| 126 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Multiple, (byte) startLED, (byte) endLED, ControllerDataProtocol.LightingValue.LedOffset, (byte) offset}; |
| 127 | + } |
| 128 | + |
| 129 | + public static byte[] setLEDSectionOffset(int section, int offset) { |
| 130 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Section, (byte) section, ControllerDataProtocol.LightingValue.LedOffset, (byte) offset}; |
| 131 | + } |
| 132 | + |
| 133 | + public static byte[] setAllLEDOffset(int offset) { |
| 134 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.All, ControllerDataProtocol.LightingValue.LedOffset, (byte) offset}; |
| 135 | + } |
| 136 | + |
| 137 | + |
| 138 | + public static byte[] setLEDSpeed(int index, int speed) { |
| 139 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Single, (byte) index, ControllerDataProtocol.LightingValue.LedSpeed, (byte) speed}; |
| 140 | + } |
| 141 | + |
| 142 | + public static byte[] setLEDRangeSpeed(int startLED, int endLED, int speed) { |
| 143 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Multiple, (byte) startLED, (byte) endLED, ControllerDataProtocol.LightingValue.LedSpeed, (byte) speed}; |
| 144 | + } |
| 145 | + |
| 146 | + public static byte[] setLEDSectionSpeed(int section, int speed) { |
| 147 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Section, (byte) section, ControllerDataProtocol.LightingValue.LedSpeed, (byte) speed}; |
| 148 | + } |
| 149 | + |
| 150 | + public static byte[] setAllLEDSpeed(int speed) { |
| 151 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.All, ControllerDataProtocol.LightingValue.LedSpeed, (byte) speed}; |
| 152 | + } |
| 153 | + |
| 154 | + |
| 155 | + public static byte[] setLEDBrightness(int index, int brightness) { |
| 156 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Single, (byte) index, ControllerDataProtocol.LightingValue.LedBrightness, (byte) brightness}; |
| 157 | + } |
| 158 | + |
| 159 | + public static byte[] setLEDRangeBrightness(int startLED, int endLED, int brightness) { |
| 160 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Multiple, (byte) startLED, (byte) endLED, ControllerDataProtocol.LightingValue.LedBrightness, (byte) brightness}; |
| 161 | + } |
| 162 | + |
| 163 | + public static byte[] setLEDSectionBrightness(int section, int brightness) { |
| 164 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.Section, (byte) section, ControllerDataProtocol.LightingValue.LedBrightness, (byte) brightness}; |
| 165 | + } |
| 166 | + |
| 167 | + public static byte[] setAllLEDBrightness(int brightness) { |
| 168 | + return new byte[] {ControllerDataProtocol.CommandID.SetLed, ControllerDataProtocol.LightingSelection.All, ControllerDataProtocol.LightingValue.LedBrightness, (byte) brightness}; |
| 169 | + } |
| 170 | +} |
0 commit comments