From bfa689be407bcfc77a9fd5b946a1b6bbd69395bb Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sun, 4 Jan 2015 08:09:10 +0000 Subject: [PATCH] Overhaul of the configuration tab. --- _locales/en/messages.json | 28 +++--- tabs/configuration.css | 21 +++-- tabs/configuration.html | 175 +++++++++++++++++++++++++++++--------- tabs/configuration.js | 113 +++++++++++++++++------- 4 files changed, 242 insertions(+), 95 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 2145f7ba97..bbfe3ce388 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -331,7 +331,7 @@ "message": "Enabled" }, "configurationFeatureName": { - "message": "Name" + "message": "Feature" }, "configurationFeatureDescription": { "message": "Description" @@ -342,10 +342,19 @@ "message": "Mixer" }, "configurationFeatures": { - "message": "Features" + "message": "Other Features" + }, + "configurationReceiver": { + "message": "Receiver Mode" + }, + "configurationRSSI": { + "message": "RSSI (Signal Strength)" + }, + "configurationEscFeatures": { + "message": "ESC/Motor Features" }, "configurationFeaturesHelp": { - "message": "Note: that not all combinations of features are valid. When the flight controller firmware detects this conflicting features will be disabled.
Note: Configure serial ports before enabling the features that will use the ports." + "message": "Note: Not all combinations of features are valid. When the flight controller firmware detects invalid feature combinations conflicting features will be disabled.
Note: Configure serial ports before enabling the features that will use the ports." }, "configurationBoardAlignment": { @@ -360,8 +369,8 @@ "configurationBoardAlignmentYaw": { "message": "Yaw Adjustment [deg]" }, - "configurationAccelTrimMagDec": { - "message": "Accelerometer & Magnetometer" + "configurationAccelTrims": { + "message": "Accelerometer Trim" }, "configurationAccelTrimRoll": { "message": "Accelerometer Roll Trim" @@ -372,9 +381,6 @@ "configurationMagDeclination": { "message": "Magnetometer Declination [deg]" }, - "configurationThrottle": { - "message": "Throttle" - }, "configurationThrottleMinimum": { "message": "Minimum Throttle" }, @@ -420,8 +426,8 @@ "configurationGPS": { "message": "GPS" }, - "configurationGPStype": { - "message": "Type" + "configurationGPSProtocol": { + "message": "Protocol" }, "configurationGPSbaudrate": { "message": "Baudrate" @@ -430,7 +436,7 @@ "message": "Ground Assistance Type" }, "configurationSerialRX": { - "message": "Serial Receiver" + "message": "Serial Receiver Provider" }, "configurationEepromSaved": { "message": "EEPROM saved" diff --git a/tabs/configuration.css b/tabs/configuration.css index 2ed748ff88..63f15a2e50 100644 --- a/tabs/configuration.css +++ b/tabs/configuration.css @@ -1,10 +1,11 @@ .tab-configuration .help { - float: left; + padding: 10px; + background-color: #ffcb18; + margin-bottom: 10px; } -.tab-configuration table { - float: left; +.tab-configuration table { margin-bottom: 10px; border-collapse: collapse; @@ -57,17 +58,13 @@ .tab-configuration .mixerPreview img { display: block; - width: calc(100% - 10px); - height: calc(100% - 10px); - - padding: 5px; - - border: 1px solid silver; - border-bottom: 0; + width: 100%; + height: 100%; } .tab-configuration select.mixerList { - width: calc(100% + 2px); + width: 180px; height: 20px; + margin-top: 10px; font-weight: bold; @@ -91,6 +88,7 @@ } .tab-configuration .number { margin-bottom: 5px; + clear: left; } .tab-configuration .number input { width: 60px; @@ -125,6 +123,7 @@ width: 125px; border: 1px solid silver; + margin-bottom: 5px; } .tab-configuration .current .checkbox { margin-top: 2px; diff --git a/tabs/configuration.html b/tabs/configuration.html index 33d19f83bb..22f2e80052 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -1,15 +1,19 @@
+
+

+
+
-
+
-
-
+
+
@@ -18,17 +22,10 @@ - +
-
-

-
-
-
-
-
+
+
+
+
+ +
+
+ +
+
+ +
+
-
+
-
- -
+
+ + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + +
+
+ + + + + + + + + + + +
+
+ + + + + + + + + + + +
+
- - +
@@ -108,10 +176,29 @@
+
+ +
+ + + + + + + + + + + +
+
+ + + + + + + + + + + +
-
-
- -
-
- -
-
- -
+
+ + + + + + + + + + + +
diff --git a/tabs/configuration.js b/tabs/configuration.js index 1931fac9bd..0b3ded018b 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -53,38 +53,66 @@ TABS.configuration.initialize = function (callback, scrollPosition) { mixer_list_e.val(BF_CONFIG.mixerConfiguration).change(); // generate features - var featureNames = [ - {name: 'RX_PPM', description: 'PPM RX input'}, - {name: 'VBAT', description: 'Battery voltage monitoring'}, - {name: 'INFLIGHT_ACC_CAL', description: 'In-flight level calibration'}, - {name: 'RX_SERIAL', description: 'Serial-based receiver (SPEKSAT, SBUS, SUMD)'}, - {name: 'MOTOR_STOP', description: 'Don\'t spin the motors when armed'}, - {name: 'SERVO_TILT', description: 'Servo gimbal'}, - {name: 'SOFTSERIAL', description: 'Enable CPU based serial ports (configure port scenario first)'}, - {name: 'GPS', description: 'GPS (configure port scenario first)'}, - {name: 'FAILSAFE', description: 'Failsafe settings on RX signal loss'}, - {name: 'SONAR', description: 'Sonar'}, - {name: 'TELEMETRY', description: 'Telemetry output'}, - {name: 'CURRENT_METER', description: 'Battery current monitoring'}, - {name: '3D', description: '3D mode (for use with reversible ESCs)'}, - {name: 'RX_PARALLEL_PWM', description: 'PWM RX input'}, - {name: 'RX_MSP', description: 'MSP RX input'}, - {name: 'RSSI_ADC', description: 'Analog RSSI input'}, - {name: 'LED_STRIP', description: 'Addressable RGB LED strip support'}, - {name: 'DISPLAY', description: 'OLED Screen Display'}, - {name: 'ONESHOT125', description: 'ONESHOT ESC support (disconnect ESCs, remove props)'} + var features = [ + {bit: 0, group: 'rxMode', mode: 'group', name: 'RX_PPM', description: 'PPM RX input'}, + {bit: 1, group: 'batteryVoltage', name: 'VBAT', description: 'Battery voltage monitoring'}, + {bit: 2, group: 'other', name: 'INFLIGHT_ACC_CAL', description: 'In-flight level calibration'}, + {bit: 3, group: 'rxMode', mode: 'group', name: 'RX_SERIAL', description: 'Serial-based receiver (SPEKSAT, SBUS, SUMD)'}, + {bit: 4, group: 'esc', name: 'MOTOR_STOP', description: 'Don\'t spin the motors when armed'}, + {bit: 5, group: 'other', name: 'SERVO_TILT', description: 'Servo gimbal'}, + {bit: 6, group: 'other', name: 'SOFTSERIAL', description: 'Enable CPU based serial ports (configure port scenario first)'}, + {bit: 7, group: 'gps', name: 'GPS', description: 'GPS (configure port scenario first)'}, + {bit: 8, group: 'rxFailsafe', name: 'FAILSAFE', description: 'Failsafe settings on RX signal loss'}, + {bit: 9, group: 'other', name: 'SONAR', description: 'Sonar'}, + {bit: 10, group: 'other', name: 'TELEMETRY', description: 'Telemetry output'}, + {bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER', description: 'Battery current monitoring'}, + {bit: 12, group: 'other', name: '3D', description: '3D mode (for use with reversible ESCs)'}, + {bit: 13, group: 'rxMode', mode: 'group', name: 'RX_PARALLEL_PWM', description: 'PWM RX input'}, + {bit: 14, group: 'rxMode', mode: 'group', name: 'RX_MSP', description: 'MSP RX input'}, + {bit: 15, group: 'rssi', name: 'RSSI_ADC', description: 'Analog RSSI input'}, + {bit: 16, group: 'other', name: 'LED_STRIP', description: 'Addressable RGB LED strip support'}, + {bit: 17, group: 'other', name: 'DISPLAY', description: 'OLED Screen Display'}, + {bit: 18, group: 'esc', name: 'ONESHOT125', description: 'ONESHOT ESC support (disconnect ESCs, remove props)'} ]; + var radioGroups = []; + var features_e = $('.features'); - for (var i = 0; i < featureNames.length; i++) { - var row_e = $('' + featureNames[i].description + ''); - row_e.find('input').attr('checked', bit_check(BF_CONFIG.features, i)); + for (var i = 0; i < features.length; i++) { + var row_e; + + if (features[i].mode == 'group') { + row_e = $('' + features[i].description + ''); + radioGroups.push(features[i].group); + } else { + row_e = $('' + features[i].description + ''); + var feature_e = row_e.find('input.feature'); + feature_e.data('bit', features[i].bit); + feature_e.prop('checked', bit_check(BF_CONFIG.features, features[i].bit)); + } - features_e.append(row_e); + features_e.each(function () { + if ($(this).hasClass(features[i].group)) { + $(this).append(row_e); + } + }); + } + + for (var i = 0; i < radioGroups.length; i++) { + var group = radioGroups[i]; + var controls_e = $('input[name="' + group + '"].feature'); + + + controls_e.each(function() { + var bit = parseInt($(this).attr('value')); + var state = bit_check(BF_CONFIG.features, bit); + + $(this).prop('checked', state); + }); } // generate GPS - var gpsTypes = [ + var gpsProtocols = [ 'NMEA', 'UBLOX' ]; @@ -108,12 +136,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) { 'Indian GAGAN' ]; - var gps_type_e = $('select.gps_type'); - for (var i = 0; i < gpsTypes.length; i++) { - gps_type_e.append(''); + var gps_protocol_e = $('select.gps_protocol'); + for (var i = 0; i < gpsProtocols.length; i++) { + gps_protocol_e.append(''); } - gps_type_e.change(function () { + gps_protocol_e.change(function () { MISC.gps_type = parseInt($(this).val()); }); @@ -138,7 +166,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { }); // select current gps configuration - gps_type_e.val(MISC.gps_type); + gps_protocol_e.val(MISC.gps_type); //gps_baudrate_e.val(MISC.gps_baudrate); gps_ubx_sbas_e.val(MISC.gps_ubx_sbas); @@ -201,9 +229,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) { // UI hooks - $('input', features_e).change(function () { + $('input[type="checkbox"].feature', features_e).change(function () { var element = $(this), - index = $('input', features_e).index(element), + index = element.data('bit'), state = element.is(':checked'); if (state) { @@ -213,6 +241,27 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } }); + // UI hooks + $('input[type="radio"].feature', features_e).change(function () { + var element = $(this), + group = element.attr('name'); + + var controls_e = $('input[name="' + group + '"]'); + var selected_bit = controls_e.filter(':checked').val(); + + controls_e.each(function() { + var bit = $(this).attr('value'); + + var selected = (selected_bit == bit); + if (selected) { + BF_CONFIG.features = bit_set(BF_CONFIG.features, bit); + } else { + BF_CONFIG.features = bit_clear(BF_CONFIG.features, bit); + } + + }); + }); + $('a.save').click(function () { // gather data that doesn't have automatic change event bound BF_CONFIG.board_align_roll = parseInt($('input[name="board_align_roll"]').val());