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