[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:
Prateek Machiraju
2021-01-05 21:33:05 -05:00
committed by GitHub
parent d8652cfd4f
commit 278e0f126e
11 changed files with 63 additions and 7 deletions

View File

@@ -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();
}
}