Skip to content

Commit 653fda4

Browse files
committed
fix bug where number of plots is saved for all devices
1 parent 75ed22b commit 653fda4

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/gui.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ impl MyApp {
308308
let panel_height = ui.available_size().y;
309309
let height = ui.available_size().y * self.plot_serial_display_ratio;
310310
let plots_height = height;
311-
let plot_height = plots_height / (self.serial_devices.number_of_plots as f32);
311+
let plot_height =
312+
plots_height / (self.serial_devices.number_of_plots[self.device_idx] as f32);
312313
let spacing = 5.0;
313314
let width = ui.available_size().x - 2.0 * border - RIGHT_PANEL_WIDTH;
314315

@@ -339,7 +340,7 @@ impl MyApp {
339340
let t_fmt = |x, _range: &RangeInclusive<f64>| format!("{:4.2} s", x);
340341

341342
let plots_ui = ui.vertical(|ui| {
342-
for graph_idx in 0..self.serial_devices.number_of_plots {
343+
for graph_idx in 0..self.serial_devices.number_of_plots[self.device_idx] {
343344
if graph_idx != 0 {
344345
ui.separator();
345346
}
@@ -682,15 +683,15 @@ impl MyApp {
682683

683684
ui.horizontal(|ui| {
684685
if ui.button("<").clicked() {
685-
self.serial_devices.number_of_plots =
686-
(self.serial_devices.number_of_plots - 1).clamp(1, 10);
686+
self.serial_devices.number_of_plots[self.device_idx] =
687+
(self.serial_devices.number_of_plots[self.device_idx] - 1).clamp(1, 10);
687688
}
688-
ui.add(egui::DragValue::new(&mut self.serial_devices.number_of_plots)
689+
ui.add(egui::DragValue::new(&mut self.serial_devices.number_of_plots[self.device_idx])
689690
.clamp_range(1..=10))
690691
.on_hover_text("Select the number of plots to be shown.");
691692
if ui.button(">").clicked() {
692-
self.serial_devices.number_of_plots =
693-
(self.serial_devices.number_of_plots + 1).clamp(1, 10);
693+
self.serial_devices.number_of_plots[self.device_idx] =
694+
(self.serial_devices.number_of_plots[self.device_idx] + 1).clamp(1, 10);
694695
}
695696
});
696697

src/serial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ use crate::{print_to_console, Packet, Print, APP_INFO, PREFS_KEY_SERIAL};
1414
pub struct SerialDevices {
1515
pub devices: Vec<Device>,
1616
pub labels: Vec<Vec<String>>,
17-
pub number_of_plots: usize,
17+
pub number_of_plots: Vec<usize>,
1818
}
1919

2020
impl Default for SerialDevices {
2121
fn default() -> Self {
2222
SerialDevices {
2323
devices: vec![Device::default()],
2424
labels: vec![vec!["Column 0".to_string()]],
25-
number_of_plots: 1,
25+
number_of_plots: vec![1],
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)