feat: measure distortion
Cherry-picked from commit 0de32f5
, on the branch Vectornaut:near_miss.
This commit is contained in:
parent
a1b7c1fcb0
commit
349dae24ab
3 changed files with 60 additions and 1 deletions
|
@ -111,6 +111,28 @@ fn StepInput() -> View {
|
|||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn DistortionGauge() -> View {
|
||||
let state = use_context::<AppState>();
|
||||
let total_distortion = create_memo(move || {
|
||||
state.assembly.regulators.with(|regs| {
|
||||
let mut total = 0.0;
|
||||
for reg in regs {
|
||||
if let Some(distortion) = reg.distortion() {
|
||||
total += distortion.get();
|
||||
}
|
||||
}
|
||||
total
|
||||
})
|
||||
});
|
||||
|
||||
view! {
|
||||
div(id = "distortion-gauge") {
|
||||
"Distortion: " (total_distortion.with(|distort| distort.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn into_log10_time_point((step, value): (usize, f64)) -> Vec<Option<f64>> {
|
||||
vec![
|
||||
Some(step as f64),
|
||||
|
@ -315,6 +337,7 @@ pub fn Diagnostics() -> View {
|
|||
}
|
||||
DiagnosticsPanel(name = "loss") { LossHistory {} }
|
||||
DiagnosticsPanel(name = "spectrum") { SpectrumHistory {} }
|
||||
DistortionGauge {}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue