[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

@@ -13,6 +13,7 @@ NTPIDControllerModel::NTPIDControllerModel(NT_Inst instance,
wpi::StringRef path)
: m_nt(instance),
m_name(m_nt.GetEntry(path + "/.name")),
m_controllable(m_nt.GetEntry(path + "/.controllable")),
m_p(m_nt.GetEntry(path + "/p")),
m_i(m_nt.GetEntry(path + "/i")),
m_d(m_nt.GetEntry(path + "/d")),
@@ -23,6 +24,7 @@ NTPIDControllerModel::NTPIDControllerModel(NT_Inst instance,
m_setpointData("NTPIDCtrlStpt:" + path),
m_nameValue(path.rsplit('/').second) {
m_nt.AddListener(m_name);
m_nt.AddListener(m_controllable);
m_nt.AddListener(m_p);
m_nt.AddListener(m_i);
m_nt.AddListener(m_d);
@@ -67,6 +69,10 @@ void NTPIDControllerModel::Update() {
if (event.value && event.value->IsDouble()) {
m_setpointData.SetValue(event.value->GetDouble());
}
} else if (event.entry == m_controllable) {
if (event.value && event.value->IsBoolean()) {
m_controllableValue = event.value->GetBoolean();
}
}
}
}