mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update LiveWindow to provide continuous telemetry. (#771)
LiveWindow.updateValues() is now called from IterativeRobotBase on every loop iteration. Telemetry for all WPILib classes is enabled by default; it can be disabled for specific classes using LiveWindow.disableTelemetry(), or all telemetry can be disabled using LiveWindow.disableAllTelemetry(). This necessitated changing the hook methodology into other classes to be more property-based rather than each class providing multiple functions. This had the benefit of reducing boilerplate and increasing consistency. - Remove NamedSendable, add name to Sendable. - Provide SendableBase abstract class. - Deprecate LiveWindow addSensor/addActuator interfaces. - Add LiveWindow support to drive classes. - Add addChild() helper functions to Subsystem. - Fix inheritance hierarchy. Now only sensors inherit from SensorBase. Other devices inherit from some combination of SendableBase, ErrorBase, or nothing.
This commit is contained in:
@@ -11,12 +11,11 @@
|
||||
#include "Buttons/PressedButtonScheduler.h"
|
||||
#include "Buttons/ReleasedButtonScheduler.h"
|
||||
#include "Buttons/ToggleButtonScheduler.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
bool Trigger::Grab() {
|
||||
return Get() || (m_pressedEntry && m_pressedEntry.GetBoolean(false));
|
||||
}
|
||||
bool Trigger::Grab() { return Get() || m_sendablePressed; }
|
||||
|
||||
void Trigger::WhenActive(Command* command) {
|
||||
auto pbs = new PressedButtonScheduler(Grab(), this, command);
|
||||
@@ -43,13 +42,9 @@ void Trigger::ToggleWhenActive(Command* command) {
|
||||
tbs->Start();
|
||||
}
|
||||
|
||||
std::string Trigger::GetSmartDashboardType() const { return "Button"; }
|
||||
|
||||
void Trigger::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
|
||||
if (subtable) {
|
||||
m_pressedEntry = subtable->GetEntry("pressed");
|
||||
m_pressedEntry.SetBoolean(Get());
|
||||
} else {
|
||||
m_pressedEntry = nt::NetworkTableEntry();
|
||||
}
|
||||
void Trigger::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Button");
|
||||
builder.SetSafeState([=]() { m_sendablePressed = false; });
|
||||
builder.AddBooleanProperty("pressed", [=]() { return Grab(); },
|
||||
[=](bool value) { m_sendablePressed = value; });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user