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

Add MCU_INFO MSP support #4306

Merged
merged 3 commits into from
Jan 18, 2025
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
3 changes: 3 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,9 @@
"initialSetupRSSIValue": {
"message": "$1 dBm"
},
"initialSetupMCU": {
"message": "MCU:"
},
"initialSetupSensorHardware": {
"message": "Sensors:"
},
Expand Down
36 changes: 6 additions & 30 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const FC = {
LED_MODE_COLORS: null,
LED_STRIP: null,
LED_CONFIG_VALUES: [],
MCU_INFO: null,
MISC: null, // DEPRECATED
MIXER_CONFIG: null,
MODE_RANGES: null,
Expand Down Expand Up @@ -595,6 +596,11 @@ const FC = {

this.SENSOR_CONFIG_ACTIVE = { gyro_hardware: 0, ...this.SENSOR_CONFIG };

this.MCU_INFO = {
id: 0,
name: 0,
};

this.RX_CONFIG = {
serialrx_provider: 0,
stick_max: 0,
Expand Down Expand Up @@ -868,36 +874,6 @@ const FC = {
this.CONFIG.hardwareName = name;
},

MCU_TYPES: {
0: "SIMULATOR",
1: "F40X",
2: "F411",
3: "F446",
4: "F722",
5: "F745",
6: "F746",
7: "F765",
8: "H750",
9: "H743_REV_UNKNOWN",
10: "H743_REV_Y",
11: "H743_REV_X",
12: "H743_REV_V",
13: "H7A3",
14: "H723_725",
15: "G474",
16: "H730",
17: "AT32F435G",
18: "APM32F405",
19: "APM32F407",
20: "AT32F435M",
21: "RP2350B",
255: "Unknown MCU",
},

getMcuType() {
return this.MCU_TYPES[this.CONFIG.mcuTypeId];
},

CONFIGURATION_STATES: {
DEFAULTS_BARE: 0,
DEFAULTS_CUSTOM: 1,
Expand Down
1 change: 1 addition & 0 deletions src/js/msp/MSPCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ const MSPCodes = {
MSP2_GET_LED_STRIP_CONFIG_VALUES: 0x3008,
MSP2_SET_LED_STRIP_CONFIG_VALUES: 0x3009,
MSP2_SENSOR_CONFIG_ACTIVE: 0x300a,
MSP2_MCU_INFO: 0x300c,

// MSP2_GET_TEXT and MSP2_SET_TEXT variable types
PILOT_NAME: 1,
Expand Down
8 changes: 8 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,14 @@ MspHelper.prototype.process_data = function (dataHandler) {
FC.SENSOR_CONFIG_ACTIVE.sonar_hardware = data.readU8();
}
break;
case MSPCodes.MSP2_MCU_INFO:
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
FC.MCU_INFO = {
id: data.readU8(),
name: self.getText(data),
};
}
break;

case MSPCodes.MSP_LED_STRIP_CONFIG:
FC.LED_STRIP = [];
Expand Down
2 changes: 1 addition & 1 deletion src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ function processBoardInfo() {
apiVersion: FC.CONFIG.apiVersion,
flightControllerVersion: FC.CONFIG.flightControllerVersion,
flightControllerIdentifier: FC.CONFIG.flightControllerIdentifier,
mcu: FC.getMcuType(),
mcu: FC.CONFIG.targetName,
});
}

Expand Down
14 changes: 13 additions & 1 deletion src/js/tabs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ setup.initialize = function (callback) {
}

function load_status() {
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false, load_mixer_config);
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false, mcu_info);
}

function mcu_info() {
MSP.send_message(MSPCodes.MSP2_MCU_INFO, false, false, load_mixer_config);
}

function load_mixer_config() {
Expand Down Expand Up @@ -195,6 +199,8 @@ setup.initialize = function (callback) {
pitch_e = $("dd.pitch"),
heading_e = $("dd.heading"),
sonar_e = $(".sonarAltitude"),
// MCU info
mcu_e = $(".mcu"),
// Sensor info
sensor_gyro_e = $(".sensor_gyro_hw"),
sensor_acc_e = $(".sensor_acc_hw"),
Expand Down Expand Up @@ -602,6 +608,12 @@ setup.initialize = function (callback) {
cputemp_e.text(i18n.getMessage("initialSetupCpuTempNotSupported"));
}

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
mcu_e.text(FC.MCU_INFO.name);
} else {
mcu_e.parent().hide();
}

// GPS info is acquired in the background using update_live_status() in serial_backend.js
gpsFix_e.text(FC.GPS_DATA.fix ? i18n.getMessage("gpsFixTrue") : i18n.getMessage("gpsFixFalse"));
gpsFix_e.toggleClass("ready", FC.GPS_DATA.fix != 0);
Expand Down
4 changes: 4 additions & 0 deletions src/tabs/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
<td i18n="initialSetupRSSI"></td>
<td class="rssi">0 %</td>
</tr>
<tr>
<td id="mcu" i18n="initialSetupMCU"></td>
<td class="mcu"></td>
</tr>
<tr>
<td id="cpu-temp" i18n="initialSetupCpuTemp"></td>
<td class="cpu-temp">0 &#8451;</td>
Expand Down
Loading