mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +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
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user