001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.wpilibj.shuffleboard; 006 007import edu.wpi.first.wpilibj.interfaces.Accelerometer.Range; 008 009/** 010 * The types of the widgets bundled with Shuffleboard. 011 * 012 * <p>For example, setting a number to be displayed with a slider: 013 * 014 * <pre>{@code 015 * NetworkTableEntry example = Shuffleboard.getTab("My Tab") 016 * .add("My Number", 0) 017 * .withWidget(BuiltInWidgets.kNumberSlider) 018 * .withProperties(Map.of("min", 0, "max", 1)) 019 * .getEntry(); 020 * }</pre> 021 * 022 * <p>Each value in this enum goes into detail on what data types that widget can support, as well 023 * as the custom properties that widget uses. 024 */ 025public enum BuiltInWidgets implements WidgetType { 026 /** 027 * Displays a value with a simple text field. <br> 028 * Supported types: 029 * 030 * <ul> 031 * <li>String 032 * <li>Number 033 * <li>Boolean 034 * </ul> 035 * 036 * <br> 037 * This widget has no custom properties. 038 */ 039 kTextView("Text View"), 040 /** 041 * Displays a number with a controllable slider. <br> 042 * Supported types: 043 * 044 * <ul> 045 * <li>Number 046 * </ul> 047 * 048 * <br> 049 * Custom properties: 050 * 051 * <table> 052 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 053 * <tr><td>Min</td><td>Number</td><td>-1.0</td><td>The minimum value of the slider</td></tr> 054 * <tr><td>Max</td><td>Number</td><td>1.0</td><td>The maximum value of the slider</td></tr> 055 * <tr><td>Block increment</td><td>Number</td><td>0.0625</td> 056 * <td>How much to move the slider by with the arrow keys</td></tr> 057 * </table> 058 */ 059 kNumberSlider("Number Slider"), 060 /** 061 * Displays a number with a view-only bar. <br> 062 * Supported types: 063 * 064 * <ul> 065 * <li>Number 066 * </ul> 067 * 068 * <br> 069 * Custom properties: 070 * 071 * <table> 072 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 073 * <tr><td>Min</td><td>Number</td><td>-1.0</td><td>The minimum value of the bar</td></tr> 074 * <tr><td>Max</td><td>Number</td><td>1.0</td><td>The maximum value of the bar</td></tr> 075 * <tr><td>Center</td><td>Number</td><td>0</td><td>The center ("zero") value of the bar</td></tr> 076 * </table> 077 */ 078 kNumberBar("Number Bar"), 079 /** 080 * Displays a number with a view-only dial. Displayed values are rounded to the nearest integer. 081 * <br> 082 * Supported types: 083 * 084 * <ul> 085 * <li>Number 086 * </ul> 087 * 088 * <br> 089 * Custom properties: 090 * 091 * <table> 092 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 093 * <tr><td>Min</td><td>Number</td><td>0</td><td>The minimum value of the dial</td></tr> 094 * <tr><td>Max</td><td>Number</td><td>100</td><td>The maximum value of the dial</td></tr> 095 * <tr><td>Show value</td><td>Boolean</td><td>true</td> 096 * <td>Whether or not to show the value as text</td></tr> 097 * </table> 098 */ 099 kDial("Simple Dial"), 100 /** 101 * Displays a number with a graph. <strong>NOTE:</strong> graphs can be taxing on the computer 102 * running the dashboard. Keep the number of visible data points to a minimum. Making the widget 103 * smaller also helps with performance, but may cause the graph to become difficult to read. <br> 104 * Supported types: 105 * 106 * <ul> 107 * <li>Number 108 * <li>Number array 109 * </ul> 110 * 111 * <br> 112 * Custom properties: 113 * 114 * <table> 115 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 116 * <tr><td>Visible time</td><td>Number</td><td>30</td> 117 * <td>How long, in seconds, should past data be visible for</td></tr> 118 * </table> 119 */ 120 kGraph("Graph"), 121 /** 122 * Displays a boolean value as a large colored box. <br> 123 * Supported types: 124 * 125 * <ul> 126 * <li>Boolean 127 * </ul> 128 * 129 * <br> 130 * Custom properties: 131 * 132 * <table> 133 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 134 * <tr><td>Color when true</td><td>Color</td><td>"green"</td> 135 * <td>Can be specified as a string ({@code "#00FF00"}) or a rgba integer ({@code 0x00FF0000}) 136 * </td></tr> 137 * <tr><td>Color when false</td><td>Color</td><td>"red"</td> 138 * <td>Can be specified as a string or a number</td></tr> 139 * </table> 140 */ 141 kBooleanBox("Boolean Box"), 142 /** 143 * Displays a boolean with a large interactive toggle button. <br> 144 * Supported types: 145 * 146 * <ul> 147 * <li>Boolean 148 * </ul> 149 * 150 * <br> 151 * This widget has no custom properties. 152 */ 153 kToggleButton("Toggle Button"), 154 /** 155 * Displays a boolean with a fixed-size toggle switch. <br> 156 * Supported types: 157 * 158 * <ul> 159 * <li>Boolean 160 * </ul> 161 * 162 * <br> 163 * This widget has no custom properties. 164 */ 165 kToggleSwitch("Toggle Switch"), 166 /** 167 * Displays an analog input or a raw number with a number bar. <br> 168 * Supported types: 169 * 170 * <ul> 171 * <li>Number 172 * <li>{@link edu.wpi.first.wpilibj.AnalogInput} 173 * </ul> 174 * 175 * <br> 176 * Custom properties: 177 * 178 * <table> 179 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 180 * <tr><td>Min</td><td>Number</td><td>0</td><td>The minimum value of the bar</td></tr> 181 * <tr><td>Max</td><td>Number</td><td>5</td><td>The maximum value of the bar</td></tr> 182 * <tr><td>Center</td><td>Number</td><td>0</td><td>The center ("zero") value of the bar</td></tr> 183 * <tr><td>Orientation</td><td>String</td><td>"HORIZONTAL"</td> 184 * <td>The orientation of the bar. One of {@code ["HORIZONTAL", "VERTICAL"]}</td></tr> 185 * <tr><td>Number of tick marks</td><td>Number</td><td>5</td> 186 * <td>The number of discrete ticks on the bar</td></tr> 187 * </table> 188 */ 189 kVoltageView("Voltage View"), 190 /** 191 * Displays a {@link edu.wpi.first.wpilibj.PowerDistribution PowerDistribution}. <br> 192 * Supported types: 193 * 194 * <ul> 195 * <li>{@link edu.wpi.first.wpilibj.PowerDistribution} 196 * </ul> 197 * 198 * <br> 199 * Custom properties: 200 * 201 * <table> 202 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 203 * <tr><td>Show voltage and current values</td><td>Boolean</td><td>true</td> 204 * <td>Whether or not to display the voltage and current draw</td></tr> 205 * </table> 206 */ 207 kPowerDistribution("PDP"), 208 /** 209 * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser SendableChooser} with a 210 * dropdown combo box with a list of options. <br> 211 * Supported types: 212 * 213 * <ul> 214 * <li>{@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser} 215 * </ul> 216 * 217 * <br> 218 * This widget has no custom properties. 219 */ 220 kComboBoxChooser("ComboBox Chooser"), 221 /** 222 * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser SendableChooser} with a 223 * toggle button for each available option. <br> 224 * Supported types: 225 * 226 * <ul> 227 * <li>{@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser} 228 * </ul> 229 * 230 * <br> 231 * This widget has no custom properties. 232 */ 233 kSplitButtonChooser("Split Button Chooser"), 234 /** 235 * Displays an {@link edu.wpi.first.wpilibj.Encoder} displaying its speed, total traveled 236 * distance, and its distance per tick. <br> 237 * Supported types: 238 * 239 * <ul> 240 * <li>{@link edu.wpi.first.wpilibj.Encoder} 241 * </ul> 242 * 243 * <br> 244 * This widget has no custom properties. 245 */ 246 kEncoder("Encoder"), 247 /** 248 * Displays a {@link edu.wpi.first.wpilibj.motorcontrol.MotorController MotorController}. The 249 * motor controller will be controllable from the dashboard when test mode is enabled, but will 250 * otherwise be view-only. <br> 251 * Supported types: 252 * 253 * <ul> 254 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMMotorController} 255 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.DMC60} 256 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Jaguar} 257 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax} 258 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMTalonFX} 259 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMTalonSRX} 260 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMVenom} 261 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMVictorSPX} 262 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.SD540} 263 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Spark} 264 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Talon} 265 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Victor} 266 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.VictorSP} 267 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup} 268 * <li>Any custom subclass of {@code MotorController} 269 * </ul> 270 * 271 * <br> 272 * Custom properties: 273 * 274 * <table> 275 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 276 * <tr><td>Orientation</td><td>String</td><td>"HORIZONTAL"</td> 277 * <td>One of {@code ["HORIZONTAL", "VERTICAL"]}</td></tr> 278 * </table> 279 */ 280 kMotorController("Motor Controller"), 281 /** 282 * Displays a command with a toggle button. Pressing the button will start the command, and the 283 * button will automatically release when the command completes. <br> 284 * Supported types: 285 * 286 * <ul> 287 * <li>{@link edu.wpi.first.wpilibj.command.Command} 288 * <li>{@link edu.wpi.first.wpilibj.command.CommandGroup} 289 * <li>Any custom subclass of {@code Command} or {@code CommandGroup} 290 * </ul> 291 * 292 * <br> 293 * This widget has no custom properties. 294 */ 295 kCommand("Command"), 296 /** 297 * Displays a PID command with a checkbox and an editor for the PIDF constants. Selecting the 298 * checkbox will start the command, and the checkbox will automatically deselect when the command 299 * completes. <br> 300 * Supported types: 301 * 302 * <ul> 303 * <li>{@link edu.wpi.first.wpilibj.command.PIDCommand} 304 * <li>Any custom subclass of {@code PIDCommand} 305 * </ul> 306 * 307 * <br> 308 * This widget has no custom properties. 309 */ 310 kPIDCommand("PID Command"), 311 /** 312 * Displays a PID controller with an editor for the PIDF constants and a toggle switch for 313 * enabling and disabling the controller. <br> 314 * Supported types: 315 * 316 * <ul> 317 * <li>{@link edu.wpi.first.wpilibj.PIDController} 318 * </ul> 319 * 320 * <br> 321 * This widget has no custom properties. 322 */ 323 kPIDController("PID Controller"), 324 /** 325 * Displays an accelerometer with a number bar displaying the magnitude of the acceleration and 326 * text displaying the exact value. <br> 327 * Supported types: 328 * 329 * <ul> 330 * <li>{@link edu.wpi.first.wpilibj.AnalogAccelerometer} 331 * </ul> 332 * 333 * <br> 334 * Custom properties: 335 * 336 * <table> 337 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 338 * <tr><td>Min</td><td>Number</td><td>-1</td> 339 * <td>The minimum acceleration value to display</td></tr> 340 * <tr><td>Max</td><td>Number</td><td>1</td> 341 * <td>The maximum acceleration value to display</td></tr> 342 * <tr><td>Show text</td><td>Boolean</td><td>true</td> 343 * <td>Show or hide the acceleration values</td></tr> 344 * <tr><td>Precision</td><td>Number</td><td>2</td> 345 * <td>How many numbers to display after the decimal point</td></tr> 346 * <tr><td>Show tick marks</td><td>Boolean</td><td>false</td> 347 * <td>Show or hide the tick marks on the number bars</td></tr> 348 * </table> 349 */ 350 kAccelerometer("Accelerometer"), 351 /** 352 * Displays a 3-axis accelerometer with a number bar for each axis' acceleration. <br> 353 * Supported types: 354 * 355 * <ul> 356 * <li>{@link edu.wpi.first.wpilibj.ADXL345_I2C} 357 * <li>{@link edu.wpi.first.wpilibj.ADXL345_SPI} 358 * <li>{@link edu.wpi.first.wpilibj.ADXL362} 359 * </ul> 360 * 361 * <br> 362 * Custom properties: 363 * 364 * <table> 365 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 366 * <tr><td>Range</td><td>{@link Range}</td><td>k16G</td><td>The accelerometer range</td></tr> 367 * <tr><td>Show value</td><td>Boolean</td><td>true</td> 368 * <td>Show or hide the acceleration values</td></tr> 369 * <tr><td>Precision</td><td>Number</td><td>2</td> 370 * <td>How many numbers to display after the decimal point</td></tr> 371 * <tr><td>Show tick marks</td><td>Boolean</td><td>false</td> 372 * <td>Show or hide the tick marks on the number bars</td></tr> 373 * </table> 374 */ 375 k3AxisAccelerometer("3-Axis Accelerometer"), 376 /** 377 * Displays a gyro with a dial from 0 to 360 degrees. <br> 378 * Supported types: 379 * 380 * <ul> 381 * <li>{@link edu.wpi.first.wpilibj.ADXRS450_Gyro} 382 * <li>{@link edu.wpi.first.wpilibj.AnalogGyro} 383 * <li>Any custom subclass of {@code GyroBase} (such as a MXP gyro) 384 * </ul> 385 * 386 * <br> 387 * Custom properties: 388 * 389 * <table> 390 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 391 * <tr><td>Major tick spacing</td><td>Number</td><td>45</td><td>Degrees</td></tr> 392 * <tr><td>Starting angle</td><td>Number</td><td>180</td> 393 * <td>How far to rotate the entire dial, in degrees</td></tr> 394 * <tr><td>Show tick mark ring</td><td>Boolean</td><td>true</td></tr> 395 * </table> 396 */ 397 kGyro("Gyro"), 398 /** 399 * Displays a relay with toggle buttons for each supported mode (off, on, forward, reverse). <br> 400 * Supported types: 401 * 402 * <ul> 403 * <li>{@link edu.wpi.first.wpilibj.Relay} 404 * </ul> 405 * 406 * <br> 407 * This widget has no custom properties. 408 */ 409 kRelay("Relay"), 410 /** 411 * Displays a differential drive with a widget that displays the speed of each side of the 412 * drivebase and a vector for the direction and rotation of the drivebase. The widget will be 413 * controllable if the robot is in test mode. <br> 414 * Supported types: 415 * 416 * <ul> 417 * <li>{@link edu.wpi.first.wpilibj.drive.DifferentialDrive} 418 * </ul> 419 * 420 * <br> 421 * Custom properties: 422 * 423 * <table> 424 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 425 * <tr><td>Number of wheels</td><td>Number</td><td>4</td><td>Must be a positive even integer 426 * </td></tr> 427 * <tr><td>Wheel diameter</td><td>Number</td><td>80</td><td>Pixels</td></tr> 428 * <tr><td>Show velocity vectors</td><td>Boolean</td><td>true</td></tr> 429 * </table> 430 */ 431 kDifferentialDrive("Differential Drivebase"), 432 /** 433 * Displays a mecanum drive with a widget that displays the speed of each wheel, and vectors for 434 * the direction and rotation of the drivebase. The widget will be controllable if the robot is in 435 * test mode. <br> 436 * Supported types: 437 * 438 * <ul> 439 * <li>{@link edu.wpi.first.wpilibj.drive.MecanumDrive} 440 * </ul> 441 * 442 * <br> 443 * Custom properties: 444 * 445 * <table> 446 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 447 * <tr><td>Show velocity vectors</td><td>Boolean</td><td>true</td></tr> 448 * </table> 449 */ 450 kMecanumDrive("Mecanum Drivebase"), 451 /** 452 * Displays a camera stream. <br> 453 * Supported types: 454 * 455 * <ul> 456 * <li>{@link edu.wpi.first.cscore.VideoSource} (as long as it is streaming on an MJPEG server) 457 * </ul> 458 * 459 * <br> 460 * Custom properties: 461 * 462 * <table> 463 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 464 * <tr><td>Show crosshair</td><td>Boolean</td><td>true</td> 465 * <td>Show or hide a crosshair on the image</td></tr> 466 * <tr><td>Crosshair color</td><td>Color</td><td>"white"</td> 467 * <td>Can be a string or a rgba integer</td></tr> 468 * <tr><td>Show controls</td><td>Boolean</td><td>true</td><td>Show or hide the stream controls 469 * </td></tr> 470 * <tr><td>Rotation</td><td>String</td><td>"NONE"</td> 471 * <td>Rotates the displayed image. One of {@code ["NONE", "QUARTER_CW", "QUARTER_CCW", "HALF"]} 472 * </td></tr> 473 * </table> 474 */ 475 kCameraStream("Camera Stream"), 476 ; 477 478 private final String m_widgetName; 479 480 BuiltInWidgets(String widgetName) { 481 this.m_widgetName = widgetName; 482 } 483 484 @Override 485 public String getWidgetName() { 486 return m_widgetName; 487 } 488}