Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion FilterReview/FilterReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ function reset() {
document.getElementById("filter_version_1").checked = true
document.getElementById("calculate").disabled = true
document.getElementById("calculate_filters").disabled = true
document.getElementById("EstimateHint").hidden = true
document.getElementById("OpenFilterTool").disabled = true
document.getElementById("SaveParams").disabled = true
document.getElementById("LoadParams").disabled = true
Expand Down Expand Up @@ -1833,6 +1834,61 @@ function update_hidden(source) {

Plotly.redraw("FFTPlot")

// Hide estimate hint once any estimate is shown
if (!document.getElementById("EstimateHint").hidden) {
update_estimate_hint()
}

}

// Get estimated post filter checkboxes that can be selected
function get_estimate_checkboxes() {
let ret = []
for (let i = 0; i < 3; i++) {
// Estimate needs pre-filter data for this gyro
if (find_instance(i, false) == null) {
continue
}
for (let j = 0; j < axis.length; j++) {
const checkbox = document.getElementById("Gyro" + i + "PostEst" + axis[j])
if (!checkbox.disabled) {
ret.push({ checkbox, gyro: i, axis: axis[j], axis_index: j })
}
}
}
return ret
}

// Prompt to show the estimated post filter lines if they are all hidden
function update_estimate_hint() {
const estimates = get_estimate_checkboxes()
const hidden = (estimates.length > 0) && !estimates.some((estimate) => estimate.checkbox.checked)
document.getElementById("EstimateHint").hidden = !hidden
}

// Show estimated post filter lines for the axes that are shown, or all if none are shown
function show_estimated() {
const estimates = get_estimate_checkboxes()
let shown = estimates.filter((estimate) => {
const pre = document.getElementById("Gyro" + estimate.gyro + "Pre" + estimate.axis)
const post = document.getElementById("Gyro" + estimate.gyro + "Post" + estimate.axis)
return pre.checked || post.checked
})
if (shown.length == 0) {
shown = estimates
}
for (const estimate of shown) {
estimate.checkbox.checked = true
fft_plot.data[get_FFT_data_index(estimate.gyro, 2, estimate.axis_index)].visible = true
}
Plotly.redraw("FFTPlot")
update_estimate_hint()
}

// Recalculate after filter parameter change
function recalculate_filters() {
re_calc()
update_estimate_hint()
}

function get_HNotch_param_names() {
Expand Down Expand Up @@ -2032,7 +2088,7 @@ async function load_parameters(file) {
}

filter_param_read()
re_calc()
recalculate_filters()
}

// Get selected filter version
Expand Down
15 changes: 9 additions & 6 deletions FilterReview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ <h1 style="text-align:center; margin-block-end: 0.25em;"><a href="" style="color
data-tippy-maxWidth='750px'/>
</legend>
<div style="display:grid;grid-template-columns:1fr 1fr;grid-template-rows:repeat(3,auto);grid-auto-flow:column;row-gap:2px">
<span title="Original filter implementation."><input type="radio" id="filter_version_1" name="filter_version" onchange="loading_call(re_calc)"><label for="filter_version_1">1.0</label></span>
<span title="New strategy when tracking frequencies under the minimum limit. Adds multi-source throttle notch and minimum frequency ratio."><input type="radio" id="filter_version_2" name="filter_version" onchange="loading_call(re_calc)"><label for="filter_version_2">2.0</label></span>
<span title="Quintuple (5) notch added but not functional."><input type="radio" id="filter_version_3" name="filter_version" onchange="loading_call(re_calc)"><label for="filter_version_3">3.0</label></span>
<span title="Quintuple (5) notch fully functional."><input type="radio" id="filter_version_4" name="filter_version" onchange="loading_call(re_calc)"><label for="filter_version_4">4.0</label></span>
<span title="Original filter implementation."><input type="radio" id="filter_version_1" name="filter_version" onchange="loading_call(recalculate_filters)"><label for="filter_version_1">1.0</label></span>
<span title="New strategy when tracking frequencies under the minimum limit. Adds multi-source throttle notch and minimum frequency ratio."><input type="radio" id="filter_version_2" name="filter_version" onchange="loading_call(recalculate_filters)"><label for="filter_version_2">2.0</label></span>
<span title="Quintuple (5) notch added but not functional."><input type="radio" id="filter_version_3" name="filter_version" onchange="loading_call(recalculate_filters)"><label for="filter_version_3">3.0</label></span>
<span title="Quintuple (5) notch fully functional."><input type="radio" id="filter_version_4" name="filter_version" onchange="loading_call(recalculate_filters)"><label for="filter_version_4">4.0</label></span>
</div>
</fieldset>
</td>
Expand Down Expand Up @@ -445,18 +445,21 @@ <h2 style="text-align:center">Filter Configuration
</fieldset>
</td>
<td>
<fieldset style="width:428px;height:70px">
<fieldset style="width:428px;min-height:70px">
<legend>Setup
<img id="TT" src="../images/question-circle.svg" style="width: 1em; vertical-align: bottom"
data-tippy-content='Recalculate filters after changing any parameters to update the estimated post filter spectrum. Save or load parameters to/from a param file.',
data-tippy-maxWidth='750px'/>
</legend>
<p>
<input type="button" id="calculate_filters" value="Recalculate filters" onclick="loading_call(re_calc)">
<input type="button" id="calculate_filters" value="Recalculate filters" onclick="loading_call(recalculate_filters)">
<input type="button" id="SaveParams" value="Save Parameters" onclick="save_parameters();">
<button class="styleClass" id="LoadParams" onclick="document.getElementById('LoadParamsbase').click()">Load Parameters</button>
<input type='file' id="LoadParamsbase" style="display:none" onchange="load_parameters(this.files[0]);">
</p>
<p id="EstimateHint" style="margin-block-start: 0" hidden>
Estimated post-filter lines are hidden. <input type="button" value="Show estimated" onclick="show_estimated()">
</p>
</fieldset>
</td>
</tr>
Expand Down
Loading