Split output config UI into its own file
This commit is contained in:
parent
53f058d307
commit
c55704dbdd
|
@ -7,6 +7,7 @@ use crossbeam_channel::{select, unbounded, Receiver, Sender};
|
||||||
use cheapsdo_protocol::*;
|
use cheapsdo_protocol::*;
|
||||||
|
|
||||||
mod formatters;
|
mod formatters;
|
||||||
|
mod outputsettings;
|
||||||
mod plots;
|
mod plots;
|
||||||
mod serial;
|
mod serial;
|
||||||
mod widgets;
|
mod widgets;
|
||||||
|
@ -159,101 +160,14 @@ impl eframe::App for CheapsdoControl {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.vertical(|ui| ui.label(egui::RichText::new("TCXO Status").size(20.0)));
|
ui.vertical(|ui| ui.label(egui::RichText::new("TCXO Status").size(20.0)));
|
||||||
ui.add_space(20.0);
|
ui.add_space(20.0);
|
||||||
plots::show_freuqencies(ui, &self.device_state);
|
self.show_freuqencies(ui);
|
||||||
ui.add_space(20.0);
|
ui.add_space(20.0);
|
||||||
plots::show_plots(ui, &self.average_points, &self.pwm_points);
|
self.show_plots(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
ui.vertical(|ui| {
|
self.output_control(ui, ctx);
|
||||||
ui.label(egui::RichText::new("Output Settings").size(20.0));
|
|
||||||
ui.add_space(20.0);
|
|
||||||
egui::Grid::new("output_pll_settings")
|
|
||||||
.spacing([20.0, 5.0])
|
|
||||||
.show(ui, |ui| {
|
|
||||||
ui.label("MS1 Frequency [Hz]");
|
|
||||||
widgets::frequency_input(
|
|
||||||
self.ms1_frequency_id,
|
|
||||||
&mut self.pll_settings.ms1_frequency,
|
|
||||||
&ctx,
|
|
||||||
ui,
|
|
||||||
);
|
|
||||||
ui.end_row();
|
|
||||||
|
|
||||||
ui.label("MS2 Frequency [Hz]");
|
|
||||||
widgets::frequency_input(
|
|
||||||
self.ms2_frequency_id,
|
|
||||||
&mut self.pll_settings.ms2_frequency,
|
|
||||||
&ctx,
|
|
||||||
ui,
|
|
||||||
);
|
|
||||||
ui.end_row();
|
|
||||||
});
|
|
||||||
|
|
||||||
for i in 0..3 {
|
|
||||||
ui.separator();
|
|
||||||
|
|
||||||
egui::Grid::new(format!("output_clk{}_settings", i + 1))
|
|
||||||
.spacing([20.0, 5.0])
|
|
||||||
.show(ui, |ui| {
|
|
||||||
ui.label(format!("CLK{} Multisynth", i + 1));
|
|
||||||
widgets::multisynth_selector(
|
|
||||||
&mut self.pll_settings.outputs[i].source,
|
|
||||||
ui,
|
|
||||||
);
|
|
||||||
ui.end_row();
|
|
||||||
|
|
||||||
ui.label(format!("CLK{} Frequency [Hz]", i + 1));
|
|
||||||
widgets::frequency_input(
|
|
||||||
self.output_frequency_id[i],
|
|
||||||
&mut self.pll_settings.outputs[i].frequency,
|
|
||||||
&ctx,
|
|
||||||
ui,
|
|
||||||
);
|
|
||||||
ui.end_row();
|
|
||||||
|
|
||||||
ui.label(format!("CLK{} Enable", i + 1));
|
|
||||||
|
|
||||||
widgets::on_off_toggle(
|
|
||||||
&mut self.pll_settings.outputs[i].enable,
|
|
||||||
ui,
|
|
||||||
);
|
|
||||||
|
|
||||||
ui.end_row();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.separator();
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
if ui
|
|
||||||
.add_enabled(
|
|
||||||
self.cmd_tx.is_some(),
|
|
||||||
egui::Button::new("Apply").fill(egui::Color32::DARK_GREEN),
|
|
||||||
)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
if let Some(cmd_tx) = &self.cmd_tx {
|
|
||||||
cmd_tx
|
|
||||||
.send(serial::Cmd::SetPLLSetting(self.pll_settings.clone()))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.add_space(40.0);
|
|
||||||
if ui
|
|
||||||
.add_enabled(
|
|
||||||
self.cmd_tx.is_some(),
|
|
||||||
egui::Button::new("Reset").fill(egui::Color32::DARK_RED),
|
|
||||||
)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
if let Some(cmd_tx) = &self.cmd_tx {
|
|
||||||
cmd_tx.send(serial::Cmd::GetPLLSettings).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
use eframe::egui::{self};
|
||||||
|
|
||||||
|
use crate::serial;
|
||||||
|
use crate::widgets;
|
||||||
|
use crate::CheapsdoControl;
|
||||||
|
|
||||||
|
impl CheapsdoControl {
|
||||||
|
pub fn output_control(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) {
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.label(egui::RichText::new("Output Settings").size(20.0));
|
||||||
|
ui.add_space(20.0);
|
||||||
|
egui::Grid::new("output_pll_settings")
|
||||||
|
.spacing([20.0, 5.0])
|
||||||
|
.show(ui, |ui| {
|
||||||
|
ui.label("MS1 Frequency [Hz]");
|
||||||
|
widgets::frequency_input(
|
||||||
|
self.ms1_frequency_id,
|
||||||
|
&mut self.pll_settings.ms1_frequency,
|
||||||
|
&ctx,
|
||||||
|
ui,
|
||||||
|
);
|
||||||
|
ui.end_row();
|
||||||
|
|
||||||
|
ui.label("MS2 Frequency [Hz]");
|
||||||
|
widgets::frequency_input(
|
||||||
|
self.ms2_frequency_id,
|
||||||
|
&mut self.pll_settings.ms2_frequency,
|
||||||
|
&ctx,
|
||||||
|
ui,
|
||||||
|
);
|
||||||
|
ui.end_row();
|
||||||
|
});
|
||||||
|
|
||||||
|
for i in 0..3 {
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
egui::Grid::new(format!("output_clk{}_settings", i + 1))
|
||||||
|
.spacing([20.0, 5.0])
|
||||||
|
.show(ui, |ui| {
|
||||||
|
ui.label(format!("CLK{} Multisynth", i + 1));
|
||||||
|
widgets::multisynth_selector(&mut self.pll_settings.outputs[i].source, ui);
|
||||||
|
ui.end_row();
|
||||||
|
|
||||||
|
ui.label(format!("CLK{} Frequency [Hz]", i + 1));
|
||||||
|
widgets::frequency_input(
|
||||||
|
self.output_frequency_id[i],
|
||||||
|
&mut self.pll_settings.outputs[i].frequency,
|
||||||
|
&ctx,
|
||||||
|
ui,
|
||||||
|
);
|
||||||
|
ui.end_row();
|
||||||
|
|
||||||
|
ui.label(format!("CLK{} Enable", i + 1));
|
||||||
|
|
||||||
|
widgets::on_off_toggle(&mut self.pll_settings.outputs[i].enable, ui);
|
||||||
|
|
||||||
|
ui.end_row();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
let apply_button = ui.add_enabled(
|
||||||
|
self.cmd_tx.is_some(),
|
||||||
|
egui::Button::new("Apply").fill(egui::Color32::DARK_GREEN),
|
||||||
|
);
|
||||||
|
if apply_button.clicked() {
|
||||||
|
if let Some(cmd_tx) = &self.cmd_tx {
|
||||||
|
cmd_tx
|
||||||
|
.send(serial::Cmd::SetPLLSetting(self.pll_settings.clone()))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.add_space(40.0);
|
||||||
|
|
||||||
|
let reset_button = ui.add_enabled(
|
||||||
|
self.cmd_tx.is_some(),
|
||||||
|
egui::Button::new("Reset").fill(egui::Color32::DARK_RED),
|
||||||
|
);
|
||||||
|
if reset_button.clicked() {
|
||||||
|
if let Some(cmd_tx) = &self.cmd_tx {
|
||||||
|
cmd_tx.send(serial::Cmd::GetPLLSettings).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,76 +2,82 @@ use eframe::egui;
|
||||||
use egui_plot::{Line, Plot, PlotPoints};
|
use egui_plot::{Line, Plot, PlotPoints};
|
||||||
|
|
||||||
use crate::formatters;
|
use crate::formatters;
|
||||||
|
use crate::CheapsdoControl;
|
||||||
use crate::StatusMessage;
|
use crate::StatusMessage;
|
||||||
|
|
||||||
pub fn show_freuqencies(ui: &mut egui::Ui, state: &StatusMessage) {
|
impl CheapsdoControl {
|
||||||
ui.horizontal(|ui| {
|
pub fn show_freuqencies(&self, ui: &mut egui::Ui) {
|
||||||
ui.label(
|
ui.horizontal(|ui| {
|
||||||
egui::RichText::new(format!(
|
ui.label(
|
||||||
"Measured: {}",
|
egui::RichText::new(format!(
|
||||||
formatters::format_frequency_mhz(state.measured_frequency as f64 / 1000.0)
|
"Measured: {}",
|
||||||
))
|
formatters::format_frequency_mhz(
|
||||||
.family(egui::FontFamily::Monospace)
|
self.device_state.measured_frequency as f64 / 1000.0
|
||||||
.size(20.0),
|
)
|
||||||
);
|
))
|
||||||
|
.family(egui::FontFamily::Monospace)
|
||||||
|
.size(20.0),
|
||||||
|
);
|
||||||
|
|
||||||
ui.add_space(100.0);
|
ui.add_space(100.0);
|
||||||
|
|
||||||
ui.label(
|
ui.label(
|
||||||
egui::RichText::new(format!(
|
egui::RichText::new(format!(
|
||||||
"Average: {}",
|
"Average: {}",
|
||||||
formatters::format_frequency_mhz(state.average_frequency as f64 / 1000.0)
|
formatters::format_frequency_mhz(
|
||||||
))
|
self.device_state.average_frequency as f64 / 1000.0
|
||||||
.family(egui::FontFamily::Monospace)
|
)
|
||||||
.size(20.0),
|
))
|
||||||
);
|
.family(egui::FontFamily::Monospace)
|
||||||
});
|
.size(20.0),
|
||||||
}
|
);
|
||||||
|
|
||||||
pub fn show_plots(ui: &mut egui::Ui, average_points: &Vec<[f64; 2]>, pwm_points: &Vec<[f64; 2]>) {
|
|
||||||
let average_line = Line::new(PlotPoints::new(average_points.clone()));
|
|
||||||
Plot::new("frequency_plot")
|
|
||||||
.width(900.0)
|
|
||||||
.view_aspect(3.0)
|
|
||||||
.allow_zoom(false)
|
|
||||||
.allow_scroll(false)
|
|
||||||
.allow_drag(false)
|
|
||||||
.allow_boxed_zoom(false)
|
|
||||||
.y_axis_width(12)
|
|
||||||
.y_axis_formatter(|val, _, _| formatters::format_frequency_mhz(val))
|
|
||||||
.label_formatter(|name, value| {
|
|
||||||
if !name.is_empty() {
|
|
||||||
format!("{}: {}", name, formatters::format_frequency_mhz(value.y))
|
|
||||||
} else {
|
|
||||||
format!(
|
|
||||||
"x = {}\ny= {}",
|
|
||||||
value.x,
|
|
||||||
formatters::format_frequency_mhz(value.y)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.link_cursor("plots", true, false)
|
|
||||||
.show(ui, |plot_ui| {
|
|
||||||
plot_ui.set_auto_bounds([true, true].into());
|
|
||||||
plot_ui.line(average_line);
|
|
||||||
//plot_ui.line(measured_line);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ui.add_space(20.0);
|
pub fn show_plots(&self, ui: &mut egui::Ui) {
|
||||||
|
let average_line = Line::new(PlotPoints::new(self.average_points.clone()));
|
||||||
|
Plot::new("frequency_plot")
|
||||||
|
.width(900.0)
|
||||||
|
.view_aspect(3.0)
|
||||||
|
.allow_zoom(false)
|
||||||
|
.allow_scroll(false)
|
||||||
|
.allow_drag(false)
|
||||||
|
.allow_boxed_zoom(false)
|
||||||
|
.y_axis_width(12)
|
||||||
|
.y_axis_formatter(|val, _, _| formatters::format_frequency_mhz(val))
|
||||||
|
.label_formatter(|name, value| {
|
||||||
|
if !name.is_empty() {
|
||||||
|
format!("{}: {}", name, formatters::format_frequency_mhz(value.y))
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"x = {}\ny= {}",
|
||||||
|
value.x,
|
||||||
|
formatters::format_frequency_mhz(value.y)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.link_cursor("plots", true, false)
|
||||||
|
.show(ui, |plot_ui| {
|
||||||
|
plot_ui.set_auto_bounds([true, true].into());
|
||||||
|
plot_ui.line(average_line);
|
||||||
|
//plot_ui.line(measured_line);
|
||||||
|
});
|
||||||
|
|
||||||
let pwm_line = Line::new(PlotPoints::new(pwm_points.clone()));
|
ui.add_space(20.0);
|
||||||
Plot::new("pwm_plot")
|
|
||||||
.width(900.0)
|
let pwm_line = Line::new(PlotPoints::new(self.pwm_points.clone()));
|
||||||
.view_aspect(3.0)
|
Plot::new("pwm_plot")
|
||||||
.allow_zoom(false)
|
.width(900.0)
|
||||||
.allow_scroll(false)
|
.view_aspect(3.0)
|
||||||
.allow_drag(false)
|
.allow_zoom(false)
|
||||||
.allow_boxed_zoom(false)
|
.allow_scroll(false)
|
||||||
.y_axis_width(12)
|
.allow_drag(false)
|
||||||
.link_cursor("plots", true, false)
|
.allow_boxed_zoom(false)
|
||||||
.show(ui, |plot_ui| {
|
.y_axis_width(12)
|
||||||
plot_ui.set_auto_bounds([true, true].into());
|
.link_cursor("plots", true, false)
|
||||||
plot_ui.line(pwm_line);
|
.show(ui, |plot_ui| {
|
||||||
});
|
plot_ui.set_auto_bounds([true, true].into());
|
||||||
|
plot_ui.line(pwm_line);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue