From 17d525352fd17eda67860d2fdc554b0381bb20f8 Mon Sep 17 00:00:00 2001 From: tricopterY Date: Tue, 26 May 2015 16:28:58 +1000 Subject: [PATCH] Allow FC loop time change via Configuration Tab --- .gitignore | 1 + _locales/en/messages.json | 3 +++ changelog.html | 1 + tabs/configuration.css | 22 +++++++++++++++++++++- tabs/configuration.html | 9 ++++++++- tabs/configuration.js | 32 +++++++++++++++++++++++++++++--- 6 files changed, 63 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index d04edac2..bfcb31dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_store +nbproject/ diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 962b09ad..ba2925ac 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -499,6 +499,9 @@ "configurationBatteryMultiwiiCurrent": { "message": "Enable support for legacy Multiwii MSP current output" }, + "configurationLoopTimeHead": { + "message": "Flight Controller Loop Time" + }, "configurationGPS": { "message": "GPS" }, diff --git a/changelog.html b/changelog.html index ea2cc733..52af57e2 100644 --- a/changelog.html +++ b/changelog.html @@ -1,5 +1,6 @@ 2015.05.23 - 0.65.0 - cleanflight

+ - Configuration tab supports setting FC loop time - Requires 1.8.0 firmware.
- Support flashing of the SPRacingF3.
- Support manual baud rate configuration for flashing.

diff --git a/tabs/configuration.css b/tabs/configuration.css index f32be360..2d8c7434 100644 --- a/tabs/configuration.css +++ b/tabs/configuration.css @@ -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; diff --git a/tabs/configuration.html b/tabs/configuration.html index 6dfde182..c049a4a7 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -233,7 +233,14 @@ - + +
diff --git a/tabs/configuration.js b/tabs/configuration.js index 962f5120..b1ae7d86 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -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() {