[glass] Add more widgets (#2947)

This adds the following widgets:
- Speed Controller
- Gyroscope
- Command
- Subsystem
- PIDController
- Scheduler
This commit is contained in:
Prateek Machiraju
2020-12-23 00:07:44 -05:00
committed by GitHub
parent 581b7ec553
commit 27b67deca6
25 changed files with 1101 additions and 0 deletions

View File

@@ -5,16 +5,44 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "glass/networktables/NTCommandScheduler.h"
#include "glass/networktables/NTCommandSelector.h"
#include "glass/networktables/NTDigitalInput.h"
#include "glass/networktables/NTDigitalOutput.h"
#include "glass/networktables/NTFMS.h"
#include "glass/networktables/NTField2D.h"
#include "glass/networktables/NTGyro.h"
#include "glass/networktables/NTPIDController.h"
#include "glass/networktables/NTSpeedController.h"
#include "glass/networktables/NTStringChooser.h"
#include "glass/networktables/NTSubsystem.h"
#include "glass/networktables/NetworkTablesProvider.h"
using namespace glass;
void glass::AddStandardNetworkTablesViews(NetworkTablesProvider& provider) {
provider.Register(
NTCommandSchedulerModel::kType,
[](NT_Inst inst, const char* path) {
return std::make_unique<NTCommandSchedulerModel>(inst, path);
},
[](Window* win, Model* model, const char*) {
win->SetDefaultSize(400, 200);
return MakeFunctionView([=] {
DisplayCommandScheduler(static_cast<NTCommandSchedulerModel*>(model));
});
});
provider.Register(
NTCommandSelectorModel::kType,
[](NT_Inst inst, const char* path) {
return std::make_unique<NTCommandSelectorModel>(inst, path);
},
[](Window* win, Model* model, const char*) {
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
return MakeFunctionView([=] {
DisplayCommandSelector(static_cast<NTCommandSelectorModel*>(model));
});
});
provider.Register(
NTFMSModel::kType,
[](NT_Inst inst, const char* path) {
@@ -59,6 +87,38 @@ void glass::AddStandardNetworkTablesViews(NetworkTablesProvider& provider) {
return std::make_unique<Field2DView>(
static_cast<NTField2DModel*>(model));
});
provider.Register(
NTGyroModel::kType,
[](NT_Inst inst, const char* path) {
return std::make_unique<NTGyroModel>(inst, path);
},
[](Window* win, Model* model, const char* path) {
win->SetDefaultSize(320, 380);
return MakeFunctionView(
[=] { DisplayGyro(static_cast<NTGyroModel*>(model)); });
});
provider.Register(
NTPIDControllerModel::kType,
[](NT_Inst inst, const char* path) {
return std::make_unique<NTPIDControllerModel>(inst, path);
},
[](Window* win, Model* model, const char* path) {
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
return MakeFunctionView([=] {
DisplayPIDController(static_cast<NTPIDControllerModel*>(model));
});
});
provider.Register(
NTSpeedControllerModel::kType,
[](NT_Inst inst, const char* path) {
return std::make_unique<NTSpeedControllerModel>(inst, path);
},
[](Window* win, Model* model, const char* path) {
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
return MakeFunctionView([=] {
DisplaySpeedController(static_cast<NTSpeedControllerModel*>(model));
});
});
provider.Register(
NTStringChooserModel::kType,
[](NT_Inst inst, const char* path) {
@@ -70,4 +130,14 @@ void glass::AddStandardNetworkTablesViews(NetworkTablesProvider& provider) {
DisplayStringChooser(static_cast<NTStringChooserModel*>(model));
});
});
provider.Register(
NTSubsystemModel::kType,
[](NT_Inst inst, const char* path) {
return std::make_unique<NTSubsystemModel>(inst, path);
},
[](Window* win, Model* model, const char*) {
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
return MakeFunctionView(
[=] { DisplaySubsystem(static_cast<NTSubsystemModel*>(model)); });
});
}