Skip to content

Commit

Permalink
Remove PIDS_ACTIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Dec 7, 2023
1 parent edff729 commit 112cac2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
for (let i = 0, needle = 0; i < (data.byteLength / 3); i++, needle += 3) {
// main for loop selecting the pid section
for (let j = 0; j < 3; j++) {
FC.PIDS_ACTIVE[i][j] = data.readU8();
FC.PIDS[i][j] = FC.PIDS_ACTIVE[i][j];
FC.PIDS[i][j] = data.readU8();
}
}
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.PIDS_ACTIVE = FC.PIDS.map(array => array.slice());
}
break;

case MSPCodes.MSP_ARMING_CONFIG:
Expand Down Expand Up @@ -621,7 +623,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;
case MSPCodes.MSP_SET_PID:
console.log('PID settings saved');
FC.PIDS_ACTIVE = FC.PIDS.map(array => array.slice());
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.PIDS_ACTIVE = FC.PIDS.map(array => array.slice());
}
break;
case MSPCodes.MSP_SET_RC_TUNING:
console.log('RC Tuning saved');
Expand Down
16 changes: 11 additions & 5 deletions src/js/tabs/pid_tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ pid_tuning.initialize = function (callback) {
// Assign each value
searchRow.each((indexInput, element) => {
if (FC.PIDS[indexPid][indexInput] !== undefined) {
$(element).val(FC.PIDS_ACTIVE[indexPid][indexInput]);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$(element).val(FC.PIDS[indexPid][indexInput]);
} else {
$(element).val(FC.PIDS_ACTIVE[indexPid][indexInput]);
}
}
});
});
Expand Down Expand Up @@ -2732,11 +2736,13 @@ pid_tuning.updatePIDColors = function(clear = false) {
element.css({ "background-color": getColorForPercentage(change, colorTables.pidSlider) });
};

FC.PID_NAMES.forEach(function(elementPid, indexPid) {
$(`.pid_tuning .${elementPid} input`).each(function(indexInput) {
setTuningElementColor($(this), FC.PIDS_ACTIVE[indexPid][indexInput], FC.PIDS[indexPid][indexInput]);
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
$(`.pid_tuning .${elementPid} input`).each(function(indexInput) {
setTuningElementColor($(this), FC.PIDS_ACTIVE[indexPid][indexInput], FC.PIDS[indexPid][indexInput]);
});
});
});
}

setTuningElementColor($('.pid_tuning input[name="dMinRoll"]'), FC.ADVANCED_TUNING_ACTIVE.dMinRoll, FC.ADVANCED_TUNING.dMinRoll);
setTuningElementColor($('.pid_tuning input[name="dMinPitch"]'), FC.ADVANCED_TUNING_ACTIVE.dMinPitch, FC.ADVANCED_TUNING.dMinPitch);
Expand Down

0 comments on commit 112cac2

Please sign in to comment.