Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSP 1.54 support #510

Merged
merged 13 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,15 @@
"motorsEnableControl": {
"message": "<strong>I understand the risks</strong>, the propellers are removed - enable motor control and arming, and disable Runaway Takeoff Prevention."
},

"motorConfigNotice": {
"message": "ESC/Motor Features are on the Configuration tab."
},
"motorPoleCount": {
"message": "Motor Poles"
},
"motorPoleCountHelp": {
"message": "The number of magnets on the motor bell."
},
"sensorsInfo": {
"message": "Keep in mind that using fast update periods and rendering multiple graphs at the same time is resource heavy and will burn your battery quicker if you use a laptop.<br />We recommend to only render graphs for sensors you are interested in while using reasonable update periods."
},
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"minimum_chrome_version": "49",
"version": "0.4.1",
"max_msp": "1.53.0",
"max_msp": "1.54.0",
"COMMENT": "MAX_MSP required!!!!",
"author": "Emuflight Team",
"name": "Emuflight Configurator",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "emuflight-configurator",
"description": "Crossplatform configuration tool for Emuflight flight control system.",
"version": "0.4.1",
"max_msp": "1.53.0",
"max_msp": "1.54.0",
"COMMENT": "MAX_MSP required!!!!",
"main": "main.html",
"chromium-args": "--disable-features=nw2",
Expand Down
15 changes: 15 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
}
CONFIG.mcuTypeId = 255;
//MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
CONFIG.gyroSampleRateHz = data.readU16();
}
//End MSP 1.54
break;

case MSPCodes.MSP_NAME:
Expand Down Expand Up @@ -990,6 +995,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
PID_ADVANCED_CONFIG.gyroUse32kHz = gyroUse32kHz;
}
}
//MSP 1.54 - insert here to avoid new unnecessary MSP code
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
PID_ADVANCED_CONFIG.motorPoleCount = data.readU8();
}
//End MSP 1.54
break;

case MSPCodes.MSP_FILTER_CONFIG:
Expand Down Expand Up @@ -1994,6 +2004,11 @@ MspHelper.prototype.crunch = function(code) {
buffer.push8(gyroUse32kHz);
}
}
//MSP 1.54 - insert here to avoid new unnecessary MSP code
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
buffer.push8(PID_ADVANCED_CONFIG.motorPoleCount);
}
//End MSP 1.54
break;

case MSPCodes.MSP_SET_FILTER_CONFIG:
Expand Down
28 changes: 25 additions & 3 deletions src/js/tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('input[name="unsyncedpwmfreq"]').val(PID_ADVANCED_CONFIG.motor_pwm_rate);
$('input[name="digitalIdlePercent"]').val(PID_ADVANCED_CONFIG.digitalIdlePercent);

//MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
$('input[name="motorPoleCount"]').val(PID_ADVANCED_CONFIG.motorPoleCount);
$('div.motorPoleCount').show();
} else {
$('div.motorPoleCount').hide();
}
//End MSP 1.54

esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
esc_protocol_e.change(function () {
Expand Down Expand Up @@ -485,7 +493,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
if (semver.gte(CONFIG.apiVersion, "1.25.0")) {
while (denom <= 32) {
addDenomOption(gyro_select_e, denom, gyroBaseFreq);

denom ++;
}
}
Expand All @@ -503,7 +510,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
if ($(this).is(':checked')) {
gyroBaseFreq = 32;
} else {
gyroBaseFreq = 8;
if (semver.gte(CONFIG.apiVersion, "1.54.0") && CONFIG.gyroSampleRateHz) {
gyroBaseFreq = CONFIG.gyroSampleRateHz / 1000;
} else {
gyroBaseFreq = 8;
}
}

updateGyroDenom(gyroBaseFreq);
Expand All @@ -521,7 +532,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
gyro_select_e.change(function () {
var originalPidDenom = pid_select_e.val();

var pidBaseFreq = 8;
let pidBaseFreq;
if (semver.gte(CONFIG.apiVersion, "1.54.0") && CONFIG.gyroSampleRateHz) {
pidBaseFreq = CONFIG.gyroSampleRateHz / 1000;
} else {
pidBaseFreq = 8;
}
if (semver.gte(CONFIG.apiVersion, "1.25.0") && gyroUse32kHz_e.is(':checked')) {
pidBaseFreq = 32;
}
Expand Down Expand Up @@ -1114,6 +1130,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
//end MSP 1.51

//MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
PID_ADVANCED_CONFIG.motorPoleCount = parseInt($('input[name="motorPoleCount"]').val());
}
//End MSP 1.54

function save_serial_config() {
var next_callback = save_feature_config;
MSP.send_message(MSPCodes.MSP_SET_CF_SERIAL_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CF_SERIAL_CONFIG), false, next_callback);
Expand Down
11 changes: 11 additions & 0 deletions src/tabs/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@
<div class="helpicon cf_tip" i18n_title="configurationThrottleMinimumCommandHelp"></div>
</label>
</div>
<!-- MSP 1.54 -->
<div class="number motorPoleCount" id="motorPoleCount">
<label>
<div class="numberspacer">
<input type="number" name="motorPoleCount" min="1" max="255" />
</div>
<span i18n="motorPoleCount"></span>
<div class="helpicon cf_tip" i18n_title="motorPoleCountHelp"></div>
</label>
</div>
<!-- End MSP 1.54 -->
</div>
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/tabs/motors.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<div class="cf_doc_version_bt">
<a id="button-documentation" href="https://github.com/emuflight/EmuFlight/releases" target="_blank"></a>
</div>

<div class="note spacebottom">
<div class="note_spacer">
<p i18n="motorConfigNotice"></p>
</div>
</div>

<div class="gui_box grey" style="margin-bottom: 15px;">
<div class="wrapper modelAndGraph">
<div class="mixerPreview">
Expand Down Expand Up @@ -171,7 +178,7 @@
<label><input id="motorsEnableTestMode" type="checkbox" class="togglesmall"/><span
class="motorsEnableTestMode" i18n="motorsEnableControl"></span></label>
</div>
<div class="cler-both"></div>
<div class="clear-both"></div>
</div>
</div>
</div>
Expand Down
Loading