CF/BF - Initial port of power/battery tab from CF 1.x.
The voltage and amperage meters cannot yet be configured and are disabled.10.3.x-maintenance
parent
43f1468451
commit
1752c5d39d
|
@ -100,6 +100,9 @@
|
|||
"tabOsd": {
|
||||
"message": "OSD"
|
||||
},
|
||||
"tabPower": {
|
||||
"message": "Power & Battery"
|
||||
},
|
||||
"tabGPS": {
|
||||
"message": "GPS"
|
||||
},
|
||||
|
@ -556,6 +559,9 @@
|
|||
"featureOSD": {
|
||||
"message": "On Screen Display"
|
||||
},
|
||||
"featureVTX": {
|
||||
"message": "Video Transmitter"
|
||||
},
|
||||
"featureFAILSAFE": {
|
||||
"message": "Enable Failsafe Stage 2"
|
||||
},
|
||||
|
@ -1885,6 +1891,128 @@
|
|||
"failsafeKillSwitchHelp": {
|
||||
"message": "Set this option to make the failsafe switch, configured in the modes tab, act as a direct kill switch, bypassing the selected failsafe procedure. <strong>Note:</strong> Arming is blocked with the failsafe kill switch in the ON position"
|
||||
},
|
||||
"powerFirmwareUpgradeRequired": {
|
||||
"message": "Firmware upgrade <span style=\"color: red\">required</span>. Battery/Amperage/Voltage configurations using API < 1.22.0 is not supported."
|
||||
},
|
||||
|
||||
"powerButtonSave": {
|
||||
"message": "Save"
|
||||
},
|
||||
|
||||
"powerVoltageHead": {
|
||||
"message": "Voltage"
|
||||
},
|
||||
"powerVoltageValue": {
|
||||
"message": "$1 V"
|
||||
},
|
||||
"powerAmperageValue": {
|
||||
"message": "$1 A"
|
||||
},
|
||||
"powerVoltageId10": {
|
||||
"message": "Battery"
|
||||
},
|
||||
"powerVoltageId20": {
|
||||
"message": "5V"
|
||||
},
|
||||
"powerVoltageId30": {
|
||||
"message": "9V"
|
||||
},
|
||||
"powerVoltageId40": {
|
||||
"message": "12V"
|
||||
},
|
||||
"powerVoltageId50": {
|
||||
"message": "ESC Combined"
|
||||
},
|
||||
"powerVoltageId60": {
|
||||
"message": "ESC Motor 1"
|
||||
},
|
||||
"powerVoltageId61": {
|
||||
"message": "ESC Motor 2"
|
||||
},
|
||||
"powerVoltageId62": {
|
||||
"message": "ESC Motor 3"
|
||||
},
|
||||
"powerVoltageId63": {
|
||||
"message": "ESC Motor 4"
|
||||
},
|
||||
"powerVoltageId80": {
|
||||
"message": "Cell 1"
|
||||
},
|
||||
"powerVoltageId81": {
|
||||
"message": "Cell 2"
|
||||
},
|
||||
"powerVoltageId82": {
|
||||
"message": "Cell 3"
|
||||
},
|
||||
"powerVoltageId83": {
|
||||
"message": "Cell 4"
|
||||
},
|
||||
"powerVoltageId84": {
|
||||
"message": "Cell 5"
|
||||
},
|
||||
"powerVoltageId85": {
|
||||
"message": "Cell 6"
|
||||
},
|
||||
|
||||
|
||||
"powerVoltageScale": {
|
||||
"message": "Scale"
|
||||
},
|
||||
"powerVoltageDivider": {
|
||||
"message": "Divider Value"
|
||||
},
|
||||
"powerVoltageMultiplier": {
|
||||
"message": "Multiplier Value"
|
||||
},
|
||||
|
||||
"powerAmperageHead": {
|
||||
"message": "Amperage"
|
||||
},
|
||||
"powerAmperageId10": {
|
||||
"message": "Battery"
|
||||
},
|
||||
"powerAmperageId50": {
|
||||
"message": "ESC Combined"
|
||||
},
|
||||
"powerAmperageId80": {
|
||||
"message": "Virtual"
|
||||
},
|
||||
"powerMahValue": {
|
||||
"message": "$1 mAh"
|
||||
},
|
||||
|
||||
"powerAmperageScale": {
|
||||
"message": "Scale the output voltage to milliamps [1/10th mV/A]"
|
||||
},
|
||||
"powerAmperageOffset": {
|
||||
"message": "Offset in millivolt steps"
|
||||
},
|
||||
|
||||
"powerBatteryHead": {
|
||||
"message": "Battery"
|
||||
},
|
||||
"powerBatteryConnected": {
|
||||
"message": "Connected"
|
||||
},
|
||||
"powerBatteryConnectedValueYes": {
|
||||
"message": "Yes (Cells: $1)"
|
||||
},
|
||||
"powerBatteryConnectedValueNo": {
|
||||
"message": "No"
|
||||
},
|
||||
"powerBatteryVoltage": {
|
||||
"message": "Voltage"
|
||||
},
|
||||
"powerBatteryCurrentDrawn": {
|
||||
"message": "mAh used"
|
||||
},
|
||||
"powerBatteryAmperage": {
|
||||
"message": "Amperage"
|
||||
},
|
||||
"powerBatteryCapacity": {
|
||||
"message": "Capacity (mAh)"
|
||||
},
|
||||
|
||||
"mainHelpArmed": {
|
||||
"message": "Motor Arming"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="-99 43 85 56.7" style="enable-background:new -99 43 85 56.7;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#838281;}
|
||||
</style>
|
||||
<g>
|
||||
<path class="st0" d="M-21.5,60h-2.6v-7c0-1.8-1.5-3.3-3.3-3.3h-63.6c-1.8,0-3.3,1.5-3.3,3.3v37.9c0,1.8,1.5,3.3,3.3,3.3h63.6
|
||||
c1.8,0,3.3-1.5,3.3-3.3v-6.7h2.6c1.8,0,3.3-1.5,3.3-3.3V63.3C-18.2,61.4-19.7,60-21.5,60L-21.5,60z M-30.6,87.6h-57V56.3h57V87.6z
|
||||
M-30.6,87.6"/>
|
||||
<path class="st0" d="M-61.4,61.9L-61.4,61.9l-17.1,15.6l15.8-6.7l5.9,11.2l17.1-15.6L-55.5,73L-61.4,61.9z M-61.4,61.9"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 828 B |
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="-99 43 85 56.7" style="enable-background:new -99 43 85 56.7;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFFFFF;}
|
||||
</style>
|
||||
<g>
|
||||
<path class="st0" d="M-21.5,60h-2.6v-7c0-1.8-1.5-3.3-3.3-3.3h-63.6c-1.8,0-3.3,1.5-3.3,3.3v37.9c0,1.8,1.5,3.3,3.3,3.3h63.6
|
||||
c1.8,0,3.3-1.5,3.3-3.3v-6.7h2.6c1.8,0,3.3-1.5,3.3-3.3V63.3C-18.2,61.4-19.7,60-21.5,60L-21.5,60z M-30.6,87.6h-57V56.3h57V87.6z
|
||||
M-30.6,87.6"/>
|
||||
<path class="st0" d="M-61.4,61.9L-61.4,61.9l-17.1,15.6l15.8-6.7l5.9,11.2l17.1-15.6L-55.5,73L-61.4,61.9z M-61.4,61.9"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 828 B |
|
@ -21,6 +21,7 @@ var GUI_control = function () {
|
|||
'failsafe',
|
||||
'transponder',
|
||||
'osd',
|
||||
'power',
|
||||
'adjustments',
|
||||
'auxiliary',
|
||||
'cli',
|
||||
|
|
|
@ -158,27 +158,29 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
ANALOG.amperage = data.read16() / 100; // A
|
||||
ANALOG.last_received_timestamp = Date.now();
|
||||
break;
|
||||
// case MSPCodes.MSP_VOLTAGE_METERS:
|
||||
// VOLTAGE_METERS = [];
|
||||
// for (var i = 0; i < (message_length); i++) {
|
||||
// var voltageMeter = {};
|
||||
// voltageMeter.voltage = data.readU8() / 10.0;
|
||||
//
|
||||
// VOLTAGE_METERS.push(voltageMeter)
|
||||
// }
|
||||
// break;
|
||||
// case MSPCodes.MSP_CURRENT_METERS:
|
||||
// CURRENT_METERS = [];
|
||||
// for (var i = 0; i < (message_length / 6); i++) {
|
||||
// var amperageMeter = {};
|
||||
// amperageMeter.amperage = data.read16() / 1000; // A
|
||||
// offset += 2;
|
||||
// amperageMeter.mAhDrawn = data.readU32(); // A
|
||||
// offset += 4;
|
||||
//
|
||||
// CURRENT_METERS.push(amperageMeter);
|
||||
// }
|
||||
// break;
|
||||
case MSPCodes.MSP_VOLTAGE_METERS:
|
||||
VOLTAGE_METERS = [];
|
||||
var voltageMeterLength = 2;
|
||||
for (var i = 0; i < (data.byteLength / voltageMeterLength); i++) {
|
||||
var voltageMeter = {};
|
||||
voltageMeter.id = data.readU8();
|
||||
voltageMeter.voltage = data.readU8() / 10.0;
|
||||
|
||||
VOLTAGE_METERS.push(voltageMeter)
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_CURRENT_METERS:
|
||||
CURRENT_METERS = [];
|
||||
var currentMeterLength = 5;
|
||||
for (var i = 0; i < (data.byteLength / currentMeterLength); i++) {
|
||||
var currentMeter = {};
|
||||
currentMeter.id = data.readU8();
|
||||
currentMeter.mAhDrawn = data.readU16(); // mAh
|
||||
currentMeter.amperage = data.readU16() / 1000; // A
|
||||
|
||||
CURRENT_METERS.push(currentMeter);
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_BATTERY_STATE:
|
||||
BATTERY_STATE.cellCount = data.readU8();
|
||||
BATTERY_STATE.capacity = data.readU16(); // mAh
|
||||
|
@ -1232,7 +1234,7 @@ MspHelper.prototype.crunch = function(code) {
|
|||
buffer.push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
|
||||
.push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10))
|
||||
.push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10))
|
||||
.push16(BATTERY_CONFIG.batterycapacity)
|
||||
.push16(BATTERY_CONFIG.capacity)
|
||||
.push8(BATTERY_CONFIG.voltageMeterSource)
|
||||
.push8(BATTERY_CONFIG.currentMeterSource);
|
||||
break;
|
||||
|
|
13
main.css
13
main.css
|
@ -811,6 +811,19 @@ li.active .ic_transponder {
|
|||
background-image: url(images/icons/icon_osd_white.svg);
|
||||
}
|
||||
|
||||
.ic_power {
|
||||
background-image: url(images/icons/cf_icon_power_grey.svg);
|
||||
background-position-y: 9px;
|
||||
}
|
||||
|
||||
.ic_power:hover {
|
||||
background-image: url(images/icons/cf_icon_power_white.svg);
|
||||
}
|
||||
|
||||
li.active .ic_power {
|
||||
background-image: url(images/icons/cf_icon_power_white.svg);
|
||||
}
|
||||
|
||||
/* SPARE Tab-Icons */
|
||||
.ic_failsafe {
|
||||
background-image: url(images/icons/cf_icon_failsafe_grey.svg);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<link type="text/css" rel="stylesheet" href="./tabs/auxiliary.css" media="all"/>
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/failsafe.css" media="all"/>
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/osd.css" media="all"/>
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/power.css" media="all"/>
|
||||
<link type="text/css" rel="stylesheet" href="./tabs/transponder.css" media="all"/>
|
||||
<link type="text/css" rel="stylesheet" href="./css/opensans_webfontkit/fonts.css" media="all"/>
|
||||
<link type="text/css" rel="stylesheet" href="./css/dropdown-lists/css/style_lists.css" media="all"/>
|
||||
|
@ -87,6 +88,7 @@
|
|||
<script type="text/javascript" src="./tabs/firmware_flasher.js"></script>
|
||||
<script type="text/javascript" src="./tabs/failsafe.js"></script>
|
||||
<script type="text/javascript" src="./tabs/osd.js"></script>
|
||||
<script type="text/javascript" src="./tabs/power.js"></script>
|
||||
<script type="text/javascript" src="./tabs/transponder.js"></script>
|
||||
<title></title>
|
||||
</head>
|
||||
|
@ -216,6 +218,8 @@
|
|||
<li class="tab_ports"><a href="#" i18n="tabPorts" class="tabicon ic_ports" title="Ports"></a></li>
|
||||
<li class="tab_configuration"><a href="#" i18n="tabConfiguration" class="tabicon ic_config"
|
||||
title="Configuration"></a></li>
|
||||
<li class="tab_power"><a href="#" i18n="tabPower" class="tabicon ic_power"
|
||||
title="Power & Battery"></a></li>
|
||||
<li class="tab_failsafe"><a href="#" i18n="tabFailsafe" class="tabicon ic_failsafe"
|
||||
title="Failsafe"></a></li>
|
||||
<li class="tab_pid_tuning"><a href="#" i18n="tabPidTuning" class="tabicon ic_pid"
|
||||
|
|
3
main.js
3
main.js
|
@ -149,6 +149,9 @@ $(document).ready(function () {
|
|||
case 'osd':
|
||||
TABS.osd.initialize(content_ready);
|
||||
break;
|
||||
case 'power':
|
||||
TABS.power.initialize(content_ready);
|
||||
break;
|
||||
case 'setup':
|
||||
TABS.setup.initialize(content_ready);
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
#tab-power-templates {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab-power td.configuration {
|
||||
padding-top: 5px;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.tab-power .battery-state .configuration {
|
||||
border-bottom: 0px;
|
||||
}
|
||||
|
||||
.tab-power td.value {
|
||||
text-align: left;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.tab-power .number input {
|
||||
width: 50px;
|
||||
padding-left: 3px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
text-align: left;
|
||||
border: 1px solid silver;
|
||||
border-radius: 3px;
|
||||
margin-right: 11px;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
|
||||
.tab-power .spacer_box {
|
||||
padding-bottom: 10px;
|
||||
float: left;
|
||||
width: calc(100% - 20px);
|
||||
}
|
||||
|
||||
.tab-power .number,
|
||||
.tab-power .select
|
||||
{
|
||||
margin-bottom: 5px;
|
||||
clear: left;
|
||||
padding-bottom: 5px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
width: 100%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.tab-power .battery-configuration select {
|
||||
border: 1px solid silver;
|
||||
margin-right: 5px;
|
||||
float: left;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.tab-power .number:last-child,
|
||||
.tab-power .select:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.tab-power .require-support {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab-power.supported .require-support {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tab-power .require-upgrade {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tab-power.supported .require-upgrade {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
<div class="tab-power toolbar_fixed_bottom">
|
||||
<div class="content_wrapper initialstyle">
|
||||
<!-- should be the first DIV on each tab -->
|
||||
<div class="cf_column spacerbottom">
|
||||
<div class="tab_title" i18n="tabPower">Power</div>
|
||||
<div class="cf_doc_version_bt">
|
||||
<a id="button-documentation" href="" target="_blank"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="require-support">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerVoltageHead"></div>
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
|
||||
<tbody class="voltage-meters">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerAmperageHead"></div>
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
|
||||
<tbody class="amperage-meters">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerBatteryHead"></div>
|
||||
</div>
|
||||
<div class="spacer_box battery">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
|
||||
<tbody class="battery-state">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="note require-upgrade">
|
||||
<div class="note_spacer">
|
||||
<p i18n="powerFirmwareUpgradeRequired"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content_toolbar">
|
||||
<div class="btn save_btn">
|
||||
<a class="save" href="#" i18n="powerButtonSave"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tab-power-templates">
|
||||
<table class="voltage-meters">
|
||||
<tbody>
|
||||
<tr class="voltage-meter">
|
||||
<td class="label"></td>
|
||||
<td class="value"></td>
|
||||
<td class="configuration"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="amperage-meters">
|
||||
<tbody>
|
||||
<tr class="amperage-meter">
|
||||
<td class="label"></td>
|
||||
<td class="value"></td>
|
||||
<td class="configuration"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="battery-states">
|
||||
<tbody class="battery-state">
|
||||
<tr class="connection-state">
|
||||
<td i18n="powerBatteryConnected"></td>
|
||||
<td class="value">?</td>
|
||||
<td class="configuration" rowspan="4"></td>
|
||||
</tr>
|
||||
<tr class="voltage">
|
||||
<td i18n="powerBatteryVoltage"></td>
|
||||
<td class="value"></td>
|
||||
</tr>
|
||||
<tr class="mah-drawn">
|
||||
<td i18n="powerBatteryCurrentDrawn"></td>
|
||||
<td class="value"></td>
|
||||
</tr>
|
||||
<tr class="amperage">
|
||||
<td i18n="powerBatteryAmperage"></td>
|
||||
<td class="value"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="battery-configuration">
|
||||
<div class="select vbatmonitoring">
|
||||
<label>
|
||||
<select class="batterymetersource"><!-- list generated here --></select>
|
||||
<span i18n="configurationBatteryVoltageMeterSource"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="select currentMonitoring">
|
||||
<label>
|
||||
<select class="currentmetersource"><!-- list generated here --></select>
|
||||
<span i18n="configurationBatteryCurrentMeterSource"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="number">
|
||||
<label> <input type="number" name="mincellvoltage" step="0.1" min="1" max="5" /> <span
|
||||
i18n="configurationBatteryMinimum"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="number">
|
||||
<label> <input type="number" name="maxcellvoltage" step="0.1" min="1" max="5" /> <span
|
||||
i18n="configurationBatteryMaximum"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="number">
|
||||
<label> <input type="number" name="warningcellvoltage" step="0.1" min="1" max="5" /> <span
|
||||
i18n="configurationBatteryWarning"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="number">
|
||||
<label> <input type="number" name="capacity" step="1" min="0" max="65535" /> <span
|
||||
i18n="powerBatteryCapacity"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="voltage-configuration">
|
||||
<div class="number">
|
||||
<label> <input type="number" name="vbatscale" step="1" min="10" max="255" /> <span
|
||||
i18n="powerVoltageScale"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="number">
|
||||
<label> <input type="number" name="vbatresdivval" step="1" min="1" max="255" /> <span
|
||||
i18n="powerVoltageDivider"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="number">
|
||||
<label> <input type="number" name="vbatresdivmultiplier" step="1" min="1" max="255" /> <span
|
||||
i18n="powerVoltageMultiplier"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="amperage-configuration">
|
||||
<div class="number">
|
||||
<label> <input type="number" name="amperagescale" step="1" min="-1000" max="1500" /> <span
|
||||
i18n="powerAmperageScale"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="number">
|
||||
<label> <input type="number" name="amperageoffset" step="1" min="0" max="3300" /> <span
|
||||
i18n="powerAmperageOffset"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,275 @@
|
|||
'use strict';
|
||||
|
||||
TABS.power = {
|
||||
supported: false,
|
||||
};
|
||||
|
||||
TABS.power.initialize = function (callback) {
|
||||
var self = this;
|
||||
|
||||
if (GUI.active_tab != 'power') {
|
||||
GUI.active_tab = 'power';
|
||||
googleAnalytics.sendAppView('Power');
|
||||
}
|
||||
|
||||
function load_status() {
|
||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_voltage_meters);
|
||||
}
|
||||
|
||||
function load_voltage_meters() {
|
||||
MSP.send_message(MSPCodes.MSP_VOLTAGE_METERS, false, false, load_current_meters);
|
||||
}
|
||||
|
||||
function load_current_meters() {
|
||||
MSP.send_message(MSPCodes.MSP_CURRENT_METERS, false, false, load_current_meter_configs);
|
||||
}
|
||||
|
||||
function load_current_meter_configs() {
|
||||
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, load_voltage_meter_configs);
|
||||
}
|
||||
|
||||
function load_voltage_meter_configs() {
|
||||
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, load_battery_state);
|
||||
}
|
||||
|
||||
function load_battery_state() {
|
||||
MSP.send_message(MSPCodes.MSP_BATTERY_STATE, false, false, load_battery_config);
|
||||
}
|
||||
|
||||
function load_battery_config() {
|
||||
MSP.send_message(MSPCodes.MSP_BATTERY_CONFIG, false, false, load_html);
|
||||
}
|
||||
|
||||
function load_html() {
|
||||
$('#content').load("./tabs/power.html", process_html);
|
||||
}
|
||||
|
||||
this.supported = semver.gte(CONFIG.apiVersion, "1.22.0");
|
||||
|
||||
if (!this.supported) {
|
||||
load_html();
|
||||
} else {
|
||||
load_status();
|
||||
}
|
||||
|
||||
function update_ui() {
|
||||
if (!TABS.power.supported) {
|
||||
$(".tab-power").removeClass("supported");
|
||||
return;
|
||||
}
|
||||
$(".tab-power").addClass("supported");
|
||||
|
||||
// voltage meters
|
||||
|
||||
var template = $('#tab-power-templates .voltage-meters .voltage-meter');
|
||||
var destination = $('.tab-power .voltage-meters');
|
||||
|
||||
for (var index = 0; index < VOLTAGE_METERS.length; index++) {
|
||||
var meterElement = template.clone();
|
||||
$(meterElement).attr('id', 'voltage-meter-' + index);
|
||||
|
||||
var message = chrome.i18n.getMessage('powerVoltageId' + VOLTAGE_METERS[index].id);
|
||||
$(meterElement).find('.label').text(message)
|
||||
destination.append(meterElement);
|
||||
}
|
||||
|
||||
var template = $('#tab-power-templates .voltage-configuration');
|
||||
for (var index = 0; index < VOLTAGE_METER_CONFIGS.length; index++) {
|
||||
var destination = $('#voltage-meter-' + index + ' .configuration');
|
||||
var element = template.clone();
|
||||
|
||||
var attributeNames = ["vbatscale", "vbatresdivval", "vbatresdivmultiplier"];
|
||||
for (let attributeName of attributeNames) {
|
||||
$(element).find('input[name="' + attributeName + '"]').attr('name', attributeName + '-' + index);
|
||||
}
|
||||
destination.append(element);
|
||||
|
||||
$('input[name="vbatscale-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatscale).attr('disabled','disabled');
|
||||
$('input[name="vbatresdivval-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivval).attr('disabled','disabled');
|
||||
$('input[name="vbatresdivmultiplier-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivmultiplier).attr('disabled','disabled');
|
||||
}
|
||||
|
||||
// amperage meters
|
||||
|
||||
var template = $('#tab-power-templates .amperage-meters .amperage-meter');
|
||||
var destination = $('.tab-power .amperage-meters');
|
||||
|
||||
for (var index = 0; index < CURRENT_METERS.length; index++) {
|
||||
var meterElement = template.clone();
|
||||
$(meterElement).attr('id', 'amperage-meter-' + index);
|
||||
|
||||
var message = chrome.i18n.getMessage('powerAmperageId' + CURRENT_METERS[index].id);
|
||||
$(meterElement).find('.label').text(message)
|
||||
destination.append(meterElement);
|
||||
}
|
||||
|
||||
var template = $('#tab-power-templates .amperage-configuration');
|
||||
for (var index = 0; index < CURRENT_METER_CONFIGS.length; index++) {
|
||||
var destination = $('#amperage-meter-' + index + ' .configuration');
|
||||
var element = template.clone();
|
||||
|
||||
var attributeNames = ["amperagescale", "amperageoffset"];
|
||||
for (let attributeName of attributeNames) {
|
||||
$(element).find('input[name="' + attributeName + '"]').attr('name', attributeName + '-' + index);
|
||||
}
|
||||
destination.append(element);
|
||||
|
||||
$('input[name="amperagescale-' + index + '"]').val(CURRENT_METER_CONFIGS[index].scale).attr('disabled','disabled');
|
||||
$('input[name="amperageoffset-' + index + '"]').val(CURRENT_METER_CONFIGS[index].offset).attr('disabled','disabled');
|
||||
}
|
||||
|
||||
|
||||
// battery
|
||||
|
||||
var template = $('#tab-power-templates .battery-states .battery-state');
|
||||
var destination = $('.tab-power .battery-state');
|
||||
var element = template.clone();
|
||||
$(element).find('.connection-state').attr('id', 'battery-connection-state');
|
||||
$(element).find('.voltage').attr('id', 'battery-voltage');
|
||||
$(element).find('.mah-drawn').attr('id', 'battery-mah-drawn');
|
||||
$(element).find('.amperage').attr('id', 'battery-amperage');
|
||||
|
||||
destination.append(element.children());
|
||||
|
||||
var template = $('#tab-power-templates .battery-configuration');
|
||||
var destination = $('.tab-power .battery .configuration');
|
||||
var element = template.clone();
|
||||
destination.append(element);
|
||||
|
||||
$('input[name="mincellvoltage"]').val(BATTERY_CONFIG.vbatmincellvoltage);
|
||||
$('input[name="maxcellvoltage"]').val(BATTERY_CONFIG.vbatmaxcellvoltage);
|
||||
$('input[name="warningcellvoltage"]').val(BATTERY_CONFIG.vbatwarningcellvoltage);
|
||||
$('input[name="capacity"]').val(BATTERY_CONFIG.capacity);
|
||||
|
||||
var batteryMeterTypes = [
|
||||
'None',
|
||||
'Onboard ADC',
|
||||
'ESC Sensor'
|
||||
];
|
||||
|
||||
var batteryMeterType_e = $('select.batterymetersource');
|
||||
for (var i = 0; i < batteryMeterTypes.length; i++) {
|
||||
batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>');
|
||||
}
|
||||
|
||||
batteryMeterType_e.change(function () {
|
||||
BATTERY_CONFIG.voltageMeterSource = parseInt($(this).val());
|
||||
});
|
||||
batteryMeterType_e.val(BATTERY_CONFIG.voltageMeterSource).change();
|
||||
|
||||
// fill current
|
||||
var currentMeterTypes = [
|
||||
'None',
|
||||
'Onboard ADC',
|
||||
'Virtual',
|
||||
'ESC Sensor'
|
||||
];
|
||||
|
||||
var currentMeterType_e = $('select.currentmetersource');
|
||||
for (var i = 0; i < currentMeterTypes.length; i++) {
|
||||
currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>');
|
||||
}
|
||||
|
||||
currentMeterType_e.change(function () {
|
||||
BATTERY_CONFIG.currentMeterSource = parseInt($(this).val());
|
||||
});
|
||||
currentMeterType_e.val(BATTERY_CONFIG.currentMeterSource).change();
|
||||
|
||||
|
||||
|
||||
function get_slow_data() {
|
||||
MSP.send_message(MSPCodes.MSP_VOLTAGE_METERS, false, false, function () {
|
||||
for (var i = 0; i < VOLTAGE_METERS.length; i++) {
|
||||
var elementName = '#voltage-meter-' + i + ' .value';
|
||||
var element = $(elementName);
|
||||
element.text(chrome.i18n.getMessage('powerVoltageValue', [VOLTAGE_METERS[i].voltage]));
|
||||
}
|
||||
});
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_CURRENT_METERS, false, false, function () {
|
||||
for (var i = 0; i < CURRENT_METERS.length; i++) {
|
||||
var elementName = '#amperage-meter-' + i + ' .value';
|
||||
var element = $(elementName);
|
||||
element.text(chrome.i18n.getMessage('powerAmperageValue', [CURRENT_METERS[i].amperage.toFixed(2)]));
|
||||
}
|
||||
});
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_BATTERY_STATE, false, false, function () {
|
||||
var elementPrefix = '#battery';
|
||||
var element;
|
||||
|
||||
element = $(elementPrefix + '-connection-state .value');
|
||||
element.text(BATTERY_STATE.cellCount > 0 ? chrome.i18n.getMessage('powerBatteryConnectedValueYes', [BATTERY_STATE.cellCount]) : chrome.i18n.getMessage('powerBatteryConnectedValueNo'));
|
||||
element = $(elementPrefix + '-voltage .value');
|
||||
element.text(chrome.i18n.getMessage('powerVoltageValue', [BATTERY_STATE.voltage]));
|
||||
element = $(elementPrefix + '-mah-drawn .value');
|
||||
element.text(chrome.i18n.getMessage('powerMahValue', [BATTERY_STATE.mAhDrawn]));
|
||||
element = $(elementPrefix + '-amperage .value');
|
||||
element.text(chrome.i18n.getMessage('powerAmperageValue', [BATTERY_STATE.amperage]));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$('a.save').click(function () {
|
||||
|
||||
/* FIXME update for api 1.33.0
|
||||
for (var index = 0; index < VOLTAGE_METER_CONFIGS.length; index++) {
|
||||
VOLTAGE_METER_CONFIGS[index].vbatscale = parseInt($('input[name="vbatscale-' + index + '"]').val());
|
||||
VOLTAGE_METER_CONFIGS[index].vbatresdivval = parseInt($('input[name="vbatresdivval-' + index + '"]').val());
|
||||
VOLTAGE_METER_CONFIGS[index].vbatresdivmultiplier = parseInt($('input[name="vbatresdivmultiplier-' + index + '"]').val());
|
||||
}
|
||||
|
||||
for (var index = 0; index < CURRENT_METER_CONFIGS.length; index++) {
|
||||
CURRENT_METER_CONFIGS[index].scale = parseInt($('input[name="amperagescale-' + index + '"]').val());
|
||||
CURRENT_METER_CONFIGS[index].offset = parseInt($('input[name="amperageoffset-' + index + '"]').val());
|
||||
}
|
||||
*/
|
||||
|
||||
BATTERY_CONFIG.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val());
|
||||
BATTERY_CONFIG.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val());
|
||||
BATTERY_CONFIG.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
|
||||
BATTERY_CONFIG.capacity = parseInt($('input[name="capacity"]').val());
|
||||
|
||||
/* FIXME update for api 1.33.0
|
||||
function save_voltage_config() {
|
||||
MSP.sendVoltageMeterConfigs(save_amperage_config);
|
||||
}
|
||||
|
||||
function save_amperage_config() {
|
||||
MSP.sendAmperageMeterConfigs(save_battery_config);
|
||||
}
|
||||
*/
|
||||
|
||||
function save_battery_config() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_BATTERY_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BATTERY_CONFIG), false, save_to_eeprom);
|
||||
}
|
||||
|
||||
function save_to_eeprom() {
|
||||
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, save_completed);
|
||||
}
|
||||
|
||||
function save_completed() {
|
||||
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
TABS.power.initialize();
|
||||
}
|
||||
|
||||
save_battery_config();
|
||||
});
|
||||
|
||||
GUI.interval_add('setup_data_pull_slow', get_slow_data, 200, true); // 5hz
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
update_ui();
|
||||
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
};
|
||||
|
||||
TABS.power.cleanup = function (callback) {
|
||||
if (callback) callback();
|
||||
};
|
Loading…
Reference in New Issue