Add beeper configuration to Configuration tab

10.3.x-maintenance
Bas Delfos 2017-07-25 22:21:02 +02:00
parent fc371852b2
commit a693761bff
9 changed files with 269 additions and 84 deletions

View File

@ -688,6 +688,66 @@
"configurationThrottleMinimumCommandHelp": { "configurationThrottleMinimumCommandHelp": {
"message": "This is the value that is sent to the ESCs when the craft is disarmed. Set this to a value that has the motors stopped (1000 for most ESCs)." "message": "This is the value that is sent to the ESCs when the craft is disarmed. Set this to a value that has the motors stopped (1000 for most ESCs)."
}, },
"configurationBeeper": {
"message": "Beeper Configuration"
},
"beeperGYRO_CALIBRATED": {
"message": "Beeps when gyro has been calibrated"
},
"beeperRX_LOST": {
"message": "Beeps when TX is turned off or signal lost (repeat until TX is okay)"
},
"beeperRX_LOST_LANDING": {
"message": "Beeps SOS when armed and TX is turned off or signal lost (autolanding/autodisarm)"
},
"beeperDISARMING": {
"message": "Beep when disarming the flightcontroller"
},
"beeperARMING": {
"message": "Beep when arming the flightcontroller"
},
"beeperARMING_GPS_FIX": {
"message": "Beep a special tone when arming the board and GPS has fix"
},
"beeperBAT_CRIT_LOW": {
"message": "Longer warning beeps when battery is critically low (repeats)"
},
"beeperBAT_LOW": {
"message": "Warning beeps when battery is getting low (repeats)"
},
"beeperGPS_STATUS": {
"message": ""
},
"beeperRX_SET": {
"message": "Beeps when aux channel is set for beep or beep sequence how many satellites has found if GPS enabled"
},
"beeperDISARM_REPEAT": {
"message": "Beeps sounded while stick held in disarm position"
},
"beeperACC_CALIBRATION": {
"message": "Accelerometer inflight calibration completed confirmation"
},
"beeperACC_CALIBRATION_FAIL": {
"message": "Accelerometer inflight calibration failed"
},
"beeperREADY_BEEP": {
"message": "Ring a tone when GPS is locked and ready"
},
"beeperMULTI_BEEPS": {
"message": ""
},
"beeperARMED": {
"message": "Warning beeps when board is armed (repeats until board is disarmed or throttle is increased)"
},
"beeperSYSTEM_INIT": {
"message": "Initialisation beeps when board is powered on"
},
"beeperUSB": {
"message": "Beep when flight controller is powered from USB. Turn this off when you don't want the beeper on the workbench"
},
"beeperBLACKBOX_ERASE": {
"message": "Beep when blackbox erase completes"
},
"configuration3d": { "configuration3d": {
"message": "3D ESC/Motor Features" "message": "3D ESC/Motor Features"
}, },
@ -1720,43 +1780,6 @@
"ledStripIndecatorOverlay": { "ledStripIndecatorOverlay": {
"message": "Indicator (uses position on matrix)" "message": "Indicator (uses position on matrix)"
}, },
"ledStripVtxOverlay": {
"message": "VTX (uses vtx frequency to assign color)"
},
"ledStripFunctionSection": {
"message": "LED Functions"
},
"ledStripFunctionTitle": {
"message": "Function"
},
"ledStripColorModifierTitle": {
"message": "Color modifier"
},
"ledStripThrottleFunction": {
"message": "Throttle"
},
"ledStripVtxFunction": {
"message": "Larson scanner"
},
"ledStripBlinkTitle": {
"message": "Blink"
},
"ledStripBlinkAlwaysOverlay": {
"message": "Blink always"
},
"ledStripBlinkLandingOverlay": {
"message": "Blink on landing"
},
"ledStripOverlayTitle": {
"message": "Overlay"
},
"ledStripWarningsOverlay": {
"message": "Warnings"
},
"ledStripIndecatorOverlay": {
"message": "Indicator (uses position on matrix)"
},
"controlAxisRoll": { "controlAxisRoll": {
"message": "Roll" "message": "Roll"
}, },

95
js/Beepers.js Normal file
View File

@ -0,0 +1,95 @@
'use strict;'
var Beepers = function (config) {
var self = this;
var beepers = [
{bit: 0, name: 'GYRO_CALIBRATED', visible: true},
{bit: 1, name: 'RX_LOST', visible: true},
{bit: 2, name: 'RX_LOST_LANDING', visible: true},
{bit: 3, name: 'DISARMING', visible: true},
{bit: 4, name: 'ARMING', visible: true},
{bit: 5, name: 'ARMING_GPS_FIX', visible: true},
{bit: 6, name: 'BAT_CRIT_LOW', visible: true},
{bit: 7, name: 'BAT_LOW', visible: true},
{bit: 8, name: 'GPS_STATUS', visible: false}, // do not show
{bit: 9, name: 'RX_SET', visible: true},
{bit: 10, name: 'DISARM_REPEAT', visible: true},
{bit: 11, name: 'ACC_CALIBRATION', visible: true},
{bit: 12, name: 'ACC_CALIBRATION_FAIL', visible: true},
{bit: 13, name: 'READY_BEEP', visible: true},
{bit: 14, name: 'MULTI_BEEPS', visible: false}, // do not show
{bit: 15, name: 'ARMED', visible: true},
{bit: 16, name: 'SYSTEM_INIT', visible: true},
{bit: 17, name: 'USB', visible: true},
{bit: 18, name: 'BLACKBOX_ERASE', visible: true},
];
self._beepers = beepers;
self._beeperMask = 0;
};
Beepers.prototype.getMask = function () {
var self = this;
return self._beeperMask;
};
Beepers.prototype.setMask = function (beeperMask) {
var self = this;
self._beeperMask = beeperMask;
};
Beepers.prototype.isEnabled = function (beeperName) {
var self = this;
for (var i = 0; i < self._beepers.length; i++) {
if (self._beepers[i].name === beeperName && bit_check(self._beeperOfMask, self._beepers[i].bit)) {
return true;
}
}
return false;
};
Beepers.prototype.generateElements = function (template, destination) {
var self = this;
for (i = 0; i < self._beepers.length; i++) {
if (self._beepers[i].visible) {
var element = template.clone();
destination.append(element);
var input_e = $(element).find('input');
var label_e = $(element).find('label');
var span_e = $(element).find('span');
input_e.attr('id', 'beeper-' + i);
input_e.attr('name', self._beepers[i].name);
input_e.attr('title', self._beepers[i].name);
input_e.prop('checked', bit_check(self._beeperMask, self._beepers[i].bit) == 0);
input_e.data('bit', self._beepers[i].bit);
label_e.attr('for', 'beeper-' + i);
label_e.text(self._beepers[i].name);
span_e.attr('i18n', 'beeper' + self._beepers[i].name);
element.show();
}
}
};
Beepers.prototype.updateData = function (beeperElement) {
var self = this;
if (beeperElement.attr('type') === 'checkbox') {
var bit = beeperElement.data('bit');
if (beeperElement.is(':checked')) {
self._beeperMask = bit_clear(self._beeperMask, bit);
} else {
self._beeperMask = bit_set(self._beeperMask, bit);
}
}
};

View File

@ -3,6 +3,7 @@
// define all the global variables that are uses to hold FC state // define all the global variables that are uses to hold FC state
var CONFIG; var CONFIG;
var FEATURE_CONFIG; var FEATURE_CONFIG;
var BEEPER_CONFIG;
var MIXER_CONFIG; var MIXER_CONFIG;
var BOARD_ALIGNMENT_CONFIG; var BOARD_ALIGNMENT_CONFIG;
var LED_STRIP; var LED_STRIP;
@ -82,6 +83,10 @@ var FC = {
features: 0, features: 0,
}; };
BEEPER_CONFIG = {
beepers: 0,
};
MIXER_CONFIG = { MIXER_CONFIG = {
mixer: 0, mixer: 0,
}; };

View File

@ -76,9 +76,9 @@ var MSPCodes = {
MSP_SET_PID_ADVANCED: 95, MSP_SET_PID_ADVANCED: 95,
MSP_SENSOR_CONFIG: 96, MSP_SENSOR_CONFIG: 96,
MSP_SET_SENSOR_CONFIG: 97, MSP_SET_SENSOR_CONFIG: 97,
//MSP_SPECIAL_PARAMETERS: 98, // DEPRECATED MSP_CAMERA_CONTROL: 98,
//MSP_SET_SPECIAL_PARAMETERS: 99, // DEPRECATED MSP_BEEPER_CONFIG: 99,
//MSP_IDENT: 100, // DEPRECTED MSP_SET_BEEPER_CONFIG: 100,
MSP_STATUS: 101, MSP_STATUS: 101,
MSP_RAW_IMU: 102, MSP_RAW_IMU: 102,
MSP_SERVO: 103, MSP_SERVO: 103,

View File

@ -492,6 +492,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_FEATURE_CONFIG: case MSPCodes.MSP_SET_FEATURE_CONFIG:
console.log('Features saved'); console.log('Features saved');
break; break;
case MSPCodes.MSP_SET_BEEPER_CONFIG:
console.log('Beeper Configuration saved');
break;
case MSPCodes.MSP_RESET_CONF: case MSPCodes.MSP_RESET_CONF:
console.log('Settings Reset'); console.log('Settings Reset');
break; break;
@ -562,6 +565,10 @@ MspHelper.prototype.process_data = function(dataHandler) {
updateTabList(FEATURE_CONFIG.features); updateTabList(FEATURE_CONFIG.features);
break; break;
case MSPCodes.MSP_BEEPER_CONFIG:
BEEPER_CONFIG.beepers.setMask(data.readU32());
break;
case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG: case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG:
BOARD_ALIGNMENT_CONFIG.roll = data.read16(); // -180 - 360 BOARD_ALIGNMENT_CONFIG.roll = data.read16(); // -180 - 360
BOARD_ALIGNMENT_CONFIG.pitch = data.read16(); // -180 - 360 BOARD_ALIGNMENT_CONFIG.pitch = data.read16(); // -180 - 360
@ -1147,7 +1154,11 @@ MspHelper.prototype.crunch = function(code) {
var featureMask = FEATURE_CONFIG.features.getMask(); var featureMask = FEATURE_CONFIG.features.getMask();
buffer.push32(featureMask); buffer.push32(featureMask);
break; break;
case MSPCodes.MSP_SET_MIXER_CONFIG: case MSPCodes.MSP_SET_BEEPER_CONFIG:
var beeperMask = BEEPER_CONFIG.beepers.getMask();
buffer.push32(beeperMask);
break;
case MSPCodes.MSP_SET_MIXER_CONFIG:
buffer.push8(MIXER_CONFIG.mixer) buffer.push8(MIXER_CONFIG.mixer)
break; break;
case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG: case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG:

View File

@ -301,6 +301,7 @@ function onConnect() {
if (CONFIG.flightControllerVersion !== '') { if (CONFIG.flightControllerVersion !== '') {
FEATURE_CONFIG.features = new Features(CONFIG); FEATURE_CONFIG.features = new Features(CONFIG);
BEEPER_CONFIG.beepers = new Beepers(CONFIG);
$('#tabs ul.mode-connected').show(); $('#tabs ul.mode-connected').show();

View File

@ -69,6 +69,7 @@
<script type="text/javascript" src="./js/boards.js"></script> <script type="text/javascript" src="./js/boards.js"></script>
<script type="text/javascript" src="./js/RateCurve.js"></script> <script type="text/javascript" src="./js/RateCurve.js"></script>
<script type="text/javascript" src="./js/Features.js"></script> <script type="text/javascript" src="./js/Features.js"></script>
<script type="text/javascript" src="./js/Beepers.js"></script>
<script type="text/javascript" src="./main.js"></script> <script type="text/javascript" src="./main.js"></script>
<script type="text/javascript" src="./tabs/landing.js"></script> <script type="text/javascript" src="./tabs/landing.js"></script>
<script type="text/javascript" src="./tabs/setup.js"></script> <script type="text/javascript" src="./tabs/setup.js"></script>

View File

@ -380,6 +380,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="rightWrapper rssi"> <div class="rightWrapper rssi">
<div class="gui_box grey" style="margin-bottom:10px;"> <div class="gui_box grey" style="margin-bottom:10px;">
<div class="gui_box_titlebar"> <div class="gui_box_titlebar">
@ -430,54 +431,82 @@
</div> </div>
</div> </div>
<div class="line"> <div class="line">
<select class="gps_protocol"> <select class="gps_protocol">
<!-- list generated here --> <!-- list generated here -->
</select> </select>
<span i18n="configurationGPSProtocol"></span> <span i18n="configurationGPSProtocol"></span>
</div>
<div class="line">
<select class="gps_baudrate">
<!-- list generated here -->
</select>
<span i18n="configurationGPSBaudrate"></span>
</div>
<div class="select gps_auto_baud">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="gps_auto_baud" class="toggle" />
</div> </div>
<label for="gps_auto_baud"> <span class="freelabel" <div class="line">
i18n="configurationGPSAutoBaud"></span> <select class="gps_baudrate">
</label>
</div>
<div class="select gps_auto_config">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="gps_auto_config" class="toggle" />
</div>
<label for="gps_auto_config"> <span class="freelabel"
i18n="configurationGPSAutoConfig"></span>
</label>
</div>
<div class="line">
<select class="gps_ubx_sbas">
<!-- list generated here --> <!-- list generated here -->
</select> </select>
<span i18n="configurationGPSubxSbas"></span> <span i18n="configurationGPSBaudrate"></span>
</div> </div>
<div class="number"> <div class="select gps_auto_baud">
<label> <input type="number" name="mag_declination" step="0.01" min="-180" max="180" /> <div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<span i18n="configurationMagDeclination"></span> <input type="checkbox" name="gps_auto_baud" class="toggle" />
</label> </div>
<label for="gps_auto_baud"> <span class="freelabel"
i18n="configurationGPSAutoBaud"></span>
</label>
</div>
<div class="select gps_auto_config">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="gps_auto_config" class="toggle" />
</div>
<label for="gps_auto_config"> <span class="freelabel"
i18n="configurationGPSAutoConfig"></span>
</label>
</div>
<div class="line">
<select class="gps_ubx_sbas">
<!-- list generated here -->
</select>
<span i18n="configurationGPSubxSbas"></span>
</div>
<div class="number">
<label> <input type="number" name="mag_declination" step="0.01" min="-180" max="180" />
<span i18n="configurationMagDeclination"></span>
</label>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="clear-both"></div>
</div>
<div class="leftWrapper beepers" style="width: calc(100% - 20px);">
<div class="gui_box grey" style="margin-top:10px;">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationBeeper"></div>
</div>
<div class="spacer_box">
<table cellpadding="0" cellspacing="0">
<tbody class="beeper-configuration" id="noline">
<tr class="beeper-template" style="display:none">
<td>
<input class="beeper toggle" id="" name="" title="" type="checkbox" />
</td>
<td>
<label for=""></label>
</td>
<td>
<span i18n=""></span>
</td>
</tr>
<!-- table generated here -->
</tbody>
</table>
</div>
</div>
</div> </div>
<div class="clear-both"></div> <div class="clear-both"></div>
</div> <div class="content_toolbar">
<div class="content_toolbar"> <div class="btn save_btn">
<div class="btn save_btn"> <a class="save" href="#" i18n="configurationButtonSave"></a>
<a class="save" href="#" i18n="configurationButtonSave"></a> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,7 +12,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function load_config() { function load_config() {
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_serial_config); MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_beeper_config);
}
function load_beeper_config() {
MSP.send_message(MSPCodes.MSP_BEEPER_CONFIG, false, false, load_serial_config);
} }
function load_serial_config() { function load_serial_config() {
@ -178,6 +182,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
FEATURE_CONFIG.features.generateElements(features_e); FEATURE_CONFIG.features.generateElements(features_e);
// Beeper
var template = $('.beepers .beeper-template');
var destination = $('.beepers .beeper-configuration');
var beeper_e = $('.tab-configuration .beepers');
BEEPER_CONFIG.beepers.generateElements(template, destination);
// translate to user-selected language // translate to user-selected language
localize(); localize();
@ -602,6 +613,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
}); });
$('input.beeper', beeper_e).change(function () {
var element = $(this);
BEEPER_CONFIG.beepers.updateData(element);
});
checkShowDisarmDelay(); checkShowDisarmDelay();
checkShowSerialRxBox(); checkShowSerialRxBox();
checkUpdateGpsControls(); checkUpdateGpsControls();
@ -665,10 +681,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function save_feature_config() { function save_feature_config() {
var next_callback = save_misc; var next_callback = save_beeper_config;
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, next_callback); MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, next_callback);
} }
function save_beeper_config() {
MSP.send_message(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG), false, save_misc);
}
function save_misc() { function save_misc() {
var next_callback = save_mixer_config; var next_callback = save_mixer_config;
if(semver.lt(CONFIG.apiVersion, "1.33.0")) { if(semver.lt(CONFIG.apiVersion, "1.33.0")) {