mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[glass] Use .controllable to set widgets' read-only state (#3035)
This modifies the mecanum drive, differential drive, speed controller, and PID controller widgets to only be writeable when .controllable is set to true.
This commit is contained in:
committed by
GitHub
parent
d8652cfd4f
commit
278e0f126e
@@ -15,6 +15,7 @@ NTMecanumDriveModel::NTMecanumDriveModel(wpi::StringRef path)
|
||||
NTMecanumDriveModel::NTMecanumDriveModel(NT_Inst instance, wpi::StringRef path)
|
||||
: m_nt(instance),
|
||||
m_name(m_nt.GetEntry(path + "/.name")),
|
||||
m_controllable(m_nt.GetEntry(path + "/.controllable")),
|
||||
m_flPercent(m_nt.GetEntry(path + "/Front Left Motor Speed")),
|
||||
m_frPercent(m_nt.GetEntry(path + "/Front Right Motor Speed")),
|
||||
m_rlPercent(m_nt.GetEntry(path + "/Rear Left Motor Speed")),
|
||||
@@ -25,6 +26,7 @@ NTMecanumDriveModel::NTMecanumDriveModel(NT_Inst instance, wpi::StringRef path)
|
||||
m_rlPercentData("NTMcnmDriveRL:" + path),
|
||||
m_rrPercentData("NTMcnmDriveRR:" + path) {
|
||||
m_nt.AddListener(m_name);
|
||||
m_nt.AddListener(m_controllable);
|
||||
m_nt.AddListener(m_flPercent);
|
||||
m_nt.AddListener(m_frPercent);
|
||||
m_nt.AddListener(m_rlPercent);
|
||||
@@ -63,6 +65,9 @@ void NTMecanumDriveModel::Update() {
|
||||
} else if (event.entry == m_rrPercent && event.value &&
|
||||
event.value->IsDouble()) {
|
||||
m_rrPercentData.SetValue(event.value->GetDouble());
|
||||
} else if (event.entry == m_controllable && event.value &&
|
||||
event.value->IsBoolean()) {
|
||||
m_controllableValue = event.value->GetBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user