Permalink
Browse files

Allow FC loop time change via Configuration Tab

  • Loading branch information...
1 parent 774fcf5 commit 17d525352fd17eda67860d2fdc554b0381bb20f8 @tricopterY tricopterY committed May 26, 2015
Showing with 63 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 _locales/en/messages.json
  3. +1 −0 changelog.html
  4. +21 −1 tabs/configuration.css
  5. +8 −1 tabs/configuration.html
  6. +29 −3 tabs/configuration.js
View
@@ -1,2 +1,3 @@
.DS_store
+nbproject/
@@ -499,6 +499,9 @@
"configurationBatteryMultiwiiCurrent": {
"message": "Enable support for legacy Multiwii MSP current output"
},
+ "configurationLoopTimeHead": {
+ "message": "Flight Controller Loop Time"
+ },
"configurationGPS": {
"message": "GPS"
},
View
@@ -1,5 +1,6 @@
<span>2015.05.23 - 0.65.0 - cleanflight</span>
<p>
+ - Configuration tab supports setting FC loop time - Requires 1.8.0 firmware.<br />
- Support flashing of the SPRacingF3.<br />
- Support manual baud rate configuration for flashing.<br />
</p>
@@ -154,7 +154,27 @@
.tab-configuration .disarm .checkbox span {
margin-left: 15px;
}
-
+.tab-configuration .cycles {
+ border-bottom: 1px solid #dddddd;
+ margin-top: 16px;
+}
+.tab-configuration .block {
+ float: left;
+ display: block;
+ border: 1px solid silver;
+}
+.tab-configuration .block .head {
+ display: block;
+ text-align: center;
+ line-height: 20px;
+ font-weight: bold;
+ border-bottom: 1px solid silver;
+ background-color: #ececec;
+}
+.tab-configuration .block.looptime {
+ width: 200px;
+ margin-top: 11px;
+}
.tab-configuration .save {
display: block;
float: right;
@@ -233,7 +233,14 @@
</div>
<span i18n="configurationBatteryMultiwiiCurrent"></span>
</label>
- </div>
+ </div>
+ <div class="cycles" style="display: none;">
+ <div class="block looptime">
+ <span class="head" i18n="configurationLoopTimeHead"></span>
+ <input type="number" name="looptime" step="100" min="0" max="9000"/>
+ <span class="looptimehz"></span>
+ </div>
+ </div>
</div>
<div class="clear-both"></div>
<div class="leftWrapper gps">
View
@@ -36,7 +36,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_arming_config() {
- MSP.send_message(MSP_codes.MSP_ARMING_CONFIG, false, false, load_html);
+ MSP.send_message(MSP_codes.MSP_ARMING_CONFIG, false, false, load_loop_time);
+ }
+
+ function load_loop_time() {
+ MSP.send_message(MSP_codes.MSP_LOOP_TIME, false, false, load_html);
}
function load_html() {
@@ -256,7 +260,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
// fill magnetometer
$('input[name="mag_declination"]').val(MISC.mag_declination);
- //fill motor disarm params
+ //fill motor disarm params and FC loop time
if(semver.gte(CONFIG.apiVersion, "1.8.0")) {
$('input[name="autodisarmdelay"]').val(ARMING_CONFIG.auto_disarm_delay);
$('input[name="disarmkillswitch"]').prop('checked', ARMING_CONFIG.disarm_kill_switch);
@@ -265,6 +269,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('div.disarmdelay').show();
else
$('div.disarmdelay').hide();
+
+ // fill FC loop time
+ $('input[name="looptime"]').val(FC_CONFIG.loopTime);
+ if(FC_CONFIG.loopTime > 0)
+ $('span.looptimehz').text(parseFloat((1/FC_CONFIG.loopTime)*1000*1000).toFixed(0) + ' Cycles per Sec');
+ else
+ $('span.looptimehz').text('Maximum Cycles per Sec');
+
+ $('div.cycles').show();
}
// fill throttle
@@ -287,6 +300,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
// UI hooks
+ $('input[name="looptime"]').change(function() {
+ FC_CONFIG.loopTime = parseInt($('input[name="looptime"]').val());
+ if(FC_CONFIG.loopTime > 0)
+ $('span.looptimehz').text(parseFloat((1/FC_CONFIG.loopTime)*1000*1000).toFixed(0) + ' Cycles per Sec');
+ else
+ $('span.looptimehz').text('Maximum Cycles per Sec');
+ });
+
$('input[type="checkbox"].feature', features_e).change(function () {
var element = $(this),
index = element.data('bit'),
@@ -338,6 +359,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
if(semver.gte(CONFIG.apiVersion, "1.8.0")) {
ARMING_CONFIG.auto_disarm_delay = parseInt($('input[name="autodisarmdelay"]').val());
ARMING_CONFIG.disarm_kill_switch = ~~$('input[name="disarmkillswitch"]').is(':checked'); // ~~ boolean to decimal conversion
+ FC_CONFIG.loopTime = parseInt($('input[name="looptime"]').val());
}
MISC.minthrottle = parseInt($('input[name="minthrottle"]').val());
@@ -373,7 +395,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_arming_config() {
- MSP.send_message(MSP_codes.MSP_SET_ARMING_CONFIG, MSP.crunch(MSP_codes.MSP_SET_ARMING_CONFIG), false, save_to_eeprom);
+ MSP.send_message(MSP_codes.MSP_SET_ARMING_CONFIG, MSP.crunch(MSP_codes.MSP_SET_ARMING_CONFIG), false, save_looptime_config);
+ }
+
+ function save_looptime_config() {
+ MSP.send_message(MSP_codes.MSP_SET_LOOP_TIME, MSP.crunch(MSP_codes.MSP_SET_LOOP_TIME), false, save_to_eeprom);
}
function save_to_eeprom() {

0 comments on commit 17d5253

Please sign in to comment.