fix: correct 3D fingertip sampling and PCB mapping

This commit is contained in:
lenn
2026-07-27 17:25:30 +08:00
parent 0d1296c482
commit d93a6694cf
6 changed files with 527 additions and 272 deletions

View File

@@ -53,7 +53,7 @@ pub struct ConnectPanelState {
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum SerialMode {
Finger,
// Finger3D,
Finger3D,
Hand,
}
@@ -61,16 +61,26 @@ impl SerialMode {
pub fn baud_rate(self) -> u32 {
match self {
SerialMode::Finger => 921_600,
SerialMode::Hand => 1_152_000,
SerialMode::Finger3D => 921_600,
SerialMode::Hand => 921_600,
}
}
pub fn protocol(self) -> SerialProtocol {
match self {
SerialMode::Finger => SerialProtocol::TactileA,
SerialMode::Finger3D => SerialProtocol::TactileA,
SerialMode::Hand => SerialProtocol::HandGateway,
}
}
pub fn matrix_shape(self) -> (u32, u32) {
match self {
SerialMode::Finger => (12, 7),
SerialMode::Finger3D => (12, 9),
SerialMode::Hand => (12, 7),
}
}
}
#[derive(Clone, Copy, PartialEq, Eq)]
@@ -483,11 +493,11 @@ fn draw_config_bar_mode(ui: &mut egui::Ui, config: &mut ConfigPanelState) -> Opt
if mode_button(ui, &mut config.mode, SerialMode::Finger, "指尖模块") {
changed_to = Some(SerialMode::Finger)
}
if mode_button(ui, &mut config.mode, SerialMode::Hand, "手掌模块") {
changed_to = Some(SerialMode::Hand)
}
// mode_button(ui, &mut config.mode, SerialMode::Model, "模型");
if mode_button(ui, &mut config.mode, SerialMode::Finger3D, "3D指尖") {
changed_to = Some(SerialMode::Finger3D)
}
// Legacy reconnect controls. Current sensors run fixed 921600 baud without auto-reconnect UI.
// ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
// ui.checkbox(&mut config.auto_reconnect, "自动");
@@ -566,10 +576,11 @@ fn draw_config_bar_connection(
if is_connected {
connection.disconnect();
} else if !config.port.is_empty() {
let (rows, cols) = config.mode.matrix_shape();
connection.connect(
&config.port,
12,
7,
rows,
cols,
config.mode.baud_rate(),
config.mode.protocol(),
recorder.clone(),
@@ -637,10 +648,11 @@ fn draw_connection_row(
if is_connected {
connection.disconnect();
} else if !config.port.is_empty() {
let (rows, cols) = config.mode.matrix_shape();
connection.connect(
&config.port,
12,
7,
rows,
cols,
config.mode.baud_rate(),
config.mode.protocol(),
recorder.clone(),
@@ -758,6 +770,9 @@ fn draw_mode_body(
// });
draw_status_bytes_row(ui, conn_state, stats);
}
SerialMode::Finger3D => {
draw_status_bytes_row(ui, conn_state, stats);
}
SerialMode::Hand => {
// Legacy manual-TX controls for older hand-module debugging:
// ui.horizontal(|ui| {
@@ -969,14 +984,17 @@ const HAND_FORCE_PANEL_MAX_HEIGHT: f32 = 190.0;
const HAND_FORCE_PANEL_GAP: f32 = 12.0;
const HAND_FORCE_PANEL_SIDE_MARGIN: f32 = 24.0;
const HAND_FORCE_PANEL_VERTICAL_MARGIN: f32 = 28.0;
const HAND_FORCE_PANEL_TITLES: [(&str, &str); 7] = [
("T1", "拇指"),
("T2", "食指"),
("T3", "中指"),
("T4", "无名指"),
("T5", "小指"),
("P1", "掌心横区"),
("P2", "掌心纵区"),
const HAND_FORCE_PANEL_TITLES: [(&str, &str); 10] = [
("T", "顶部 2×4"),
("L3", "左侧 3×1"),
("L5", "左侧 5×1"),
("L8", "左侧 8×1"),
("L10", "左侧 10×1"),
("C", "中央 11×4"),
("R3", "右侧 3×1"),
("R5", "右侧 5×1"),
("R8", "右侧 8×1"),
("R10", "右侧 10×1"),
];
fn has_recent_resultant_force(values: &[f32]) -> bool {
@@ -1002,7 +1020,7 @@ pub fn draw_hand_force_panels(ctx: &egui::Context, visible: bool, histories: &[V
.max(HAND_FORCE_PANEL_MIN_WIDTH.min(side_width));
let left_x = screen.left() + side_margin;
let right_x = screen.right() - side_margin - panel_width;
let left_count = 4usize;
let left_count = 5usize;
let right_count = HAND_FORCE_PANEL_TITLES.len() - left_count;
let available_height =
(screen.height() - layout::TITLE_BAR_HEIGHT - vertical_margin * 2.0).max(0.0);