mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 04:15:28 +03:00
Fix battery values
Allow negative values of power, mAh drawn and mWh drawn
This commit is contained in:
parent
8331b7d034
commit
2ee946c358
4 changed files with 67 additions and 32 deletions
|
@ -406,7 +406,7 @@
|
||||||
"initialSetupInfoHead": {
|
"initialSetupInfoHead": {
|
||||||
"message": "Info"
|
"message": "Info"
|
||||||
},
|
},
|
||||||
"initialSetupBattery": {
|
"initialSetupBatteryVoltage": {
|
||||||
"message": "Battery voltage:"
|
"message": "Battery voltage:"
|
||||||
},
|
},
|
||||||
"initialSetupBatteryDetectedCells": {
|
"initialSetupBatteryDetectedCells": {
|
||||||
|
@ -445,19 +445,25 @@
|
||||||
"initialSetup_Wh_drawnValue": {
|
"initialSetup_Wh_drawnValue": {
|
||||||
"message": "$1 Wh"
|
"message": "$1 Wh"
|
||||||
},
|
},
|
||||||
"initialSetupBatteryValue": {
|
"initialSetupBatteryVoltageValue": {
|
||||||
"message": "$1 V"
|
"message": "$1 V"
|
||||||
},
|
},
|
||||||
"initialSetupDrawn": {
|
"initialSetupDrawn": {
|
||||||
"message": "Capacity drawn:"
|
"message": "Capacity drawn:"
|
||||||
},
|
},
|
||||||
"initialSetupDrawing": {
|
"initialSetupCurrentDraw": {
|
||||||
"message": "Current draw:"
|
"message": "Current draw:"
|
||||||
},
|
},
|
||||||
|
"initialSetupPowerDraw": {
|
||||||
|
"message": "Power draw:"
|
||||||
|
},
|
||||||
|
"initialSetupPowerDrawValue": {
|
||||||
|
"message": "$1 W"
|
||||||
|
},
|
||||||
"initialSetupBatteryMahValue": {
|
"initialSetupBatteryMahValue": {
|
||||||
"message": "$1 mAh"
|
"message": "$1 mAh"
|
||||||
},
|
},
|
||||||
"initialSetupBatteryAValue": {
|
"initialSetupCurrentDrawValue": {
|
||||||
"message": "$1 A"
|
"message": "$1 A"
|
||||||
},
|
},
|
||||||
"initialSetupRSSI": {
|
"initialSetupRSSI": {
|
||||||
|
|
|
@ -251,6 +251,28 @@ var mspHelper = (function (gui) {
|
||||||
ANALOG.amperage = data.getInt16(5, true) / 100; // A
|
ANALOG.amperage = data.getInt16(5, true) / 100; // A
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSPV2_INAV_ANALOG:
|
case MSPCodes.MSPV2_INAV_ANALOG:
|
||||||
|
if (semver.gte(CONFIG.flightControllerVersion, "2.0.0")) {
|
||||||
|
var tmp = data.getUint8(offset++);
|
||||||
|
ANALOG.battery_full_when_plugged_in = (tmp & 1 ? true : false);
|
||||||
|
ANALOG.use_capacity_thresholds = ((tmp & 2) >> 1 ? true : false);
|
||||||
|
ANALOG.battery_state = (tmp & 12) >> 2;
|
||||||
|
ANALOG.cell_count = (tmp & 0xF0) >> 4;
|
||||||
|
ANALOG.voltage = data.getUint16(offset, true) / 100.0;
|
||||||
|
offset += 2;
|
||||||
|
ANALOG.amperage = data.getInt16(offset, true) / 100; // A
|
||||||
|
offset += 2;
|
||||||
|
ANALOG.power = data.getInt32(offset, true) / 100.0;
|
||||||
|
offset += 4;
|
||||||
|
ANALOG.mAhdrawn = data.getInt32(offset, true);
|
||||||
|
offset += 4;
|
||||||
|
ANALOG.mWhdrawn = data.getInt32(offset, true);
|
||||||
|
offset += 4;
|
||||||
|
ANALOG.battery_remaining_capacity = data.getUint32(offset, true);
|
||||||
|
offset += 4;
|
||||||
|
ANALOG.battery_percentage = data.getUint8(offset++);
|
||||||
|
ANALOG.rssi = data.getUint16(offset, true); // 0-1023
|
||||||
|
offset += 2;
|
||||||
|
} else {
|
||||||
ANALOG.voltage = data.getUint16(offset, true) / 100.0;
|
ANALOG.voltage = data.getUint16(offset, true) / 100.0;
|
||||||
offset += 2;
|
offset += 2;
|
||||||
ANALOG.cell_count = data.getUint8(offset++);
|
ANALOG.cell_count = data.getUint8(offset++);
|
||||||
|
@ -271,6 +293,7 @@ var mspHelper = (function (gui) {
|
||||||
ANALOG.battery_state = (battery_flags & 12) >> 2;
|
ANALOG.battery_state = (battery_flags & 12) >> 2;
|
||||||
ANALOG.battery_remaining_capacity = data.getUint32(offset, true);
|
ANALOG.battery_remaining_capacity = data.getUint32(offset, true);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
}
|
||||||
//noinspection JSValidateTypes
|
//noinspection JSValidateTypes
|
||||||
dataHandler.analog_last_received_timestamp = Date.now();
|
dataHandler.analog_last_received_timestamp = Date.now();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
<td class="bat-cells">0</td>
|
<td class="bat-cells">0</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td data-i18n="initialSetupBattery"></td>
|
<td data-i18n="initialSetupBatteryVoltage"></td>
|
||||||
<td class="bat-voltage">0 V</td>
|
<td class="bat-voltage">0 V</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="requires-v1_8_1">
|
<tr class="requires-v1_8_1">
|
||||||
|
@ -114,8 +114,12 @@
|
||||||
<td class="bat-thresh">0</td>
|
<td class="bat-thresh">0</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td data-i18n="initialSetupDrawing"></td>
|
<td data-i18n="initialSetupCurrentDraw"></td>
|
||||||
<td class="bat-mah-drawing">0.00 A</td>
|
<td class="bat-current-draw">0.00 A</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td data-i18n="initialSetupPowerDraw"></td>
|
||||||
|
<td class="bat-power-draw">0.00 W</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td data-i18n="initialSetupDrawn"></td>
|
<td data-i18n="initialSetupDrawn"></td>
|
||||||
|
|
|
@ -93,8 +93,9 @@ TABS.setup.initialize = function (callback) {
|
||||||
bat_thresh_e = $('.bat-thresh'),
|
bat_thresh_e = $('.bat-thresh'),
|
||||||
bat_full_e = $('.bat-full'),
|
bat_full_e = $('.bat-full'),
|
||||||
bat_mah_drawn_e = $('.bat-mah-drawn'),
|
bat_mah_drawn_e = $('.bat-mah-drawn'),
|
||||||
bat_mwh_drawn_e = $('.bat-mwh-drawn'),
|
bat_wh_drawn_e = $('.bat-mwh-drawn'),
|
||||||
bat_mah_drawing_e = $('.bat-mah-drawing'),
|
bat_current_draw_e = $('.bat-current-draw'),
|
||||||
|
bat_power_draw_e = $('.bat-power-draw'),
|
||||||
rssi_e = $('.rssi'),
|
rssi_e = $('.rssi'),
|
||||||
gpsFix_e = $('.gpsFixType'),
|
gpsFix_e = $('.gpsFixType'),
|
||||||
gpsSats_e = $('.gpsSats'),
|
gpsSats_e = $('.gpsSats'),
|
||||||
|
@ -155,7 +156,7 @@ TABS.setup.initialize = function (callback) {
|
||||||
|
|
||||||
helper.interval.add('gui_analog_update', function () {
|
helper.interval.add('gui_analog_update', function () {
|
||||||
bat_cells_e.text(chrome.i18n.getMessage('initialSetupBatteryDetectedCellsValue', [ANALOG.cell_count]));
|
bat_cells_e.text(chrome.i18n.getMessage('initialSetupBatteryDetectedCellsValue', [ANALOG.cell_count]));
|
||||||
bat_voltage_e.text(chrome.i18n.getMessage('initialSetupBatteryValue', [ANALOG.voltage]));
|
bat_voltage_e.text(chrome.i18n.getMessage('initialSetupBatteryVoltageValue', [ANALOG.voltage]));
|
||||||
remaining_capacity_wh_decimals = ANALOG.battery_remaining_capacity.toString().length < 5 ? 3 : (7 - ANALOG.battery_remaining_capacity.toString().length);
|
remaining_capacity_wh_decimals = ANALOG.battery_remaining_capacity.toString().length < 5 ? 3 : (7 - ANALOG.battery_remaining_capacity.toString().length);
|
||||||
remaining_capacity_value = MISC.battery_capacity_unit == 'mAh' ? ANALOG.battery_remaining_capacity : (ANALOG.battery_remaining_capacity / 1000).toFixed(remaining_capacity_wh_decimals < 0 ? 0 : remaining_capacity_wh_decimals);
|
remaining_capacity_value = MISC.battery_capacity_unit == 'mAh' ? ANALOG.battery_remaining_capacity : (ANALOG.battery_remaining_capacity / 1000).toFixed(remaining_capacity_wh_decimals < 0 ? 0 : remaining_capacity_wh_decimals);
|
||||||
remaining_capacity_unit = MISC.battery_capacity_unit == 'mAh' ? 'mAh' : 'Wh';
|
remaining_capacity_unit = MISC.battery_capacity_unit == 'mAh' ? 'mAh' : 'Wh';
|
||||||
|
@ -165,8 +166,9 @@ TABS.setup.initialize = function (callback) {
|
||||||
bat_thresh_e.text(chrome.i18n.getMessage('initialSetupBatteryThresholdsValue', [ANALOG.use_capacity_thresholds]));
|
bat_thresh_e.text(chrome.i18n.getMessage('initialSetupBatteryThresholdsValue', [ANALOG.use_capacity_thresholds]));
|
||||||
bat_mah_drawn_e.text(chrome.i18n.getMessage('initialSetupBatteryMahValue', [ANALOG.mAhdrawn]));
|
bat_mah_drawn_e.text(chrome.i18n.getMessage('initialSetupBatteryMahValue', [ANALOG.mAhdrawn]));
|
||||||
capacity_drawn_decimals = ANALOG.mWhdrawn.toString().length < 5 ? 3 : (7 - ANALOG.mWhdrawn.toString().length);
|
capacity_drawn_decimals = ANALOG.mWhdrawn.toString().length < 5 ? 3 : (7 - ANALOG.mWhdrawn.toString().length);
|
||||||
bat_mwh_drawn_e.text(chrome.i18n.getMessage('initialSetup_Wh_drawnValue', [(ANALOG.mWhdrawn / 1000).toFixed(capacity_drawn_decimals < 0 ? 0 : capacity_drawn_decimals)]));
|
bat_wh_drawn_e.text(chrome.i18n.getMessage('initialSetup_Wh_drawnValue', [(ANALOG.mWhdrawn / 1000).toFixed(capacity_drawn_decimals < 0 ? 0 : capacity_drawn_decimals)]));
|
||||||
bat_mah_drawing_e.text(chrome.i18n.getMessage('initialSetupBatteryAValue', [ANALOG.amperage.toFixed(2)]));
|
bat_current_draw_e.text(chrome.i18n.getMessage('initialSetupCurrentDrawValue', [ANALOG.amperage.toFixed(2)]));
|
||||||
|
bat_power_draw_e.text(chrome.i18n.getMessage('initialSetupPowerDrawValue', [ANALOG.power.toFixed(2)]));
|
||||||
rssi_e.text(chrome.i18n.getMessage('initialSetupRSSIValue', [((ANALOG.rssi / 1023) * 100).toFixed(0)]));
|
rssi_e.text(chrome.i18n.getMessage('initialSetupRSSIValue', [((ANALOG.rssi / 1023) * 100).toFixed(0)]));
|
||||||
}, 100, true);
|
}, 100, true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue