Hello, I am new to FRC and I was wondering how I could achieve something like this: I want to have a dropdown menu and two buttons in shuffleboard. I want to be able to have the driver select an option from the dropdown and then press the button to run a command using one button, and stop it using the other. I don’t know if this is possible, but it would be like binding a command to a button on a controller, but the button only exists inside shuffleboard. Is there any way to do this, or something similar? Thank you!
You can always just send the commands to the dashboard; by default they’ll display as a button that can be clicked to run the command.
If you find it’s too much clutter to put every command individually, consider something like the following (Shuffleboard calls performed with Oblog):
@Config
private final SendableChooser<Command> commandChooser = new SendableChooser<>();
public RobotContainer() {
// Rest of your ordinary stuff goes here
commandChooser.setDefaultOption("Foo", new FooCommand());
commandChooser.addOption("Bar", new BarCommand());
commandChooser.addOption("Baz", new BazCommand());
}
@Config.ToggleButton
void runSelectedCommand(boolean run) {
if (run) {
commandChooser.getSelected().schedule();
} else {
commandChooser.getSelected().cancel();
}
}
Unfortunately, a drop-down menu is likely impossible without writing a custom widget.
Thank you so much! This should work, but just out of curiosity, is it possible to have a single-click, non-toggle button in shuffleboard? I haven’t been able to find any information on this and it would be nice to have a single-click button-based interface. Thank you for the help!
As far as I know, it is not; it’d be a useful feature, I’ll see if we can add it for 2021.
Edit: I might be able to hack something together for Oblog for binding to void()
methods which uses the ToggleButton
but automatically resets the tracked variable to false. I’m a bit busy these days, so I can’t promise anything.
Thank you so much for all the help!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.