plot update rate can be now adjusted in RX tab

10.3.x-maintenance
cTn 2014-03-06 19:50:01 +01:00
parent 52559cf9ec
commit 3f6f363d1b
3 changed files with 98 additions and 64 deletions

View File

@ -111,4 +111,10 @@
}
.tab-receiver .update.success {
border: 1px solid #43c84d;
}
.tab-receiver select[name="rx_refresh_rate"] {
float: right;
margin-right: 20px;
border: 1px solid silver;
}

View File

@ -74,6 +74,17 @@
</div>
</div>
<div class="clear-both"></div>
<select title="Plot refresh rate" name="rx_refresh_rate">
<option value="10">10 ms</option>
<option value="20">20 ms</option>
<option value="30">30 ms</option>
<option value="40">40 ms</option>
<option value="50" selected="selected">50 ms</option>
<option value="100">100 ms</option>
<option value="250">250 ms</option>
<option value="500">500 ms</option>
<option value="1000">1000 ms</option>
</select>
<div id="RX_plot">
</div>
</div>

View File

@ -53,8 +53,15 @@ function tab_initialize_receiver() {
}
};
// UI Hooks
chrome.storage.local.get('rx_refresh_rate', function(result) {
if (typeof result.rx_refresh_rate != 'undefined') {
$('select[name="rx_refresh_rate"]').val(result.rx_refresh_rate).change();
} else {
$('select[name="rx_refresh_rate"]').change(); // start with default value
}
});
// UI Hooks
// curves
$('.tunings .throttle input').change(function() {
setTimeout(function() {
@ -152,73 +159,83 @@ function tab_initialize_receiver() {
});
});
// enable RC data pulling
GUI.interval_add('receiver_poll', function() {
// Update UI with latest data
$('.tab-receiver meter:eq(0)').val(RC.throttle);
$('.tab-receiver .value:eq(0)').html(RC.throttle);
$('select[name="rx_refresh_rate"]').change(function() {
var plot_update_rate = parseInt($(this).val());
$('.tab-receiver meter:eq(1)').val(RC.pitch);
$('.tab-receiver .value:eq(1)').html(RC.pitch);
// timer initialization
GUI.interval_remove('receiver_poll');
$('.tab-receiver meter:eq(2)').val(RC.roll);
$('.tab-receiver .value:eq(2)').html(RC.roll);
$('.tab-receiver meter:eq(3)').val(RC.yaw);
$('.tab-receiver .value:eq(3)').html(RC.yaw);
$('.tab-receiver meter:eq(4)').val(RC.AUX1);
$('.tab-receiver .value:eq(4)').html(RC.AUX1);
$('.tab-receiver meter:eq(5)').val(RC.AUX2);
$('.tab-receiver .value:eq(5)').html(RC.AUX2);
$('.tab-receiver meter:eq(6)').val(RC.AUX3);
$('.tab-receiver .value:eq(6)').html(RC.AUX3);
$('.tab-receiver meter:eq(7)').val(RC.AUX4);
$('.tab-receiver .value:eq(7)').html(RC.AUX4);
// push latest data to the main array
RX_plot_data[0].push([samples_i, RC.throttle]);
RX_plot_data[1].push([samples_i, RC.pitch]);
RX_plot_data[2].push([samples_i, RC.roll]);
RX_plot_data[3].push([samples_i, RC.yaw]);
RX_plot_data[4].push([samples_i, RC.AUX1]);
RX_plot_data[5].push([samples_i, RC.AUX2]);
RX_plot_data[6].push([samples_i, RC.AUX3]);
RX_plot_data[7].push([samples_i, RC.AUX4]);
// Remove old data from array
while (RX_plot_data[0].length > 300) {
RX_plot_data[0].shift();
RX_plot_data[1].shift();
RX_plot_data[2].shift();
RX_plot_data[3].shift();
RX_plot_data[4].shift();
RX_plot_data[5].shift();
RX_plot_data[6].shift();
RX_plot_data[7].shift();
};
// redraw plot
Flotr.draw(e_RX_plot, [
{data: RX_plot_data[0], label: "THROTTLE"},
{data: RX_plot_data[1], label: "PITCH"},
{data: RX_plot_data[2], label: "ROLL"},
{data: RX_plot_data[3], label: "YAW"},
{data: RX_plot_data[4], label: "AUX1"},
{data: RX_plot_data[5], label: "AUX2"},
{data: RX_plot_data[6], label: "AUX3"},
{data: RX_plot_data[7], label: "AUX4"} ], RX_plot_options);
// enable RC data pulling
GUI.interval_add('receiver_poll', function() {
// Update UI with latest data
$('.tab-receiver meter:eq(0)').val(RC.throttle);
$('.tab-receiver .value:eq(0)').html(RC.throttle);
samples_i++;
$('.tab-receiver meter:eq(1)').val(RC.pitch);
$('.tab-receiver .value:eq(1)').html(RC.pitch);
$('.tab-receiver meter:eq(2)').val(RC.roll);
$('.tab-receiver .value:eq(2)').html(RC.roll);
$('.tab-receiver meter:eq(3)').val(RC.yaw);
$('.tab-receiver .value:eq(3)').html(RC.yaw);
$('.tab-receiver meter:eq(4)').val(RC.AUX1);
$('.tab-receiver .value:eq(4)').html(RC.AUX1);
$('.tab-receiver meter:eq(5)').val(RC.AUX2);
$('.tab-receiver .value:eq(5)').html(RC.AUX2);
$('.tab-receiver meter:eq(6)').val(RC.AUX3);
$('.tab-receiver .value:eq(6)').html(RC.AUX3);
$('.tab-receiver meter:eq(7)').val(RC.AUX4);
$('.tab-receiver .value:eq(7)').html(RC.AUX4);
// push latest data to the main array
RX_plot_data[0].push([samples_i, RC.throttle]);
RX_plot_data[1].push([samples_i, RC.pitch]);
RX_plot_data[2].push([samples_i, RC.roll]);
RX_plot_data[3].push([samples_i, RC.yaw]);
RX_plot_data[4].push([samples_i, RC.AUX1]);
RX_plot_data[5].push([samples_i, RC.AUX2]);
RX_plot_data[6].push([samples_i, RC.AUX3]);
RX_plot_data[7].push([samples_i, RC.AUX4]);
// Remove old data from array
while (RX_plot_data[0].length > 300) {
RX_plot_data[0].shift();
RX_plot_data[1].shift();
RX_plot_data[2].shift();
RX_plot_data[3].shift();
RX_plot_data[4].shift();
RX_plot_data[5].shift();
RX_plot_data[6].shift();
RX_plot_data[7].shift();
};
// redraw plot
Flotr.draw(e_RX_plot, [
{data: RX_plot_data[0], label: "THROTTLE"},
{data: RX_plot_data[1], label: "PITCH"},
{data: RX_plot_data[2], label: "ROLL"},
{data: RX_plot_data[3], label: "YAW"},
{data: RX_plot_data[4], label: "AUX1"},
{data: RX_plot_data[5], label: "AUX2"},
{data: RX_plot_data[6], label: "AUX3"},
{data: RX_plot_data[7], label: "AUX4"} ], RX_plot_options);
samples_i++;
// Request new data
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC);
}, plot_update_rate, true);
// Request new data
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC);
}, 50, true);
chrome.storage.local.set({'rx_refresh_rate': plot_update_rate});
});
});
});
});