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.DMC60} 254 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Jaguar} 255 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax} 256 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMTalonFX} 257 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMTalonSRX} 258 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMVenom} 259 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.PWMVictorSPX} 260 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.SD540} 261 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Spark} 262 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Talon} 263 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.Victor} 264 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.VictorSP} 265 * <li>{@link edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup} 266 * <li>Any custom subclass of {@code MotorController} 267 * </ul> 268 * 269 * <br> 270 * Custom properties: 271 * 272 * <table> 273 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 274 * <tr><td>Orientation</td><td>String</td><td>"HORIZONTAL"</td> 275 * <td>One of {@code ["HORIZONTAL", "VERTICAL"]}</td></tr> 276 * </table> 277 */ 278 kMotorController("Motor Controller"), 279 /** 280 * Displays a command with a toggle button. Pressing the button will start the command, and the 281 * button will automatically release when the command completes. <br> 282 * Supported types: 283 * 284 * <ul> 285 * <li>{@link edu.wpi.first.wpilibj2.command.Command} 286 * <li>Any custom subclass of {@code Command} 287 * </ul> 288 * 289 * <br> 290 * This widget has no custom properties. 291 */ 292 kCommand("Command"), 293 /** 294 * Displays a PID command with a checkbox and an editor for the PIDF constants. Selecting the 295 * checkbox will start the command, and the checkbox will automatically deselect when the command 296 * completes. <br> 297 * Supported types: 298 * 299 * <ul> 300 * <li>{@link edu.wpi.first.wpilibj2.command.PIDCommand} 301 * <li>Any custom subclass of {@code PIDCommand} 302 * </ul> 303 * 304 * <br> 305 * This widget has no custom properties. 306 */ 307 kPIDCommand("PID Command"), 308 /** 309 * Displays a PID controller with an editor for the PIDF constants and a toggle switch for 310 * enabling and disabling the controller. <br> 311 * Supported types: 312 * 313 * <ul> 314 * <li>{@link edu.wpi.first.math.controller.PIDController} 315 * </ul> 316 * 317 * <br> 318 * This widget has no custom properties. 319 */ 320 kPIDController("PID Controller"), 321 /** 322 * Displays an accelerometer with a number bar displaying the magnitude of the acceleration and 323 * text displaying the exact value. <br> 324 * Supported types: 325 * 326 * <ul> 327 * <li>{@link edu.wpi.first.wpilibj.AnalogAccelerometer} 328 * </ul> 329 * 330 * <br> 331 * Custom properties: 332 * 333 * <table> 334 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 335 * <tr><td>Min</td><td>Number</td><td>-1</td> 336 * <td>The minimum acceleration value to display</td></tr> 337 * <tr><td>Max</td><td>Number</td><td>1</td> 338 * <td>The maximum acceleration value to display</td></tr> 339 * <tr><td>Show text</td><td>Boolean</td><td>true</td> 340 * <td>Show or hide the acceleration values</td></tr> 341 * <tr><td>Precision</td><td>Number</td><td>2</td> 342 * <td>How many numbers to display after the decimal point</td></tr> 343 * <tr><td>Show tick marks</td><td>Boolean</td><td>false</td> 344 * <td>Show or hide the tick marks on the number bars</td></tr> 345 * </table> 346 */ 347 kAccelerometer("Accelerometer"), 348 /** 349 * Displays a 3-axis accelerometer with a number bar for each axis' acceleration. <br> 350 * Supported types: 351 * 352 * <ul> 353 * <li>{@link edu.wpi.first.wpilibj.ADXL345_I2C} 354 * <li>{@link edu.wpi.first.wpilibj.ADXL345_SPI} 355 * <li>{@link edu.wpi.first.wpilibj.ADXL362} 356 * </ul> 357 * 358 * <br> 359 * Custom properties: 360 * 361 * <table> 362 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 363 * <tr><td>Show value</td><td>Boolean</td><td>true</td> 364 * <td>Show or hide the acceleration values</td></tr> 365 * <tr><td>Precision</td><td>Number</td><td>2</td> 366 * <td>How many numbers to display after the decimal point</td></tr> 367 * <tr><td>Show tick marks</td><td>Boolean</td><td>false</td> 368 * <td>Show or hide the tick marks on the number bars</td></tr> 369 * </table> 370 */ 371 k3AxisAccelerometer("3-Axis Accelerometer"), 372 /** 373 * Displays a gyro with a dial from 0 to 360 degrees. <br> 374 * Supported types: 375 * 376 * <ul> 377 * <li>{@link edu.wpi.first.wpilibj.ADXRS450_Gyro} 378 * <li>{@link edu.wpi.first.wpilibj.AnalogGyro} 379 * <li>Any custom subclass of {@code GyroBase} (such as a MXP gyro) 380 * </ul> 381 * 382 * <br> 383 * Custom properties: 384 * 385 * <table> 386 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 387 * <tr><td>Major tick spacing</td><td>Number</td><td>45</td><td>Degrees</td></tr> 388 * <tr><td>Starting angle</td><td>Number</td><td>180</td> 389 * <td>How far to rotate the entire dial, in degrees</td></tr> 390 * <tr><td>Show tick mark ring</td><td>Boolean</td><td>true</td></tr> 391 * </table> 392 */ 393 kGyro("Gyro"), 394 /** 395 * Displays a relay with toggle buttons for each supported mode (off, on, forward, reverse). <br> 396 * Supported types: 397 * 398 * <ul> 399 * <li>{@link edu.wpi.first.wpilibj.Relay} 400 * </ul> 401 * 402 * <br> 403 * This widget has no custom properties. 404 */ 405 kRelay("Relay"), 406 /** 407 * Displays a differential drive with a widget that displays the speed of each side of the 408 * drivebase and a vector for the direction and rotation of the drivebase. The widget will be 409 * controllable if the robot is in test mode. <br> 410 * Supported types: 411 * 412 * <ul> 413 * <li>{@link edu.wpi.first.wpilibj.drive.DifferentialDrive} 414 * </ul> 415 * 416 * <br> 417 * Custom properties: 418 * 419 * <table> 420 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 421 * <tr><td>Number of wheels</td><td>Number</td><td>4</td><td>Must be a positive even integer 422 * </td></tr> 423 * <tr><td>Wheel diameter</td><td>Number</td><td>80</td><td>Pixels</td></tr> 424 * <tr><td>Show velocity vectors</td><td>Boolean</td><td>true</td></tr> 425 * </table> 426 */ 427 kDifferentialDrive("Differential Drivebase"), 428 /** 429 * Displays a mecanum drive with a widget that displays the speed of each wheel, and vectors for 430 * the direction and rotation of the drivebase. The widget will be controllable if the robot is in 431 * test mode. <br> 432 * Supported types: 433 * 434 * <ul> 435 * <li>{@link edu.wpi.first.wpilibj.drive.MecanumDrive} 436 * </ul> 437 * 438 * <br> 439 * Custom properties: 440 * 441 * <table> 442 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 443 * <tr><td>Show velocity vectors</td><td>Boolean</td><td>true</td></tr> 444 * </table> 445 */ 446 kMecanumDrive("Mecanum Drivebase"), 447 /** 448 * Displays a camera stream. <br> 449 * Supported types: 450 * 451 * <ul> 452 * <li>{@link edu.wpi.first.cscore.VideoSource} (as long as it is streaming on an MJPEG server) 453 * </ul> 454 * 455 * <br> 456 * Custom properties: 457 * 458 * <table> 459 * <tr><th>Name</th><th>Type</th><th>Default Value</th><th>Notes</th></tr> 460 * <tr><td>Show crosshair</td><td>Boolean</td><td>true</td> 461 * <td>Show or hide a crosshair on the image</td></tr> 462 * <tr><td>Crosshair color</td><td>Color</td><td>"white"</td> 463 * <td>Can be a string or a rgba integer</td></tr> 464 * <tr><td>Show controls</td><td>Boolean</td><td>true</td><td>Show or hide the stream controls 465 * </td></tr> 466 * <tr><td>Rotation</td><td>String</td><td>"NONE"</td> 467 * <td>Rotates the displayed image. One of {@code ["NONE", "QUARTER_CW", "QUARTER_CCW", "HALF"]} 468 * </td></tr> 469 * </table> 470 */ 471 kCameraStream("Camera Stream"), 472 /** 473 * Displays a Field2d object.<br> 474 * Supported types: 475 * 476 * <ul> 477 * <li>{@link edu.wpi.first.wpilibj.smartdashboard.Field2d} 478 * </ul> 479 */ 480 kField("Field"), 481 ; 482 483 private final String m_widgetName; 484 485 BuiltInWidgets(String widgetName) { 486 this.m_widgetName = widgetName; 487 } 488 489 @Override 490 public String getWidgetName() { 491 return m_widgetName; 492 } 493}