mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat(vr-ux,safety,perf): add VR quick menu, P0/P1 safety & perf fixes, unify on GPUI
This commit is contained in:
1 parent
c0bad51d3b
commit
0823a9e682
15 files changed
+1288
-3765
No files matched your search
+184
-28
@@ -175,6 +175,8 @@ impl SteamFrameGpuiApp {
|
||||
/// Synchronise l'état IHM avec le moteur FPV en minimisant au maximum la contention des verrous
|
||||
fn sync_from_engine(&mut self, window: &mut Window) -> bool {
|
||||
let mut changed = false;
|
||||
self.controls
|
||||
.set_preview_active(self.active_tab == ActiveTab::Cockpit);
|
||||
|
||||
// 1. Snapshot rapide avec maintien minimal du verrou monitor
|
||||
let (preview_frame_seq, new_frame_data) = {
|
||||
@@ -273,11 +275,20 @@ impl SteamFrameGpuiApp {
|
||||
(mon.preview_frame_seq, frame_data)
|
||||
}; // Verrou `engine_monitor` immédiatement libéré !
|
||||
|
||||
// 2. Conversion BGRA et allocation GPU hors du verrou monitor
|
||||
// 2. Conversion BGRA vectorisable (u32) et allocation GPU hors du verrou monitor
|
||||
if let Some((w, h, raw_arc)) = new_frame_data {
|
||||
let mut raw_buf = (*raw_arc).clone();
|
||||
for pixel in raw_buf.chunks_exact_mut(4) {
|
||||
pixel.swap(0, 2);
|
||||
// SAFETY: `align_to_mut::<u32>` découpe proprement préfixe, tranche u32 alignée et suffixe.
|
||||
let (head, pixels_u32, tail) = unsafe { raw_buf.align_to_mut::<u32>() };
|
||||
if head.is_empty() && tail.is_empty() {
|
||||
for px in pixels_u32 {
|
||||
let v = *px;
|
||||
*px = (v & 0xFF00_FF00) | ((v & 0x00FF_0000) >> 16) | ((v & 0x0000_00FF) << 16);
|
||||
}
|
||||
} else {
|
||||
for pixel in raw_buf.chunks_exact_mut(4) {
|
||||
pixel.swap(0, 2);
|
||||
}
|
||||
}
|
||||
if let Some(img_buf) = RgbaImage::from_raw(w, h, raw_buf) {
|
||||
let frame = Frame::new(img_buf);
|
||||
@@ -330,17 +341,19 @@ impl SteamFrameGpuiApp {
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("scripts/setup_usb_rndis.sh")))
|
||||
.filter(|p| p.exists())
|
||||
.unwrap_or_else(|| {
|
||||
let candidate = std::path::PathBuf::from("scripts/setup_usb_rndis.sh");
|
||||
if candidate.exists() {
|
||||
candidate
|
||||
.or_else(|| {
|
||||
let installed = std::path::PathBuf::from("/usr/share/steamframe-fpv/scripts/setup_usb_rndis.sh");
|
||||
if installed.exists() {
|
||||
Some(installed)
|
||||
} else {
|
||||
std::path::PathBuf::from(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/scripts/setup_usb_rndis.sh"
|
||||
))
|
||||
let local = std::path::PathBuf::from("scripts/setup_usb_rndis.sh");
|
||||
local.exists().then_some(local)
|
||||
}
|
||||
});
|
||||
let Some(script_path) = script_path else {
|
||||
log::error!("[USB RNDIS] Script setup_usb_rndis.sh introuvable à côté du binaire ni dans /usr/share/steamframe-fpv/scripts.");
|
||||
return;
|
||||
};
|
||||
std::thread::spawn(move || {
|
||||
match Command::new("bash").arg(&script_path).output() {
|
||||
Ok(out) => {
|
||||
@@ -358,7 +371,13 @@ impl SteamFrameGpuiApp {
|
||||
|
||||
fn configure_radxa_ssh(&self) {
|
||||
let ch = self.cfg.wifi_channel;
|
||||
let ip = self.cfg.radxa_vrx_ip.clone();
|
||||
let Ok(ip) = self.cfg.radxa_vrx_ip.trim().parse::<std::net::IpAddr>() else {
|
||||
log::error!(
|
||||
"[Radxa Zero 3W] Adresse IP invalide pour SSH : '{}'",
|
||||
self.cfg.radxa_vrx_ip
|
||||
);
|
||||
return;
|
||||
};
|
||||
log::info!(
|
||||
"[Radxa Zero 3W] Configuration du canal 5.8GHz={} sur root@{}...",
|
||||
ch,
|
||||
@@ -371,10 +390,12 @@ impl SteamFrameGpuiApp {
|
||||
std::thread::spawn(move || {
|
||||
match Command::new("ssh")
|
||||
.args([
|
||||
"-o",
|
||||
"BatchMode=yes",
|
||||
"-o",
|
||||
"ConnectTimeout=2",
|
||||
"-o",
|
||||
"StrictHostKeyChecking=no",
|
||||
"StrictHostKeyChecking=accept-new",
|
||||
"--",
|
||||
&format!("root@{}", ip),
|
||||
&remote_cmd,
|
||||
@@ -800,6 +821,20 @@ impl SteamFrameGpuiApp {
|
||||
rgb(COLOR_CYAN),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.id("btn_vr_menu_quick")
|
||||
.cursor_pointer()
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
this.controls.toggle_vr_menu();
|
||||
cx.notify();
|
||||
}))
|
||||
.child(self.render_toggle_pill(
|
||||
"📋 Menu VR",
|
||||
self.controls.is_vr_menu_open(),
|
||||
rgb(COLOR_ORANGE),
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.id("btn_tare_quick")
|
||||
@@ -2094,24 +2129,66 @@ impl SteamFrameGpuiApp {
|
||||
}),
|
||||
)),
|
||||
))
|
||||
// Lentille et FOV
|
||||
// Champ de vision, Lentille k1/k2 et Distance virtuelle (réglables à chaud en VR)
|
||||
.child(self.render_setting_row(
|
||||
"Champ de Vision & Optique",
|
||||
"Optique & Écran VR (Réglage à chaud)",
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||||
.child(format!(
|
||||
"FOV : {}° | Lentille : k1={:.2}, k2={:.2}",
|
||||
self.cfg.camera_fov_deg, self.cfg.lens_k1, self.cfg.lens_k2
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_2()
|
||||
.p_2p5()
|
||||
.rounded_md()
|
||||
.bg(rgb(COLOR_BG_DARK))
|
||||
.border_1()
|
||||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||||
.child(self.render_optical_stepper_row(
|
||||
"opt_fov",
|
||||
"FOV Caméra",
|
||||
format!("{:.0}°", self.cfg.camera_fov_deg),
|
||||
|cfg, step| {
|
||||
cfg.camera_fov_deg =
|
||||
(cfg.camera_fov_deg + step * 5.0).clamp(70.0, 180.0);
|
||||
},
|
||||
cx,
|
||||
))
|
||||
.child(self.render_optical_stepper_row(
|
||||
"opt_k1",
|
||||
"Distorsion k1",
|
||||
format!("{:+.2}", self.cfg.lens_k1),
|
||||
|cfg, step| {
|
||||
cfg.lens_k1 = (((cfg.lens_k1 + step * 0.02) * 100.0)
|
||||
.round()
|
||||
/ 100.0)
|
||||
.clamp(-0.50, 0.50);
|
||||
},
|
||||
cx,
|
||||
))
|
||||
.child(self.render_optical_stepper_row(
|
||||
"opt_k2",
|
||||
"Distorsion k2",
|
||||
format!("{:+.2}", self.cfg.lens_k2),
|
||||
|cfg, step| {
|
||||
cfg.lens_k2 = (((cfg.lens_k2 + step * 0.01) * 100.0)
|
||||
.round()
|
||||
/ 100.0)
|
||||
.clamp(-0.25, 0.25);
|
||||
},
|
||||
cx,
|
||||
))
|
||||
.child(self.render_optical_stepper_row(
|
||||
"opt_dist",
|
||||
"Distance Écran",
|
||||
format!("{:.1} m", self.cfg.screen_distance_m),
|
||||
|cfg, step| {
|
||||
cfg.screen_distance_m = (((cfg.screen_distance_m
|
||||
+ step * 0.2)
|
||||
* 10.0)
|
||||
.round()
|
||||
/ 10.0)
|
||||
.clamp(0.8, 4.0);
|
||||
},
|
||||
cx,
|
||||
)),
|
||||
))
|
||||
// Distance virtuelle
|
||||
.child(self.render_setting_row(
|
||||
"Distance Virtuelle Écran",
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||||
.child(format!("{:.1} mètres", self.cfg.screen_distance_m)),
|
||||
)),
|
||||
))
|
||||
// 3.4 Carte Télémétrie OSD & MAVLink
|
||||
@@ -2425,6 +2502,85 @@ impl SteamFrameGpuiApp {
|
||||
self.controls.set_gear_speed_limits(def);
|
||||
}
|
||||
|
||||
fn sync_optical_params(&self) {
|
||||
self.controls.update_optical_params(LiveOpticalParams {
|
||||
projection_mode: ProjectionMode::from_str(&self.cfg.projection_mode),
|
||||
camera_fov_deg: self.cfg.camera_fov_deg,
|
||||
lens_k1: self.cfg.lens_k1,
|
||||
lens_k2: self.cfg.lens_k2,
|
||||
screen_distance_m: self.cfg.screen_distance_m,
|
||||
screen_width_m: self.cfg.screen_width_m,
|
||||
});
|
||||
}
|
||||
|
||||
fn render_optical_stepper_row(
|
||||
&self,
|
||||
id_prefix: &'static str,
|
||||
label: &'static str,
|
||||
value_text: String,
|
||||
mutator: fn(&mut AppConfig, f32),
|
||||
cx: &mut Context<Self>,
|
||||
) -> impl IntoElement {
|
||||
let step_btn = |suffix: &'static str, txt: &'static str, step: f32| {
|
||||
let btn_id = gpui::SharedString::from(format!("btn_opt_{}_{}", id_prefix, suffix));
|
||||
div()
|
||||
.id(btn_id)
|
||||
.px_2p5()
|
||||
.py_1()
|
||||
.rounded_md()
|
||||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||||
.border_1()
|
||||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||||
.text_xs()
|
||||
.font_weight(gpui::FontWeight::BOLD)
|
||||
.cursor_pointer()
|
||||
.on_click(cx.listener(move |this, _, _, cx| {
|
||||
mutator(&mut this.cfg, step);
|
||||
this.sync_optical_params();
|
||||
cx.notify();
|
||||
}))
|
||||
.child(txt)
|
||||
};
|
||||
|
||||
div()
|
||||
.flex()
|
||||
.flex_wrap()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||||
.child(label),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_1p5()
|
||||
.child(step_btn("m2", "−−", -2.0))
|
||||
.child(step_btn("m1", "−", -1.0))
|
||||
.child(
|
||||
div()
|
||||
.w(px(64.0))
|
||||
.py_0p5()
|
||||
.rounded_md()
|
||||
.bg(rgb(COLOR_SURFACE_CARD))
|
||||
.border_1()
|
||||
.border_color(rgb(COLOR_CYAN))
|
||||
.text_xs()
|
||||
.font_weight(gpui::FontWeight::BOLD)
|
||||
.text_color(rgb(COLOR_CYAN))
|
||||
.flex()
|
||||
.justify_center()
|
||||
.child(value_text),
|
||||
)
|
||||
.child(step_btn("p1", "+", 1.0))
|
||||
.child(step_btn("p2", "++", 2.0)),
|
||||
)
|
||||
}
|
||||
|
||||
fn render_gear_stepper_row(
|
||||
&self,
|
||||
id_prefix: &'static str,
|
||||
|
||||
Reference in new issue
Block a user