2020-12-26 14:31:24 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-09-12 10:55:46 -07:00
|
|
|
|
|
|
|
|
#include "glass/hardware/AnalogGyro.h"
|
|
|
|
|
|
2023-09-17 20:00:16 -07:00
|
|
|
#include <wpi/StringExtras.h>
|
|
|
|
|
|
2020-09-12 10:55:46 -07:00
|
|
|
#include "glass/DataSource.h"
|
|
|
|
|
#include "glass/other/DeviceTree.h"
|
|
|
|
|
|
|
|
|
|
using namespace glass;
|
|
|
|
|
|
|
|
|
|
void glass::DisplayAnalogGyroDevice(AnalogGyroModel* model, int index) {
|
|
|
|
|
char name[32];
|
2023-09-17 20:00:16 -07:00
|
|
|
wpi::format_to_n_c_str(name, sizeof(name), "AnalogGyro[{}]", index);
|
|
|
|
|
|
2020-09-12 10:55:46 -07:00
|
|
|
if (BeginDevice(name)) {
|
|
|
|
|
// angle
|
|
|
|
|
if (auto angleData = model->GetAngleData()) {
|
|
|
|
|
double value = angleData->GetValue();
|
|
|
|
|
if (DeviceDouble("Angle", false, &value, angleData)) {
|
|
|
|
|
model->SetAngle(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rate
|
|
|
|
|
if (auto rateData = model->GetRateData()) {
|
|
|
|
|
double value = rateData->GetValue();
|
|
|
|
|
if (DeviceDouble("Rate", false, &value, rateData)) {
|
|
|
|
|
model->SetRate(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EndDevice();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glass::DisplayAnalogGyrosDevice(AnalogGyrosModel* model) {
|
|
|
|
|
model->ForEachAnalogGyro(
|
|
|
|
|
[&](AnalogGyroModel& gyro, int i) { DisplayAnalogGyroDevice(&gyro, i); });
|
|
|
|
|
}
|