mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[ntcore] NetworkTables 4 (#3217)
This commit is contained in:
@@ -83,7 +83,7 @@ class PlotSeries {
|
||||
return m_digital.GetValue() == kDigital ||
|
||||
(m_digital.GetValue() == kAuto && m_source && m_source->IsDigital());
|
||||
}
|
||||
void AppendValue(double value, uint64_t time);
|
||||
void AppendValue(double value, int64_t time);
|
||||
|
||||
// source linkage
|
||||
DataSource* m_source = nullptr;
|
||||
@@ -248,10 +248,10 @@ void PlotSeries::SetSource(DataSource* source) {
|
||||
AppendValue(source->GetValue(), 0);
|
||||
|
||||
m_newValueConn = source->valueChanged.connect_connection(
|
||||
[this](double value, uint64_t time) { AppendValue(value, time); });
|
||||
[this](double value, int64_t time) { AppendValue(value, time); });
|
||||
}
|
||||
|
||||
void PlotSeries::AppendValue(double value, uint64_t timeUs) {
|
||||
void PlotSeries::AppendValue(double value, int64_t timeUs) {
|
||||
double time = (timeUs != 0 ? timeUs : wpi::Now()) * 1.0e-6;
|
||||
if (IsDigital()) {
|
||||
if (m_size < kMaxSize) {
|
||||
|
||||
@@ -10,16 +10,13 @@ using namespace glass;
|
||||
|
||||
EnumSetting::EnumSetting(std::string& str, int defaultValue,
|
||||
std::initializer_list<const char*> choices)
|
||||
: m_str{str}, m_choices{choices}, m_value{defaultValue} {
|
||||
// override default value if str is one of the choices
|
||||
int i = 0;
|
||||
for (auto choice : choices) {
|
||||
if (str == choice) {
|
||||
m_value = i;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
: m_str{str}, m_choices{choices}, m_defaultValue{defaultValue} {}
|
||||
|
||||
int EnumSetting::GetValue() const {
|
||||
if (m_value == -1) {
|
||||
UpdateValue();
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void EnumSetting::SetValue(int value) {
|
||||
@@ -29,6 +26,9 @@ void EnumSetting::SetValue(int value) {
|
||||
|
||||
bool EnumSetting::Combo(const char* label, int numOptions,
|
||||
int popup_max_height_in_items) {
|
||||
if (m_value == -1) {
|
||||
UpdateValue();
|
||||
}
|
||||
if (ImGui::Combo(
|
||||
label, &m_value, m_choices.data(),
|
||||
numOptions < 0 ? m_choices.size() : static_cast<size_t>(numOptions),
|
||||
@@ -38,3 +38,17 @@ bool EnumSetting::Combo(const char* label, int numOptions,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EnumSetting::UpdateValue() const {
|
||||
// override default value if str is one of the choices
|
||||
int i = 0;
|
||||
for (auto choice : m_choices) {
|
||||
if (m_str == choice) {
|
||||
m_value = i;
|
||||
return;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
// no match, default it
|
||||
m_value = m_defaultValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user