Skip to content

Change Enum variant to CamelCase #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const DEFAULT_FONT_ID: FontId = FontId::new(14.0, FontFamily::Monospace);

#[derive(Clone)]
pub enum Print {
EMPTY,
MESSAGE(String),
ERROR(String),
DEBUG(String),
TASK(String),
Empty,
Message(String),
Error(String),
Debug(String),
Task(String),
OK(String),
}

Expand Down Expand Up @@ -113,7 +113,7 @@ impl MyApp {
picked_path: PathBuf::new(),
device: "".to_string(),
data: DataContainer::default(),
console: vec![Print::MESSAGE(
console: vec![Print::Message(
"waiting for serial connection..,".to_owned(),
)],
connected_lock,
Expand Down Expand Up @@ -288,7 +288,7 @@ impl eframe::App for MyApp {
Err(err) => {
print_to_console(
&self.print_lock,
Print::ERROR(format!("send_tx thread send failed: {:?}", err)),
Print::Error(format!("send_tx thread send failed: {:?}", err)),
);
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@ impl eframe::App for MyApp {
Err(err) => {
print_to_console(
&self.print_lock,
Print::ERROR(format!("clear_tx thread send failed: {:?}", err)),
Print::Error(format!("clear_tx thread send failed: {:?}", err)),
);
}
}
Expand Down Expand Up @@ -433,7 +433,7 @@ impl eframe::App for MyApp {
Err(err) => {
print_to_console(
&self.print_lock,
Print::ERROR(format!(
Print::Error(format!(
"save_tx thread send failed: {:?}",
err
)),
Expand Down Expand Up @@ -487,8 +487,8 @@ impl eframe::App for MyApp {
.show_rows(ui, row_height, num_rows, |ui, row_range| {
for row in row_range {
match self.console[row].clone() {
Print::EMPTY => {}
Print::MESSAGE(s) => {
Print::Empty => {}
Print::Message(s) => {
let text = "[MSG] ".to_string();
ui.horizontal_wrapped(|ui| {
let color = if self.dark_mode {
Expand All @@ -508,7 +508,7 @@ impl eframe::App for MyApp {
);
});
}
Print::ERROR(s) => {
Print::Error(s) => {
ui.horizontal_wrapped(|ui| {
let text = "[ERR] ".to_string();
ui.label(
Expand All @@ -523,7 +523,7 @@ impl eframe::App for MyApp {
);
});
}
Print::DEBUG(s) => {
Print::Debug(s) => {
if self.gui_conf.debug {
let color = if self.dark_mode {
egui::Color32::YELLOW
Expand All @@ -545,7 +545,7 @@ impl eframe::App for MyApp {
});
}
}
Print::TASK(s) => {
Print::Task(s) => {
ui.horizontal_wrapped(|ui| {
let text = "[ ] ".to_string();
ui.label(
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn main_thread(
if let Ok(file_path) = save_rx.recv_timeout(Duration::from_millis(10)) {
let print_index = print_to_console(
&print_lock,
Print::TASK(format!("saving data file to {:?} ...", file_path)),
Print::Task(format!("saving data file to {:?} ...", file_path)),
);
match save_to_csv(&data, &file_path) {
Ok(_) => {
Expand All @@ -109,7 +109,7 @@ fn main_thread(
Err(e) => {
print_to_console(
&print_lock,
Print::ERROR(format!("failed to save file: {e:?}")),
Print::Error(format!("failed to save file: {e:?}")),
);
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ fn main() {
let baud_lock = Arc::new(RwLock::new(gui_settings.baud));
let raw_data_lock = Arc::new(RwLock::new(vec![Packet::default()]));
let data_lock = Arc::new(RwLock::new(DataContainer::default()));
let print_lock = Arc::new(RwLock::new(vec![Print::EMPTY]));
let print_lock = Arc::new(RwLock::new(vec![Print::Empty]));
let connected_lock = Arc::new(RwLock::new(false));

let (save_tx, save_rx): (Sender<PathBuf>, Receiver<PathBuf>) = mpsc::channel();
Expand Down
4 changes: 2 additions & 2 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn serial_thread(
device = "".to_string();
print_to_console(
&print_lock,
Print::ERROR(format!("Error connecting: {}", err)),
Print::Error(format!("Error connecting: {}", err)),
);
continue;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ pub fn serial_thread(
if reconnect || !dev_is_con {
print_to_console(
&print_lock,
Print::ERROR(format!("disconnected from serial port: {}", device)),
Print::Error(format!("disconnected from serial port: {}", device)),
);
if let Ok(mut write_guard) = device_lock.write() {
*write_guard = "".to_string();
Expand Down