Improve hand mode panels and recording

This commit is contained in:
lenn
2026-07-01 17:08:07 +08:00
parent 1ed729f8da
commit da77f2f194
5 changed files with 120 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ use std::time::Duration;
use crossbeam_channel::{self, Receiver, Sender, TryRecvError};
use crate::recording::Recorder;
use crate::serial_core::serial::{
SerialIoStats, SerialPortReadWrite, SerialProtocol, run_serial_loop,
};
@@ -83,6 +84,7 @@ impl ConnectionManager {
cols: u32,
baud_rate: u32,
protocol: SerialProtocol,
recorder: Recorder,
) {
self.disconnect();
self.set_state(ConnectionState::Connecting);
@@ -108,6 +110,7 @@ impl ConnectionManager {
&sample_tx,
&stats_tx,
&latest_sample,
recorder,
);
if let Err(e) = result {
eprintln!("[connection] device loop error: {e}");
@@ -187,9 +190,10 @@ fn run_device_loop(
sample_tx: &Sender<Vec<i32>>,
stats_tx: &Sender<SerialIoStats>,
latest_sample: &Arc<Mutex<Option<PressureSample>>>,
recorder: Recorder,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let port = serialport::new(port_name, baud_rate)
.timeout(Duration::from_millis(100))
.timeout(Duration::from_millis(1))
.open()?;
*state.lock().unwrap() = ConnectionState::Connected;
@@ -205,6 +209,7 @@ fn run_device_loop(
cancel_rx,
sample_tx,
Some(stats_tx),
Some(&recorder),
);
if let Ok(mut latest) = latest_sample.lock() {