Merge pull request #1076 from mikeller/add_rtc_setting

Added setting of RTC when connecting.
10.4.x-maintenance
Michael Keller 2018-07-03 22:51:10 +12:00 committed by GitHub
commit 192e886f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View File

@ -150,6 +150,11 @@ var MSPCodes = {
MSP_ACC_TRIM: 240,
MSP_SERVO_MIX_RULES: 241,
MSP_SET_SERVO_MIX_RULE: 242, // Not used
MSP_SET_4WAY_IF: 245, // Not used
MSP_SET_RTC: 246,
MSP_RTC: 247, // Not used
MSP_SET_BOARD_INFO: 248, // Not used
MSP_SET_SIGNATURE: 249, // Not used
MSP_EEPROM_WRITE: 250,
MSP_DEBUGMSG: 253, // Not used

View File

@ -1178,6 +1178,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_ARMING_DISABLE:
console.log('Arming disable');
break;
case MSPCodes.MSP_SET_RTC:
console.log('Real time clock set');
break;
default:
console.log('Unknown code detected: ' + code);
} else {
@ -1577,6 +1580,16 @@ MspHelper.prototype.crunch = function(code) {
// This will be ignored if `armingDisabled` is true
buffer.push8(value);
break;
case MSPCodes.MSP_SET_RTC:
var now = new Date();
buffer.push16(now.getUTCFullYear());
buffer.push8(now.getUTCMonth() + 1);
buffer.push8(now.getUTCDate());
buffer.push8(now.getUTCHours());
buffer.push8(now.getUTCMinutes());
buffer.push8(now.getUTCSeconds());
break;
default:
return false;

View File

@ -228,10 +228,10 @@ function onOpen(openInfo) {
GUI.log(i18n.getMessage('craftNameReceived', [CONFIG.name]));
CONFIG.armingDisabled = false;
mspHelper.setArmingEnabled(false, false, finishOpen);
mspHelper.setArmingEnabled(false, false, setRtc);
});
} else {
finishOpen();
setRtc();
}
});
});
@ -280,6 +280,14 @@ function onOpen(openInfo) {
}
}
function setRtc() {
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
MSP.send_message(MSPCodes.MSP_SET_RTC, mspHelper.crunch(MSPCodes.MSP_SET_RTC), false, finishOpen);
} else {
finishOpen();
}
}
function finishOpen() {
CONFIGURATOR.connectionValid = true;
GUI.allowedTabs = GUI.defaultAllowedFCTabsWhenConnected.slice();