mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
initial push of Rust version
This commit is contained in:
parent
fba1dfc2be
commit
138b1e07a8
5 changed files with 262 additions and 0 deletions
38
src/main.rs
Normal file
38
src/main.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
mod sync_logic;
|
||||
mod serial_input;
|
||||
mod ui;
|
||||
|
||||
use crate::sync_logic::LtcState;
|
||||
use crate::serial_input::start_serial_thread;
|
||||
use crate::ui::start_ui;
|
||||
|
||||
use std::sync::{Arc, Mutex, mpsc};
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
println!("🧪 Timeturner startup...");
|
||||
|
||||
let (tx, rx) = mpsc::channel();
|
||||
println!("✅ Channel created");
|
||||
|
||||
let ltc_state = Arc::new(Mutex::new(LtcState::new()));
|
||||
println!("✅ State initialised");
|
||||
|
||||
start_serial_thread("/dev/ttyACM0", 115200, tx.clone(), ltc_state.clone());
|
||||
println!("🚀 Serial thread launched");
|
||||
|
||||
let ui_state = ltc_state.clone();
|
||||
thread::spawn(move || {
|
||||
println!("🖥️ UI thread started");
|
||||
start_ui(ui_state);
|
||||
});
|
||||
|
||||
println!("📡 Main thread entering loop...");
|
||||
|
||||
for frame in rx {
|
||||
println!(
|
||||
"📥 Received LTC frame: {:02}:{:02}:{:02}:{:02} [{}]",
|
||||
frame.hours, frame.minutes, frame.seconds, frame.frames, frame.status
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue