mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Add confirmation to SendableChooser (#1217)
This echos back the "selected" value to the "active" key to enable dashboards to display positive feedback to the user that the value is actually set on the robot side. Also fixes SendableChooser so it can be safely added to multiple tables. Changes to "selected" in any table will result in all "active" values being updated. Now that adding SendableChooser to multiple tables is supported, an ".instance" key enables dashboards to treat the same SendableChooser as a common instance if desired.
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
@@ -30,9 +33,16 @@ class SendableChooserBase : public SendableBase {
|
||||
static constexpr const char* kDefault = "default";
|
||||
static constexpr const char* kOptions = "options";
|
||||
static constexpr const char* kSelected = "selected";
|
||||
static constexpr const char* kActive = "active";
|
||||
static constexpr const char* kInstance = ".instance";
|
||||
|
||||
std::string m_defaultChoice;
|
||||
nt::NetworkTableEntry m_selectedEntry;
|
||||
std::string m_selected;
|
||||
bool m_haveSelected = false;
|
||||
wpi::SmallVector<nt::NetworkTableEntry, 2> m_activeEntries;
|
||||
wpi::mutex m_mutex;
|
||||
int m_instance;
|
||||
static std::atomic_int s_instances;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user