1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 20:10:11 +03:00

callback based upload for restoring settings

This commit is contained in:
cTn 2014-01-15 14:31:03 +01:00
parent f9087db785
commit b9a09b38a0

View file

@ -194,9 +194,11 @@ function configuration_upload() {
}
// Send over the PID changes
send_message(MSP_codes.MSP_SET_PID, PID_buffer_out);
send_message(MSP_codes.MSP_SET_PID, PID_buffer_out, false, function() {
rc_tuning();
});
var rc_tuning = function() {
// RC Tuning section
var RC_tuning_buffer_out = new Array();
RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100);
@ -208,9 +210,12 @@ function configuration_upload() {
RC_tuning_buffer_out[6] = parseInt(RC_tuning.throttle_EXPO * 100);
// Send over the RC_tuning changes
send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out);
send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out, false, function() {
aux();
});
};
var aux = function() {
// AUX section
var AUX_val_buffer_out = new Array();
@ -221,10 +226,14 @@ function configuration_upload() {
}
// Send over the AUX changes
send_message(MSP_codes.MSP_SET_BOX, AUX_val_buffer_out);
send_message(MSP_codes.MSP_SET_BOX, AUX_val_buffer_out, false, function() {
trim();
});
};
// Trim section
var trim = function() {
var buffer_out = new Array();
buffer_out[0] = lowByte(CONFIG.accelerometerTrims[0]);
buffer_out[1] = highByte(CONFIG.accelerometerTrims[0]);
@ -232,8 +241,12 @@ function configuration_upload() {
buffer_out[3] = highByte(CONFIG.accelerometerTrims[1]);
// Send over the new trims
send_message(MSP_codes.MSP_SET_ACC_TRIM, buffer_out);
send_message(MSP_codes.MSP_SET_ACC_TRIM, buffer_out, false, function() {
misc();
});
};
var misc = function() {
// MISC
// we also have to fill the unsupported bytes
var buffer_out = new Array();
@ -261,9 +274,9 @@ function configuration_upload() {
buffer_out[21] = 0; // vbatlevel_crit (unused)
// Send ove the new MISC
send_message(MSP_codes.MSP_SET_MISC, buffer_out);
send_message(MSP_codes.MSP_SET_MISC, buffer_out, false, function() {
// Save changes to EEPROM
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
});
};
}