diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3d867b2d..19f3063c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -694,6 +694,66 @@ "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)." }, + "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": { "message": "3D ESC/Motor Features" }, @@ -1726,43 +1786,6 @@ "ledStripIndecatorOverlay": { "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": { "message": "Roll" }, diff --git a/js/Beepers.js b/js/Beepers.js new file mode 100644 index 00000000..7d41a188 --- /dev/null +++ b/js/Beepers.js @@ -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); + } + } +}; \ No newline at end of file diff --git a/js/fc.js b/js/fc.js index d4e2e00e..1e0b069f 100644 --- a/js/fc.js +++ b/js/fc.js @@ -3,6 +3,7 @@ // define all the global variables that are uses to hold FC state var CONFIG; var FEATURE_CONFIG; +var BEEPER_CONFIG; var MIXER_CONFIG; var BOARD_ALIGNMENT_CONFIG; var LED_STRIP; @@ -82,6 +83,10 @@ var FC = { features: 0, }; + BEEPER_CONFIG = { + beepers: 0, + }; + MIXER_CONFIG = { mixer: 0, reverseMotorDir: 0, diff --git a/js/msp/MSPCodes.js b/js/msp/MSPCodes.js index 89b49a16..cb8101ca 100644 --- a/js/msp/MSPCodes.js +++ b/js/msp/MSPCodes.js @@ -76,9 +76,8 @@ var MSPCodes = { MSP_SET_PID_ADVANCED: 95, MSP_SENSOR_CONFIG: 96, MSP_SET_SENSOR_CONFIG: 97, - //MSP_SPECIAL_PARAMETERS: 98, // DEPRECATED - //MSP_SET_SPECIAL_PARAMETERS: 99, // DEPRECATED - //MSP_IDENT: 100, // DEPRECTED + MSP_CAMERA_CONTROL: 98, + MSP_STATUS: 101, MSP_RAW_IMU: 102, MSP_SERVO: 103, @@ -117,6 +116,9 @@ var MSPCodes = { MSP_DISPLAYPORT: 182, + MSP_BEEPER_CONFIG: 184, + MSP_SET_BEEPER_CONFIG: 185, + MSP_SET_RAW_RC: 200, MSP_SET_RAW_GPS: 201, // Not used MSP_SET_PID: 202, diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index a7ca2be4..83aade7d 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -492,6 +492,9 @@ MspHelper.prototype.process_data = function(dataHandler) { case MSPCodes.MSP_SET_FEATURE_CONFIG: console.log('Features saved'); break; + case MSPCodes.MSP_SET_BEEPER_CONFIG: + console.log('Beeper Configuration saved'); + break; case MSPCodes.MSP_RESET_CONF: console.log('Settings Reset'); break; @@ -563,6 +566,10 @@ MspHelper.prototype.process_data = function(dataHandler) { updateTabList(FEATURE_CONFIG.features); break; + case MSPCodes.MSP_BEEPER_CONFIG: + BEEPER_CONFIG.beepers.setMask(data.readU32()); + break; + case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG: BOARD_ALIGNMENT_CONFIG.roll = data.read16(); // -180 - 360 BOARD_ALIGNMENT_CONFIG.pitch = data.read16(); // -180 - 360 @@ -1148,7 +1155,11 @@ MspHelper.prototype.crunch = function(code) { var featureMask = FEATURE_CONFIG.features.getMask(); buffer.push32(featureMask); 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) .push8(MIXER_CONFIG.reverseMotorDir); break; diff --git a/js/serial_backend.js b/js/serial_backend.js index 420115fd..a6dcac9f 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -301,6 +301,7 @@ function onConnect() { if (CONFIG.flightControllerVersion !== '') { FEATURE_CONFIG.features = new Features(CONFIG); + BEEPER_CONFIG.beepers = new Beepers(CONFIG); $('#tabs ul.mode-connected').show(); diff --git a/main.html b/main.html index f941f6db..7a7b05a5 100755 --- a/main.html +++ b/main.html @@ -69,6 +69,7 @@ + diff --git a/tabs/configuration.html b/tabs/configuration.html index 973ca717..6ebf908c 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -392,6 +392,7 @@ +
@@ -442,54 +443,82 @@
-
- - -
-
- - -
-
-
- +
+ +
- -
-
-
- -
- -
-
- - - -
-
- + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+
+ + + + + + + + + +
+
+
- -
-
- +
+
+ +
-
+ \ No newline at end of file diff --git a/tabs/configuration.js b/tabs/configuration.js index ffa48502..e889677f 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -12,7 +12,16 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } 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() { + var next_callback = load_serial_config; + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + MSP.send_message(MSPCodes.MSP_BEEPER_CONFIG, false, false, next_callback); + } else { + next_callback(); + } } function load_serial_config() { @@ -190,6 +199,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) { FEATURE_CONFIG.features.generateElements(features_e); + // Beeper + var template = $('.beepers .beeper-template'); + var destination = $('.beepers .beeper-configuration'); + var beeper_e = $('.tab-configuration .beepers'); + + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + BEEPER_CONFIG.beepers.generateElements(template, destination); + } else { + beeper_e.hide(); + } + // translate to user-selected language localize(); @@ -614,6 +634,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } }); + $('input.beeper', beeper_e).change(function () { + var element = $(this); + BEEPER_CONFIG.beepers.updateData(element); + }); + checkShowDisarmDelay(); checkShowSerialRxBox(); checkUpdateGpsControls(); @@ -677,10 +702,19 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } 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); } + function save_beeper_config() { + var next_callback = save_misc; + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + MSP.send_message(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG), false, next_callback); + } else { + next_callback(); + } + } + function save_misc() { var next_callback = save_mixer_config; if(semver.lt(CONFIG.apiVersion, "1.33.0")) {