1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 12:25:13 +03:00

battery voltage indicator

This commit is contained in:
cTn 2013-04-15 08:44:08 +02:00
parent 369a3cb020
commit 0a1b8c5d03
5 changed files with 51 additions and 8 deletions

View file

@ -342,6 +342,33 @@ a:hover {
padding: 5px; padding: 5px;
line-height: 18px; line-height: 18px;
} }
.tab-initial_setup .battery {
float: left;
display: block;
margin-top: 10px;
margin-left: 20px;
width: 145px;
border: 1px solid silver;
}
.tab-initial_setup .battery .head {
display: block;
text-align: center;
line-height: 20px;
font-weight: bold;
border-bottom: 1px solid silver;
background-color: #ececec;
}
.tab-initial_setup .battery .fields {
padding: 5px;
}
.tab-initial_setup .battery .bat-voltage {
padding-left: 20px;
}
.tab-initial_setup .compass-wrapper { .tab-initial_setup .compass-wrapper {
float: left; float: left;

View file

@ -50,7 +50,7 @@ $(document).ready(function() {
}); });
// temporary // temporary
//$('#content').load("./tabs/about.html"); //$('#content').load("./tabs/initial_setup.html", tab_initialize_initial_setup);
}); });
function disable_timers() { function disable_timers() {

View file

@ -39,7 +39,7 @@ var MSP_codes = {
MSP_DEBUGMSG: 253, MSP_DEBUGMSG: 253,
MSP_DEBUG: 254 MSP_DEBUG: 254
}; }
var CONFIG = { var CONFIG = {
version: 0, version: 0,
@ -48,7 +48,7 @@ var CONFIG = {
i2cError: 0, i2cError: 0,
activeSensors: 0, activeSensors: 0,
mode: 0 mode: 0
}; }
var PIDs = new Array(10); var PIDs = new Array(10);
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
@ -64,7 +64,7 @@ var RC = {
AUX2: 0, AUX2: 0,
AUX3: 0, AUX3: 0,
AUX4: 0 AUX4: 0
}; }
var RC_tuning = { var RC_tuning = {
RC_RATE: 0, RC_RATE: 0,
@ -74,7 +74,7 @@ var RC_tuning = {
dynamic_THR_PID: 0, dynamic_THR_PID: 0,
throttle_MID: 0, throttle_MID: 0,
throttle_EXPO: 0, throttle_EXPO: 0,
}; }
var AUX_CONFIG = new Array(); var AUX_CONFIG = new Array();
var AUX_CONFIG_values = new Array(); var AUX_CONFIG_values = new Array();
@ -87,7 +87,7 @@ var SENSOR_DATA = {
kinematicsX: 0.0, kinematicsX: 0.0,
kinematicsY: 0.0, kinematicsY: 0.0,
kinematicsZ: 0.0 kinematicsZ: 0.0
}; }
var MOTOR_DATA = new Array(8); var MOTOR_DATA = new Array(8);
var SERVO_DATA = new Array(8); var SERVO_DATA = new Array(8);
@ -102,7 +102,12 @@ var GPS_DATA = {
distanceToHome: 0, distanceToHome: 0,
ditectionToHome: 0, ditectionToHome: 0,
update: 0 update: 0
}; }
var BATTERY = {
voltage: 0,
pMeterSum: 0,
}
var CLI_active = false; var CLI_active = false;
@ -489,7 +494,8 @@ function process_message(code, data) {
SENSOR_DATA.altitude = view.getUint32(0, 1) / 100.0; // correct scale factor SENSOR_DATA.altitude = view.getUint32(0, 1) / 100.0; // correct scale factor
break; break;
case MSP_codes.MSP_BAT: case MSP_codes.MSP_BAT:
console.log(data); BATTERY.voltage = view.getUint8(0) / 10.0;
BATTERY.power = view.getUint16(1, 1);
break; break;
case MSP_codes.MSP_RC_TUNING: case MSP_codes.MSP_RC_TUNING:
RC_tuning.RC_RATE = parseFloat((view.getUint8(0) / 100).toFixed(2)); RC_tuning.RC_RATE = parseFloat((view.getUint8(0) / 100).toFixed(2));

View file

@ -64,6 +64,12 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="battery">
<span class="head">Battery</span>
<div class="fields">
Voltage: <span class="bat-voltage">0 V</span>
</div>
</div>
<div class="compass-wrapper"> <div class="compass-wrapper">
<div id="compass"> <div id="compass">
<span>N</span> <span>N</span>

View file

@ -44,8 +44,12 @@ function data_poll() {
$('div#compass .pointer').css('-webkit-transform', 'rotate(' + (SENSOR_DATA.kinematicsZ) + 'deg)'); $('div#compass .pointer').css('-webkit-transform', 'rotate(' + (SENSOR_DATA.kinematicsZ) + 'deg)');
$('div#compass .value').html(SENSOR_DATA.kinematicsZ + '&deg;'); $('div#compass .value').html(SENSOR_DATA.kinematicsZ + '&deg;');
// Update voltage indicator
$('span.bat-voltage').html(BATTERY.voltage + ' V');
// Request new data // Request new data
send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE); send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE);
send_message(MSP_codes.MSP_RAW_GPS, MSP_codes.MSP_RAW_GPS); send_message(MSP_codes.MSP_RAW_GPS, MSP_codes.MSP_RAW_GPS);
send_message(MSP_codes.MSP_COMP_GPS, MSP_codes.MSP_COMP_GPS); send_message(MSP_codes.MSP_COMP_GPS, MSP_codes.MSP_COMP_GPS);
send_message(MSP_codes.MSP_BAT, MSP_codes.MSP_BAT);
} }