更新ui中
This commit is contained in:
@@ -24,6 +24,7 @@ pub enum SerialProtocol {
|
||||
|
||||
/// Runs the serial polling loop on the calling (background) thread.
|
||||
/// Sends decoded pressure matrix data (Vec<i32>) to the output channel.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn run_serial_loop(
|
||||
port: &mut dyn ReadWrite,
|
||||
rows: usize,
|
||||
@@ -73,11 +74,11 @@ fn run_tactile_a_loop(
|
||||
}
|
||||
|
||||
// Send poll request
|
||||
if let Ok(req_bytes) = codec.encode(&req_frame) {
|
||||
if port.write_all(&req_bytes).is_ok() {
|
||||
io_stats.tx_bytes += req_bytes.len() as u64;
|
||||
publish_stats(stats_tx, io_stats);
|
||||
}
|
||||
if let Ok(req_bytes) = codec.encode(&req_frame)
|
||||
&& port.write_all(&req_bytes).is_ok()
|
||||
{
|
||||
io_stats.tx_bytes += req_bytes.len() as u64;
|
||||
publish_stats(stats_tx, io_stats);
|
||||
}
|
||||
|
||||
// Read response with poll interval
|
||||
@@ -93,15 +94,15 @@ fn run_tactile_a_loop(
|
||||
publish_stats(stats_tx, io_stats);
|
||||
if let Ok(frames) = codec.decode(&buffer[..n], session_started_at) {
|
||||
for frame in frames {
|
||||
if let TactileAFrame::Rep(rep) = frame {
|
||||
if let Ok(vals) = TactileACodec::parse_data_frame(&rep.payload) {
|
||||
if let Some(recorder) = recorder {
|
||||
let pressures: Vec<u32> =
|
||||
vals.iter().map(|v| (*v).max(0) as u32).collect();
|
||||
recorder.add_frame(&pressures);
|
||||
}
|
||||
let _ = sample_tx.try_send(vals);
|
||||
if let TactileAFrame::Rep(rep) = frame
|
||||
&& let Ok(vals) = TactileACodec::parse_data_frame(&rep.payload)
|
||||
{
|
||||
if let Some(recorder) = recorder {
|
||||
let pressures: Vec<u32> =
|
||||
vals.iter().map(|v| (*v).max(0) as u32).collect();
|
||||
recorder.add_frame(&pressures);
|
||||
}
|
||||
let _ = sample_tx.try_send(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user