1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-19 14:25:13 +03:00

moving request for MSP_BOXNAMES & MSP_BOX

to aux tab, as the content can dynamically change (while changing
configuration via CLI)
#12
This commit is contained in:
cTn 2013-12-05 09:54:49 +01:00
parent 71677c2b68
commit 607abbd046
2 changed files with 72 additions and 71 deletions

View file

@ -203,9 +203,6 @@ function onOpen(openInfo) {
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID); send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID);
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING); send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING);
send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES);
send_message(MSP_codes.MSP_BOX, MSP_codes.MSP_BOX);
}, connection_delay * 1000); }, connection_delay * 1000);
} else { } else {
console.log('Failed to open serial port'); console.log('Failed to open serial port');

View file

@ -2,78 +2,82 @@ function tab_initialize_auxiliary_configuration() {
ga_tracker.sendAppView('Auxiliary Configuration'); ga_tracker.sendAppView('Auxiliary Configuration');
GUI.active_tab = 'auxiliary_configuration'; GUI.active_tab = 'auxiliary_configuration';
// generate table from the supplied AUX names and AUX data send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() {
for (var i = 0; i < AUX_CONFIG.length; i++) { send_message(MSP_codes.MSP_BOX, MSP_codes.MSP_BOX, false, function() {
$('.tab-auxiliary_configuration .boxes > tbody:last').append( // generate table from the supplied AUX names and AUX data
'<tr>' + for (var i = 0; i < AUX_CONFIG.length; i++) {
'<td class="name">' + AUX_CONFIG[i] + '</td>' + $('.tab-auxiliary_configuration .boxes > tbody:last').append(
box_check(AUX_CONFIG_values[i], 0) + '<tr>' +
box_check(AUX_CONFIG_values[i], 1) + '<td class="name">' + AUX_CONFIG[i] + '</td>' +
box_check(AUX_CONFIG_values[i], 2) + box_check(AUX_CONFIG_values[i], 0) +
box_check(AUX_CONFIG_values[i], 1) +
box_check(AUX_CONFIG_values[i], 2) +
box_check(AUX_CONFIG_values[i], 3) + box_check(AUX_CONFIG_values[i], 3) +
box_check(AUX_CONFIG_values[i], 4) + box_check(AUX_CONFIG_values[i], 4) +
box_check(AUX_CONFIG_values[i], 5) + box_check(AUX_CONFIG_values[i], 5) +
box_check(AUX_CONFIG_values[i], 6) + box_check(AUX_CONFIG_values[i], 6) +
box_check(AUX_CONFIG_values[i], 7) + box_check(AUX_CONFIG_values[i], 7) +
box_check(AUX_CONFIG_values[i], 8) + box_check(AUX_CONFIG_values[i], 8) +
box_check(AUX_CONFIG_values[i], 9) + box_check(AUX_CONFIG_values[i], 9) +
box_check(AUX_CONFIG_values[i], 10) + box_check(AUX_CONFIG_values[i], 10) +
box_check(AUX_CONFIG_values[i], 11) + box_check(AUX_CONFIG_values[i], 11) +
'</tr>' '</tr>'
); );
} }
// UI Hooks // UI Hooks
$('.tab-auxiliary_configuration .boxes input').change(function() { $('.tab-auxiliary_configuration .boxes input').change(function() {
// if any of the fields changed, unlock update button // if any of the fields changed, unlock update button
$('a.update').addClass('active'); $('a.update').addClass('active');
}); });
$('.tab-auxiliary_configuration a.update').click(function() { $('.tab-auxiliary_configuration a.update').click(function() {
if ($(this).hasClass('active')) { if ($(this).hasClass('active')) {
// catch the input changes // catch the input changes
var main_needle = 0; var main_needle = 0;
var needle = 0; var needle = 0;
$('.tab-auxiliary_configuration .boxes input').each(function() { $('.tab-auxiliary_configuration .boxes input').each(function() {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
AUX_CONFIG_values[main_needle] = bit_set(AUX_CONFIG_values[main_needle], needle); AUX_CONFIG_values[main_needle] = bit_set(AUX_CONFIG_values[main_needle], needle);
} else { } else {
AUX_CONFIG_values[main_needle] = bit_clear(AUX_CONFIG_values[main_needle], needle); AUX_CONFIG_values[main_needle] = bit_clear(AUX_CONFIG_values[main_needle], needle);
} }
needle++; needle++;
if (needle >= 12) { // 4 aux * 3 checkboxes = 12 bits per line if (needle >= 12) { // 4 aux * 3 checkboxes = 12 bits per line
main_needle++; main_needle++;
needle = 0; needle = 0;
}
});
// send over the data
var AUX_val_buffer_out = new Array();
var needle = 0;
for (var i = 0; i < AUX_CONFIG_values.length; i++) {
AUX_val_buffer_out[needle++] = lowByte(AUX_CONFIG_values[i]);
AUX_val_buffer_out[needle++] = highByte(AUX_CONFIG_values[i]);
}
send_message(MSP_codes.MSP_SET_BOX, AUX_val_buffer_out);
// Save changes to EEPROM
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
// remove the active status
$(this).removeClass('active');
} }
}); });
// send over the data // enable data pulling
var AUX_val_buffer_out = new Array(); GUI.interval_add('aux_data_poll', aux_data_poll, 50, true);
});
var needle = 0;
for (var i = 0; i < AUX_CONFIG_values.length; i++) {
AUX_val_buffer_out[needle++] = lowByte(AUX_CONFIG_values[i]);
AUX_val_buffer_out[needle++] = highByte(AUX_CONFIG_values[i]);
}
send_message(MSP_codes.MSP_SET_BOX, AUX_val_buffer_out);
// Save changes to EEPROM
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
// remove the active status
$(this).removeClass('active');
}
}); });
// enable data pulling
timers.push(setInterval(aux_data_poll, 50));
} }
function aux_data_poll() { function aux_data_poll() {