mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 00:35:26 +03:00
Motor output reordering feature
Fixed Sonar warnings renaming MOTOR_REMAP to MOTOR_OUTPUT_REORDER<ING> Sonar warning fix Code style fixes after the code review moving styles to css from the motors tab dialog Dialog size of Androind devices Raneming MSP_<SET>_MOTOR_OUTPUT_REORDERING to MSP2 removing old styles and js files reference to motor_remap folder adding FC.* where needed to accomodate new master changes fixed alphabetical order for FC settings MOTOR_OUTPUT_REORDER css fix for Android for motor reordering dialog
This commit is contained in:
parent
b596c5fc76
commit
e4a85ccc2f
13 changed files with 930 additions and 3 deletions
|
@ -41,6 +41,7 @@ const FC = {
|
|||
MOTOR_3D_CONFIG: null,
|
||||
MOTOR_CONFIG: null,
|
||||
MOTOR_DATA: null,
|
||||
MOTOR_OUTPUT_ORDER: null,
|
||||
MOTOR_TELEMETRY_DATA: null,
|
||||
MULTIPLE_MSP: null,
|
||||
PID: null,
|
||||
|
@ -605,6 +606,8 @@ const FC = {
|
|||
vtxtable_powerlevel_label: 0,
|
||||
};
|
||||
|
||||
this.MOTOR_OUTPUT_ORDER = [];
|
||||
|
||||
this.MULTIPLE_MSP = {
|
||||
msp_commands: [],
|
||||
};
|
||||
|
|
|
@ -179,4 +179,6 @@ var MSPCodes = {
|
|||
|
||||
// MSPv2 Betaflight specific
|
||||
MSP2_BETAFLIGHT_BIND: 0x3000,
|
||||
MSP2_MOTOR_OUTPUT_REORDERING: 0x3001,
|
||||
MSP2_SET_MOTOR_OUTPUT_REORDERING: 0x3002,
|
||||
};
|
||||
|
|
|
@ -147,6 +147,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
FC.MOTOR_DATA[i] = data.readU16();
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP2_MOTOR_OUTPUT_REORDERING:
|
||||
FC.MOTOR_OUTPUT_ORDER = [];
|
||||
const arraySize = data.read8();
|
||||
for (let i = 0; i < arraySize; i++) {
|
||||
FC.MOTOR_OUTPUT_ORDER[i] = data.readU8();
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_MOTOR_TELEMETRY:
|
||||
var telemMotorCount = data.readU8();
|
||||
for (let i = 0; i < telemMotorCount; i++) {
|
||||
|
@ -1549,6 +1556,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
case MSPCodes.MSP_SET_RTC:
|
||||
console.log('Real time clock set');
|
||||
break;
|
||||
case MSPCodes.MSP2_SET_MOTOR_OUTPUT_REORDERING:
|
||||
console.log('Motor output reordering set');
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_MULTIPLE_MSP:
|
||||
|
||||
|
@ -2249,6 +2259,15 @@ MspHelper.prototype.crunch = function(code) {
|
|||
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_SET_MOTOR_OUTPUT_REORDERING:
|
||||
|
||||
buffer.push8(FC.MOTOR_OUTPUT_ORDER.length);
|
||||
for (let i = 0; i < FC.MOTOR_OUTPUT_ORDER.length; i++) {
|
||||
buffer.push8(FC.MOTOR_OUTPUT_ORDER[i]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,11 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function load_esc_protocol() {
|
||||
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, load_motor_data);
|
||||
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, load_motor_output_reordering);
|
||||
}
|
||||
|
||||
function load_motor_output_reordering() {
|
||||
MSP.send_message(MSPCodes.MSP2_MOTOR_OUTPUT_REORDERING, false, false, load_motor_data);
|
||||
}
|
||||
|
||||
function load_motor_data() {
|
||||
|
@ -222,6 +226,13 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
$('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[mixer - 1].image + reverse + '.svg');
|
||||
|
||||
const motorOutputReorderConfig = new MotorOutputReorderConfig(100);
|
||||
const domMotorOutputReorderDialogOpen = $('#motorOutputReorderDialogOpen');
|
||||
|
||||
const isMotorReorderingAvailable = (mixerList[mixer - 1].name in motorOutputReorderConfig)
|
||||
&& (FC.MOTOR_OUTPUT_ORDER) && (FC.MOTOR_OUTPUT_ORDER.length > 0);
|
||||
domMotorOutputReorderDialogOpen.toggle(isMotorReorderingAvailable);
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
|
@ -726,7 +737,50 @@ TABS.motors.initialize = function (callback) {
|
|||
// enable Status and Motor data pulling
|
||||
GUI.interval_add('motor_and_status_pull', get_status, 50, true);
|
||||
|
||||
GUI.content_ready(callback);
|
||||
let zeroThrottleValue = rangeMin;
|
||||
|
||||
if (self.feature3DEnabled) {
|
||||
zeroThrottleValue = neutral3d;
|
||||
}
|
||||
|
||||
setup_motor_output_reordering_dialog(content_ready, zeroThrottleValue);
|
||||
|
||||
function content_ready() {
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
|
||||
function setup_motor_output_reordering_dialog(callbackFunction, zeroThrottleValue)
|
||||
{
|
||||
const domDialogMotorOutputReorder = $('#dialogMotorOutputReorder');
|
||||
|
||||
const motorOutputReorderComponent = new MotorOutputReorderComponent($('#dialogMotorOutputReorderContent'),
|
||||
callbackFunction, mixerList[FC.MIXER_CONFIG.mixer - 1].name,
|
||||
zeroThrottleValue, zeroThrottleValue + 200);
|
||||
|
||||
$('#dialogMotorOutputReorder-closebtn').click(closeDialog);
|
||||
|
||||
function closeDialog()
|
||||
{
|
||||
domDialogMotorOutputReorder[0].close();
|
||||
motorOutputReorderComponent.close();
|
||||
$(document).off("keydown", onDocumentKeyPress);
|
||||
}
|
||||
|
||||
function onDocumentKeyPress(event)
|
||||
{
|
||||
if (27 === event.which) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
$('#motorOutputReorderDialogOpen').click(function()
|
||||
{
|
||||
$(document).on("keydown", onDocumentKeyPress);
|
||||
domDialogMotorOutputReorder[0].showModal();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue