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