Skip to content

Commit

Permalink
Merge branch 'main' into add_color_picker
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus authored Oct 14, 2024
2 parents f41cf1d + 67bf086 commit f0770c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ use crate::toggle::toggle;
use crate::FileOptions;
use crate::{APP_INFO, PREFS_KEY};

const MAX_FPS: f64 = 60.0;

const DEFAULT_FONT_ID: FontId = FontId::new(14.0, FontFamily::Monospace);
pub const RIGHT_PANEL_WIDTH: f32 = 350.0;
const BAUD_RATES: &[u32] = &[
Expand Down Expand Up @@ -494,8 +492,6 @@ impl MyApp {
self.command = self.history[self.index].clone();
}
}

ctx.request_repaint()
});
ui.add_space(left_border);
});
Expand Down Expand Up @@ -979,8 +975,6 @@ impl eframe::App for MyApp {
eprintln!("Image saved to {path:?}.");
}
}

std::thread::sleep(Duration::from_millis((1000.0 / MAX_FPS) as u64));
}

fn save(&mut self, _storage: &mut dyn Storage) {
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fn split(payload: &str) -> Vec<f32> {
}

fn main_thread(
sync_tx: Sender<bool>,
data_lock: Arc<RwLock<DataContainer>>,
print_lock: Arc<RwLock<Vec<Print>>>,
raw_data_rx: Receiver<Packet>,
Expand All @@ -65,6 +66,7 @@ fn main_thread(

if let Ok(packet) = raw_data_rx.recv_timeout(Duration::from_millis(1)) {
if !packet.payload.is_empty() {
sync_tx.send(true).expect("unable to send sync tx");
data.raw_traffic.push(packet.clone());
let split_data = split(&packet.payload);
if data.dataset.is_empty() || failed_format_counter > 10 {
Expand Down Expand Up @@ -134,6 +136,7 @@ fn main() {
let (send_tx, send_rx): (Sender<String>, Receiver<String>) = mpsc::channel();
let (clear_tx, clear_rx): (Sender<bool>, Receiver<bool>) = mpsc::channel();
let (raw_data_tx, raw_data_rx): (Sender<Packet>, Receiver<Packet>) = mpsc::channel();
let (sync_tx, sync_rx): (Sender<bool>, Receiver<bool>) = mpsc::channel();

let serial_device_lock = device_lock.clone();
let serial_devices_lock = devices_lock.clone();
Expand All @@ -158,6 +161,7 @@ fn main() {
println!("starting main thread..");
let _main_thread_handler = thread::spawn(|| {
main_thread(
sync_tx,
main_data_lock,
main_print_lock,
raw_data_rx,
Expand Down Expand Up @@ -191,6 +195,15 @@ fn main() {
egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular);
_cc.egui_ctx.set_fonts(fonts);
_cc.egui_ctx.set_visuals(Visuals::dark());

let repaint_signal = _cc.egui_ctx.clone();
thread::spawn(move || loop {
if let Ok(_) = sync_rx.recv() {
println!("requested repaint!");
repaint_signal.request_repaint();
}
});

Ok(Box::new(MyApp::new(
gui_print_lock,
gui_data_lock,
Expand Down

0 comments on commit f0770c4

Please sign in to comment.