1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-16 21:05:28 +03:00

save button now actually save the configuration

This commit is contained in:
cTn 2013-11-08 13:52:44 +01:00
parent 255c0d24ae
commit 32a140268d
2 changed files with 30 additions and 0 deletions

View file

@ -659,6 +659,9 @@ function process_message(code, data, bytes) {
case MSP_codes.MSP_SELECT_SETTING: case MSP_codes.MSP_SELECT_SETTING:
console.log(data); console.log(data);
break; break;
case MSP_codes.MSP_SET_SERVO_CONF:
console.log('Servo Configuration saved');
break;
/* disabled (find out why ???) /* disabled (find out why ???)
case MSP_codes.MSP_BIND: case MSP_codes.MSP_BIND:
console.log(data); console.log(data);

View file

@ -44,6 +44,7 @@ function tab_initialize_servos() {
case 14: // Airplane case 14: // Airplane
model.html('Airplane'); model.html('Airplane');
// rate
process_servos('Wing 1', SERVO_CONFIG[3], 3); process_servos('Wing 1', SERVO_CONFIG[3], 3);
process_servos('Wing 2', SERVO_CONFIG[4], 4); process_servos('Wing 2', SERVO_CONFIG[4], 4);
process_servos('Rudd', SERVO_CONFIG[5], 5); process_servos('Rudd', SERVO_CONFIG[5], 5);
@ -73,11 +74,14 @@ function tab_initialize_servos() {
servos = [3, 4, 5, 6, 7]; servos = [3, 4, 5, 6, 7];
break; break;
default:
model.html('Doesn\'t support servos');
} }
}, 50); }, 50);
// UI hooks // UI hooks
$('a.update').click(function() { $('a.update').click(function() {
// update objects
var itter = 0; var itter = 0;
$('div.tab-servos table.fields tr:not(".main")').each(function() { $('div.tab-servos table.fields tr:not(".main")').each(function() {
if ($('.middle input', this).is(':disabled')) { if ($('.middle input', this).is(':disabled')) {
@ -93,6 +97,28 @@ function tab_initialize_servos() {
itter++; itter++;
}); });
var buffer_out = [];
var needle = 0;
for (var i = 0; i < SERVO_CONFIG.length; i++) {
buffer_out[needle++] = lowByte(SERVO_CONFIG[i].min);
buffer_out[needle++] = highByte(SERVO_CONFIG[i].min);
buffer_out[needle++] = lowByte(SERVO_CONFIG[i].max);
buffer_out[needle++] = highByte(SERVO_CONFIG[i].max);
buffer_out[needle++] = lowByte(SERVO_CONFIG[i].middle);
buffer_out[needle++] = highByte(SERVO_CONFIG[i].middle);
buffer_out[needle++] = lowByte(SERVO_CONFIG[i].rate);
}
send_message(MSP_codes.MSP_SET_SERVO_CONF, buffer_out);
// Save changes to EEPROM
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
}); });
} }
@ -119,6 +145,7 @@ function process_servos(name, obj, pos) {
); );
if (obj.middle <= 7) { if (obj.middle <= 7) {
$('div.tab-servos table.fields tr:last td.middle input').prop('disabled', true);
$('div.tab-servos table.fields tr:last td.channel').find('input').eq(obj.middle).prop('checked', true); $('div.tab-servos table.fields tr:last td.channel').find('input').eq(obj.middle).prop('checked', true);
} }