mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 04:15:28 +03:00
Intermediate commit.
Not currently working
This commit is contained in:
parent
553bde1b37
commit
372dcae919
4 changed files with 87 additions and 14 deletions
|
@ -183,6 +183,8 @@ var MSPCodes = {
|
|||
MSP2_INAV_MC_BRAKING: 0x200B,
|
||||
MSP2_INAV_SET_MC_BRAKING: 0x200C,
|
||||
MSPV2_INAV_OUTPUT_MAPPING_EXT: 0x200D,
|
||||
MSP2_INAV_TIMER_OUTPUT_MODE: 0x200E,
|
||||
MSP2_INAV_SET_TIMER_OUTPUT_MODE: 0x200F,
|
||||
|
||||
MSP2_INAV_MIXER: 0x2010,
|
||||
MSP2_INAV_SET_MIXER: 0x2011,
|
||||
|
|
|
@ -1500,7 +1500,16 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
break;
|
||||
|
||||
|
||||
case MSPCodes.MSPV2_INAV_TIMER_OUTPUT_MODE:
|
||||
if(data.byteLength > 2) {
|
||||
OUTPUT_MAPPING.flushTimerOverrides();
|
||||
}
|
||||
for (i = 0; i < data.byteLength; i += 2) {
|
||||
timerId = data.getUint8(i);
|
||||
outputMode = data.getUint8(i + 1);
|
||||
OUTPUT_MAPPING.setTimerOverride(timerId, outputMode);
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_MC_BRAKING:
|
||||
try {
|
||||
|
@ -2841,6 +2850,44 @@ var mspHelper = (function (gui) {
|
|||
MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT, false, false, callback);
|
||||
};
|
||||
|
||||
self.loadTimerOutputModes = function(callback) {
|
||||
MSP.send_message(MSPCodes.MSPV2_INAV_TIMER_OUTPUT_MODE, false, false, callback);
|
||||
}
|
||||
|
||||
self.sendTimerOutputModes = function(callback) {
|
||||
var nextFunction = send_next_output_mode;
|
||||
|
||||
var idIndex = 0;
|
||||
|
||||
var overrideIds = OUTPUT_MAPPING.getTimerOverrideIds();
|
||||
|
||||
if (MODE_RANGES.length == 0) {
|
||||
onCompleteCallback();
|
||||
} else {
|
||||
send_next_output_mode();
|
||||
}
|
||||
|
||||
function send_next_output_mode() {
|
||||
|
||||
var timerId = overrideIds[idIndex];
|
||||
|
||||
var ouputMode = OUTPUT_MAPPING.getTimerOverride(timerId);
|
||||
|
||||
var buffer = [];
|
||||
buffer.push(timerId);
|
||||
buffer.push(outputMode);
|
||||
|
||||
// prepare for next iteration
|
||||
idIndex++;
|
||||
if (idIndex == overrideIds.length) {
|
||||
nextFunction = onCompleteCallback;
|
||||
|
||||
}
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SET_TIMER_OUTPUT_MODE, buffer, false, nextFunction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
self.loadBatteryConfig = function (callback) {
|
||||
MSP.send_message(MSPCodes.MSPV2_BATTERY_CONFIG, false, false, callback);
|
||||
};
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
let OutputMappingCollection = function () {
|
||||
let self = {},
|
||||
data = [];
|
||||
data = [],
|
||||
timerOverrides = {};
|
||||
|
||||
const TIM_USE_ANY = 0;
|
||||
const TIM_USE_PPM = 0;
|
||||
|
@ -19,6 +20,26 @@ let OutputMappingCollection = function () {
|
|||
const OUTPUT_TYPE_MOTOR = 0;
|
||||
const OUTPUT_TYPE_SERVO = 1;
|
||||
|
||||
const TIMER_OUTPUT_MODE_AUTO = 0;
|
||||
const TIMER_OUTPUT_MODE_MOTORS = 1;
|
||||
const TIMER_OUTPUT_MODE_SERVOS = 2;
|
||||
|
||||
self.flushTimerOverrides = function() {
|
||||
timerOverrides = {};
|
||||
}
|
||||
|
||||
self.setTimerOverride = function (timer, outputMode) {
|
||||
timerOverrides[timer] = outputMode;
|
||||
}
|
||||
|
||||
self.getTimerOverride = function (timer) {
|
||||
timerOverrides[timer] = outputMode;
|
||||
}
|
||||
|
||||
self.getTimerOverrideIds = function (timer) {
|
||||
return Object.keys(timerOverrides).sort((a, b) => a - b);
|
||||
}
|
||||
|
||||
function getTimerMap(isMR, motors, servos) {
|
||||
let timerMap = [],
|
||||
motorsToGo = motors,
|
||||
|
|
|
@ -28,6 +28,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
mspHelper.loadServoMixRules,
|
||||
mspHelper.loadMotorMixRules,
|
||||
mspHelper.loadOutputMappingExt,
|
||||
mspHelper.loadTimerOutputModes,
|
||||
mspHelper.loadLogicConditions
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
|
@ -37,6 +38,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
mspHelper.saveMixerConfig,
|
||||
mspHelper.sendServoMixer,
|
||||
mspHelper.sendMotorMixer,
|
||||
mspHelper.sendTimerOutputModes,
|
||||
saveSettings,
|
||||
mspHelper.saveToEeprom
|
||||
]);
|
||||
|
@ -87,29 +89,25 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
$container = $('#timerOutputsList'), timers = {};
|
||||
|
||||
|
||||
for(let i = 0; i < outputCount; ++i) {
|
||||
let timer = OUTPUT_MAPPING.getTimerId(i);
|
||||
|
||||
timers[timer] = true;
|
||||
console.log("timer: " + i + " " + timer);
|
||||
}
|
||||
|
||||
let usedTimers = Object.keys(timers).sort((a,b) => a-b);
|
||||
let usedTimers = OUTPUT_MAPPING.getTimerOverrideIds();
|
||||
|
||||
for (t of usedTimers) {
|
||||
var usageMode = OUTPUT_MAPPING.getTimerOverride(t);
|
||||
console.log("timer settings: " + t);
|
||||
/*
|
||||
$container.append(
|
||||
'<div class="select">' +
|
||||
'<select id="timer-output-' + t + '">' +
|
||||
'<option>AUTO</option>'+
|
||||
'<option>MOTORS</option>'+
|
||||
'<option>SERVOS</option>'+
|
||||
'<option value=' + TIMER_OUTPUT_MODE_AUTO + '' + (usageMode == TIMER_OUTPUT_MODE_AUTO ? ' selected' : '')+ '>AUTO</option>'+
|
||||
'<option value=' + TIMER_OUTPUT_MODE_MOTORS + '' + (usageMode == TIMER_OUTPUT_MODE_MOTORS ? ' selected' : '')+ '>MOTORS</option>'+
|
||||
'<option value=' + TIMER_OUTPUT_MODE_SERVOS + '' + (usageMode == TIMER_OUTPUT_MODE_SERVOS ? ' selected' : '')+ '>SERVOS</option>'+
|
||||
'</select>' +
|
||||
'<label for="timer-output-' + t + '">' +
|
||||
'<span> T' + t + '</span>' +
|
||||
'</label>' +
|
||||
'</div>'
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -469,6 +467,11 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
SERVO_RULES.inflate();
|
||||
MOTOR_RULES.cleanup();
|
||||
MOTOR_RULES.inflate();
|
||||
|
||||
for (timerId OUTPUT_MAPPING.getTimerOverrideIds()) {
|
||||
|
||||
}
|
||||
|
||||
saveChainer.execute();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue