From e15cb55e2475c713638b2f366bee1ddcf398acdb Mon Sep 17 00:00:00 2001 From: HThuren <99370924+HThuren@users.noreply.github.com> Date: Thu, 6 Apr 2023 22:22:13 +0200 Subject: [PATCH] Show CPU core temp on Setup tab (#3403) * add temp * add cpu temperature --- locales/en/messages.json | 3 +++ src/js/fc.js | 2 ++ src/js/msp/MSPHelper.js | 8 ++++++++ src/js/tabs/setup.js | 6 +++++- src/tabs/setup.html | 4 ++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index ecc7f801..e623c992 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -901,6 +901,9 @@ "initialSetupBatteryAValue": { "message": "$1 A" }, + "initialSetupCpuTemp": { + "message": "CPU Temperature:" + }, "initialSetupRSSI": { "message": "RSSI:" }, diff --git a/src/js/fc.js b/src/js/fc.js index b5e811dd..d3d8ccc5 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -16,6 +16,7 @@ const INITIAL_CONFIG = { cycleTime: 0, i2cError: 0, cpuload: 0, + cpuTemp: 0, activeSensors: 0, mode: 0, profile: 0, @@ -43,6 +44,7 @@ const INITIAL_CONFIG = { signature: [], mcuTypeId: 255, configurationState: 0, + configStateFlag: 0, sampleRateHz: 0, configurationProblems: 0, hardwareName: '', diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index cdc0371a..b7841780 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -213,6 +213,14 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.CONFIG.armingDisableCount = data.readU8(); // Flag count FC.CONFIG.armingDisableFlags = data.readU32(); + // Read config state flags - bits to indicate the state of the configuration, reboot required, etc. + FC.CONFIG.configStateFlag = data.readU8(); + + // Read CPU temp, from API version 1.46 + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + FC.CONFIG.cpuTemp = data.readU16(); + } + sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix); break; diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 55beb615..79952d32 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -9,7 +9,7 @@ import FC from '../fc'; import MSP from '../msp'; import Model from '../model'; import MSPCodes from '../msp/MSPCodes'; -import CONFIGURATOR, { API_VERSION_1_42, API_VERSION_1_43 } from '../data_storage'; +import CONFIGURATOR, { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_46 } from '../data_storage'; import { gui_log } from '../gui_log'; const setup = { @@ -190,6 +190,7 @@ setup.initialize = function (callback) { bat_mah_drawn_e = $('.bat-mah-drawn'), bat_mah_drawing_e = $('.bat-mah-drawing'), rssi_e = $('.rssi'), + cputemp_e = $('.cpu-temp'), arming_disable_flags_e = $('.arming-disable-flags'), gpsFix_e = $('.gpsFix'), gpsSats_e = $('.gpsSats'), @@ -400,6 +401,9 @@ setup.initialize = function (callback) { bat_mah_drawn_e.text(i18n.getMessage('initialSetupBatteryMahValue', [FC.ANALOG.mAhdrawn])); bat_mah_drawing_e.text(i18n.getMessage('initialSetupBatteryAValue', [FC.ANALOG.amperage.toFixed(2)])); rssi_e.text(i18n.getMessage('initialSetupRSSIValue', [((FC.ANALOG.rssi / 1023) * 100).toFixed(0)])); + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) { + cputemp_e.html(`${FC.CONFIG.cpuTemp.toFixed(0)} ℃`); + } }); } diff --git a/src/tabs/setup.html b/src/tabs/setup.html index ab9ee3dd..9b1469fb 100644 --- a/src/tabs/setup.html +++ b/src/tabs/setup.html @@ -167,6 +167,10 @@ 0 % + + + 0 ℃ +