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 all 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 @@ -2409,7 +2409,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
26 changes: 26 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 @@ -1551,6 +1561,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
VTX_CONFIG.vtx_power = data.readU8();
VTX_CONFIG.vtx_pit_mode = data.readU8() !== 0;
VTX_CONFIG.vtx_frequency = data.readU16();
//MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
VTX_CONFIG.vtx_low_power_disarm = data.readU8();
}
// End MSP 1.54
}
//console.log('exit MSPCodes.MSP_VTX_CONFIG');
break;
Expand Down Expand Up @@ -1994,6 +2009,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 Expand Up @@ -2272,6 +2292,12 @@ MspHelper.prototype.crunch = function(code) {
buffer.push16(VTX_CONFIG.vtx_frequency)
.push8(VTX_CONFIG.vtx_power)
.push8(VTX_CONFIG.vtx_pit_mode ? 1 : 0);
//MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
//buffer.push16(VTX_CONFIG.vtx_pit_mode_freq);
buffer.push8(VTX_CONFIG.vtx_low_power_disarm);
}
//End MSP 1.54
}
break;

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
17 changes: 15 additions & 2 deletions src/js/tabs/vtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ TABS.vtx.initialize = function(callback) {
$(".field.vtx_pit_mode").hide();
}

//$("#vtx_pit_mode_frequency").val(VTX_CONFIG.vtx_pit_mode_frequency); //no EmuF MSP
// MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
$("#vtx_low_power_disarm").prop('checked', VTX_CONFIG.vtx_low_power_disarm);
$(".field.vtx_low_power_disarm").show();
} else {
$(".field.vtx_low_power_disarm").hide();
}
// End MSP 1.54

//const yesMessage = i18n.getMessage("yes");
//const noMessage = i18n.getMessage("no");
//$("#vtx_device_ready_description").text(VTX_CONFIG.vtx_device_ready ? yesMessage : noMessage);
Expand Down Expand Up @@ -339,7 +347,12 @@ function dump_html_to_msp() {

VTX_CONFIG.vtx_power = parseInt($("#vtx_power").val());
VTX_CONFIG.vtx_pit_mode = $("#vtx_pit_mode").prop('checked');
// VTX_CONFIG.vtx_low_power_disarm = parseInt($("#vtx_low_power_disarm").val()); //no EmuF MSP

// MSP 1.54
if (semver.gte(CONFIG.apiVersion, "1.54.0")) {
VTX_CONFIG.vtx_low_power_disarm = $("#vtx_low_power_disarm").prop('checked');
}
// End MSP 1.54

//console.log('dump_html_to_msp(): bnd'+VTX_CONFIG.vtx_band+'/ch'+VTX_CONFIG.vtx_channel+'/frq'+VTX_CONFIG.vtx_frequency+'/lvl'+VTX_CONFIG.vtx_power+'/pm'+VTX_CONFIG.vtx_pit_mode);
//console.log('exit dump_html_to_msp()');
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
22 changes: 5 additions & 17 deletions src/tabs/vtx.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,15 @@
<span i18n="vtxPower"></span>
<div class="helpicon cf_tip" i18n_title="vtxPowerHelp"></div>
</div>
<!-- not supported by EMUF MSP (yet)
<div class="field number vtx_pit_mode_frequency">
<span class="numberspacer">
<input class="frequency_input" type="number" id="vtx_pit_mode_frequency" min="0" max="5999">
</span>
<span i18n="vtxPitModeFrequency"></span>
<div class="helpicon cf_tip" i18n_title="vtxPitModeFrequencyHelp"></div>
</div>
-->
<!-- not supported by EMUF MSP (yet)
<div class="field select vtx_low_power_disarm">
<span class="selectspacer">
<select id="vtx_low_power_disarm">
<option value="0" i18n="vtxLowPowerDisarmOption_0"></option>
<option value="1" i18n="vtxLowPowerDisarmOption_1"></option>
</select>
<!-- MSP 1.54 -->
<div class="field checkbox vtx_low_power_disarm">
<span class="checkboxspacer">
<input type="checkbox" id="vtx_low_power_disarm" class="toggle" />
</span>
<span class="freelabel" i18n="vtxLowPowerDisarm"></span>
<div class="helpicon cf_tip" i18n_title="vtxLowPowerDisarmHelp"></div>
</div>
-->
<!-- End MSP 1.54 -->
<div class="field checkbox vtx_pit_mode">
<span class="checkboxspacer">
<input type="checkbox" id="vtx_pit_mode" class="toggle" />
Expand Down
Loading