only enforce mincommand if necessary

10.3.x-maintenance
cTn 2014-03-06 18:52:18 +01:00
parent e83b29cfde
commit 96d2bdbb12
1 changed files with 28 additions and 10 deletions

View File

@ -216,17 +216,35 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
case 'motor_outputs':
GUI.interval_remove('motor_poll');
// send data to mcu
var buffer_out = [];
for (var i = 0; i < 8; i++) {
buffer_out.push(lowByte(MISC.mincommand));
buffer_out.push(highByte(MISC.mincommand));
}
send_message(MSP_codes.MSP_SET_MOTOR, buffer_out, false, function() {
// only enforce mincommand if necessary
if (MOTOR_DATA != undefined) {
var update = false;
for (var i = 0; i < MOTOR_DATA.length; i++) {
if (MOTOR_DATA[i] > MISC.mincommand) {
update = true;
break;
}
}
if (update) {
// send data to mcu
var buffer_out = [];
for (var i = 0; i < 8; i++) {
buffer_out.push(lowByte(MISC.mincommand));
buffer_out.push(highByte(MISC.mincommand));
}
send_message(MSP_codes.MSP_SET_MOTOR, buffer_out, false, function() {
if (callback) callback();
});
} else {
if (callback) callback();
}
} else {
if (callback) callback();
});
}
break;
case 'sensors':
GUI.interval_kill_all(['port_usage']);