Permalink
Browse files

Show VTX channel and band on the setup page.

  • Loading branch information...
1 parent a33a3b3 commit bbab4a298551df8c26c0f9e48d799f74edea712c @hydra hydra committed with hydra Oct 28, 2016
Showing with 122 additions and 3 deletions.
  1. +23 −0 _locales/en/messages.json
  2. +21 −0 js/fc.js
  3. +18 −0 js/msp.js
  4. +26 −0 tabs/setup.html
  5. +33 −2 tabs/setup.js
  6. +1 −1 tabs/setup_osd.html
@@ -405,6 +405,29 @@
"initialSetupModel": {
"message": "Model: $1"
},
+
+ "initialSetupVTXHead": {
+ "message": "VTX"
+ },
+ "initialSetupVTXBandAndChannel": {
+ "message": "Band and Channel"
+ },
+ "initialSetupVTXBandAndChannelValue": {
+ "message": "$1-$2"
+ },
+ "initialSetupVTXRFPower": {
+ "message": "RF Power"
+ },
+ "initialSetupVTXState": {
+ "message": "State"
+ },
+ "initialSetupVTXStateValueEnabled": {
+ "message": "Enabled"
+ },
+ "initialSetupVTXStateValueDisabled": {
+ "message": "Disabled"
+ },
+
"initialSetupAttitude": {
"message": "$1 deg"
},
View
@@ -46,6 +46,9 @@ var RX_CONFIG;
var FAILSAFE_CONFIG;
var RXFAIL_CONFIG;
var PILOT_CONFIG;
+var VTX;
+var VTX_STATE;
+var VTX_CONFIG;
var FC = {
resetState: function() {
@@ -285,5 +288,23 @@ var FC = {
PILOT_CONFIG = {
callsign: " CLEANFLIGHT! ",
};
+
+ VTX = {
+ supported: false,
+ };
+
+ VTX_STATE = {
+ channel: 0,
+ band: 0,
+ rfPower: 0,
+ enabled: false,
+ };
+
+ VTX_CONFIG = {
+ channel: 0,
+ band: 0,
+ rfPower: 0,
+ enabledOnBoot: false,
+ };
}
};
View
@@ -52,6 +52,8 @@ var MSP_codes = {
MSP_SET_BLACKBOX_CONFIG: 81,
MSP_TRANSPONDER_CONFIG: 82,
MSP_SET_TRANSPONDER_CONFIG: 83,
+ MSP_VTX: 88,
+ MSP_SET_VTX: 89,
MSP_LED_STRIP_MODECOLOR: 127,
MSP_SET_LED_STRIP_MODECOLOR: 221,
@@ -449,6 +451,22 @@ var MSP = {
BATTERY_STATE.mah_drawn = data.getUint16(offset, 1);
offset += 2;
break;
+ case MSP_codes.MSP_VTX:
+ var offset = 0;
+ var flags = data.getUint8(offset++, 1);
+
+ VTX.supported = bit_check(flags, 0);
+
+ VTX_STATE.enabled = bit_check(flags, 1);
+ VTX_STATE.channel = data.getUint8(offset++, 1);
+ VTX_STATE.band = data.getUint8(offset++, 1);
+ VTX_STATE.rfPower = data.getUint8(offset++, 1);
+
+ VTX_CONFIG.channel = data.getUint8(offset++, 1);
+ VTX_CONFIG.band = data.getUint8(offset++, 1);
+ VTX_CONFIG.rfPower = data.getUint8(offset++, 1);
+ VTX_CONFIG.enabledOnBoot = data.getUint8(offset++, 1);
+ break;
case MSP_codes.MSP_RC_TUNING:
var offset = 0;
View
@@ -130,6 +130,32 @@
</div>
</div>
</div>
+ <div class="spacer_left vtx_state">
+ <div class="gui_box grey">
+ <div class="gui_box_titlebar">
+ <div class="spacer_box_title" i18n="initialSetupVTXHead"></div>
+ </div>
+ <div class="spacer_box">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
+ <tbody>
+ <tr>
+ <td i18n="initialSetupVTXBandAndChannel"></td>
+ <td class="vtx-band-and-channel"></td>
+ </tr>
+ <tr>
+ <td i18n="initialSetupVTXRFPower"></td>
+ <td class="vtx-rf-power"></td>
+ </tr>
+ <tr>
+ <td i18n="initialSetupVTXState"></td>
+ <td class="vtx-state"></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+
<div class="spacer_left">
<div class="gui_box grey instrumentsbox" align="center">
<div class="gui_box_titlebar" align="left">
View
@@ -21,7 +21,16 @@ TABS.setup.initialize = function (callback) {
}
function load_misc_data() {
- MSP.send_message(MSP_codes.MSP_MISC, false, false, load_html);
+ MSP.send_message(MSP_codes.MSP_MISC, false, false, load_vtx);
+ }
+
+ function load_vtx() {
+ var next_callback = load_html;
+ if (semver.gte(CONFIG.apiVersion, "1.25.0")) {
+ MSP.send_message(MSP_codes.MSP_VTX, false, false, next_callback);
+ } else {
+ next_callback();
+ }
}
function load_html() {
@@ -54,6 +63,10 @@ TABS.setup.initialize = function (callback) {
$('a.calibrateMag').addClass('disabled');
$('default_btn').addClass('disabled');
}
+
+ if (!VTX.supported) {
+ $('.vtx_state').hide();
+ }
self.initializeInstruments();
@@ -137,7 +150,10 @@ TABS.setup.initialize = function (callback) {
gpsLon_e = $('.gpsLon'),
roll_e = $('dd.roll'),
pitch_e = $('dd.pitch'),
- heading_e = $('dd.heading');
+ heading_e = $('dd.heading'),
+ vtx_band_and_channel_e = $('.vtx-band-and-channel'),
+ vtx_rf_power_e = $('.vtx-rf-power'),
+ vtx_state_e = $('.vtx-state');
function get_slow_data() {
MSP.send_message(MSP_codes.MSP_ANALOG, false, false, function () {
@@ -147,6 +163,21 @@ TABS.setup.initialize = function (callback) {
rssi_e.text(chrome.i18n.getMessage('initialSetupRSSIValue', [((ANALOG.rssi / 1023) * 100).toFixed(0)]));
});
+ if (VTX.supported) {
+ MSP.send_message(MSP_codes.MSP_VTX, false, false, function () {
+ var vtxBands = [
+ 'A', 'B', 'C', 'D', 'R'
+ ];
+ var vtxBand = vtxBands[VTX_STATE.band];
+ vtx_band_and_channel_e.text(chrome.i18n.getMessage('initialSetupVTXBandAndChannelValue', [vtxBand, VTX_STATE.channel + 1]));
+
+ vtx_rf_power_e.text(VTX_STATE.rfPower);
+
+ var vtxStateValueKey = VTX_STATE.enabled ? 'initialSetupVTXStateValueEnabled' : 'initialSetupVTXStateValueDisabled';
+ vtx_state_e.text(chrome.i18n.getMessage(vtxStateValueKey));
+ });
+ }
+
if (have_sensor(CONFIG.activeSensors, 'gps')) {
MSP.send_message(MSP_codes.MSP_RAW_GPS, false, false, function () {
gpsFix_e.html((GPS_DATA.fix) ? chrome.i18n.getMessage('gpsFixTrue') : chrome.i18n.getMessage('gpsFixFalse'));
View
@@ -1,5 +1,5 @@
<div class="tab-setup-osd">
- <div class="content_wrapper initialstyle">
+ <div class="content_wrapper">
<!-- should be the first DIV on each tab -->
<div class="cf_column full spacerbottom">
<div class="tab_title" i18n="tabSetupOSD">OSD</div>

0 comments on commit bbab4a2

Please sign in to comment.