mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +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
@@ -16,12 +16,14 @@ NTDifferentialDriveModel::NTDifferentialDriveModel(NT_Inst instance,
|
||||
wpi::StringRef path)
|
||||
: m_nt(instance),
|
||||
m_name(m_nt.GetEntry(path + "/.name")),
|
||||
m_controllable(m_nt.GetEntry(path + "/.controllable")),
|
||||
m_lPercent(m_nt.GetEntry(path + "/Left Motor Speed")),
|
||||
m_rPercent(m_nt.GetEntry(path + "/Right Motor Speed")),
|
||||
m_nameValue(path.rsplit('/').second),
|
||||
m_lPercentData("NTDiffDriveL:" + path),
|
||||
m_rPercentData("NTDiffDriveR:" + path) {
|
||||
m_nt.AddListener(m_name);
|
||||
m_nt.AddListener(m_controllable);
|
||||
m_nt.AddListener(m_lPercent);
|
||||
m_nt.AddListener(m_rPercent);
|
||||
|
||||
@@ -44,6 +46,9 @@ void NTDifferentialDriveModel::Update() {
|
||||
} else if (event.entry == m_rPercent && event.value &&
|
||||
event.value->IsDouble()) {
|
||||
m_rPercentData.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