diff --git a/README.md b/README.md index 596d94d7..1bf8efa1 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ sudo mv inav-configurator.desktop /usr/share/applications/ ``` 10. Make the following files executable: * inav-configurator `chmod +x /opt/inav/inav-configurator/inav-configurator` - * (5.0.0+) chrome_crashpad_handler `chmod +x /opt/inav/inav-configurator/chrome_crashpad_handler` 11. Run the INAV Configurator app from the unpacked folder `/opt/inav/inav-configurator/inav-configurator` ### Mac @@ -83,7 +82,7 @@ For local development, the **node.js** build system is used. 1. Install node.js 1. From the project folder run `npm install` -1. To build the JS and CSS files and start the configurator: +1. To build the and start the configurator: - Run `npm start`. To build the App run `npm run make` to build for your platform. @@ -94,7 +93,7 @@ Options: See [Electron Forge CLI Documentation](https://www.electronforge.io/cli#options-2) for details Example (note the double -- ): -``` npm start -- --arch="ia32 ``` +``` npm run make -- --arch="x64" ``` ### Running with debug | Inspector diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index e2ceb25e..00000000 --- a/gulpfile.js +++ /dev/null @@ -1,756 +0,0 @@ -'use strict'; - -var child_process = require('child_process'); -var fs = require('fs'); -var path = require('path'); -var minimist = require('minimist'); - -var archiver = require('archiver'); -var del = require('del'); -var NwBuilder = require('nw-builder'); -var semver = require('semver'); - -var gulp = require('gulp'); -var concat = require('gulp-concat'); - -const commandExistsSync = require('command-exists').sync; - -// Each key in the *sources* variable must be an array of -// the source files that will be combined into a single -// file and stored in *outputDir*. Each key in *sources* -// must be also present in *output*, whose value indicates -// the filename for the output file which combines the -// contents of the source files. -// -// Keys must be camel cased and end with either 'Css' or -// 'Js' (e.g. someSourcesCss or someSourcesJs). For each -// key, a build task will be generated named by prepending -// 'build-' and converting the key to dash-separated words -// (e.g. someSourcesCss will generate build-some-sources-css). -// -// Tasks with names ending with '-js' will be executed by the -// build-all-js task, while the ones ending with '-css' will -// be done by build-all-css. There's also a build task which -// runs both build-all-css and build-all-js. -// -// The watch task will monitor any files mentioned in the *sources* -// variable and regenerate the corresponding output file when -// they change. -// -// See README.md for details on the other tasks. - -var sources = {}; - -sources.css = [ - './main.css', - './js/libraries/jquery.nouislider.min.css', - './js/libraries/jquery.nouislider.pips.min.css', - './js/libraries/flightindicators.css', - './src/css/tabs/*.css', - './src/css/opensans_webfontkit/fonts.css', - './src/css/font-awesome/css/font-awesome.css', - './src/css/dropdown-lists/css/style_lists.css', - './js/libraries/switchery/switchery.css', - './js/libraries/jbox/jBox.css', - './node_modules/openlayers/dist/ol.css', - './src/css/logic.css', - './src/css/defaults_dialog.css', - './src/css/groundstation.css', -]; - -sources.js = [ - './js/libraries/google-analytics-bundle.js', - './node_modules/jquery/dist/jquery.min.js', - './node_modules/jquery-ui-npm/jquery-ui.min.js', - './node_modules/marked/lib/marked.js', - './js/libraries/d3.min.js', - './js/libraries/jquery.nouislider.all.min.js', - './node_modules/three/build/three.min.js', - './node_modules/three/examples/js/loaders/GLTFLoader.js', - './node_modules/three/examples/js/controls/OrbitControls.js', - './js/libraries/nw-dialog.js', - './js/libraries/bundle_xml2js.js', - './js/libraries/Projector.js', - './js/libraries/CanvasRenderer.js', - './js/libraries/jquery.flightindicators.js', - './js/libraries/semver.js', - './js/libraries/jbox/jBox.min.js', - './js/libraries/switchery/switchery.js', - './js/libraries/jquery.ba-throttle-debounce.js', - './js/helpers.js', - './node_modules/inflection/inflection.min.js', - './node_modules/bluebird/js/browser/bluebird.min.js', - './js/injected_methods.js', - './js/intervals.js', - './js/timeouts.js', - './js/pid_controller.js', - './js/simple_smooth_filter.js', - './js/walking_average_filter.js', - './js/gui.js', - './js/serialPortHelper.js', - './js/msp/MSPCodes.js', - './js/msp/MSPHelper.js', - './js/msp/MSPchainer.js', - './js/port_handler.js', - './js/connection/connection.js', - './js/connection/connectionBle.js', - './js/connection/connectionSerial.js', - './js/connection/connectionTcp.js', - './js/connection/connectionUdp.js', - './js/servoMixRule.js', - './js/motorMixRule.js', - './js/logicCondition.js', - './js/settings.js', - './js/outputMapping.js', - './js/model.js', - './js/serial_backend.js', - './js/data_storage.js', - './js/fc.js', - './js/msp.js', - './js/protocols/stm32.js', - './js/protocols/stm32usbdfu.js', - './js/localization.js', - './js/boards.js', - './js/servoMixerRuleCollection.js', - './js/motorMixerRuleCollection.js', - './js/logicConditionsCollection.js', - './js/logicConditionsStatus.js', - './js/globalVariablesStatus.js', - './js/programmingPid.js', - './js/programmingPidCollection.js', - './js/programmingPidStatus.js', - './js/vtx.js', - './main.js', - './js/tabs.js', - './tabs/*.js', - './js/eventFrequencyAnalyzer.js', - './js/periodicStatusUpdater.js', - './js/serial_queue.js', - './js/msp_balanced_interval.js', - './tabs/advanced_tuning.js', - './tabs/ez_tune.js', - './js/peripherals.js', - './js/appUpdater.js', - './js/feature_framework.js', - './js/defaults_dialog.js', - './js/safehomeCollection.js', - './js/safehome.js', - './js/waypointCollection.js', - './js/waypoint.js', - './node_modules/openlayers/dist/ol.js', - './js/libraries/plotly-latest.min.js', - './js/sitl.js', - './js/CliAutoComplete.js', - './node_modules/jquery-textcomplete/dist/jquery.textcomplete.js', - './js/fwApproach.js', - './js/fwApproachCollection.js', - './js/ltmDecoder.js', - './js/groundstation.js' -]; - -sources.receiverCss = [ - './src/css/tabs/receiver_msp.css', - './src/css/opensans_webfontkit/fonts.css', - './js/libraries/jquery.nouislider.min.css', - './js/libraries/jquery.nouislider.pips.min.css', -]; - -sources.receiverJs = [ - './node_modules/jquery/dist/jquery.min.js', - './node_modules/jquery-ui-npm/jquery-ui.min.js', - './js/libraries/jquery.nouislider.all.min.js', - './tabs/receiver_msp.js' -]; - -sources.debugTraceJs = [ - './js/debug_trace.js' -]; - -sources.hexParserJs = [ - './js/workers/hex_parser.js', -]; - -var output = { - css: 'styles.css', - js: 'script.js', - receiverCss: 'receiver-msp.css', - receiverJs: 'receiver-msp.js', - debugTraceJs: 'debug-trace.js', - hexParserJs: 'hex_parser.js', -}; - - -var outputDir = './build/'; -var distDir = './dist/'; -var appsDir = './apps/'; - -function get_task_name(key) { - return 'build-' + key.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();}); -} - -function getArguments() { - return minimist(process.argv.slice(2)); -} - -function getPlatforms() { - const defaultPlatforms = ['win32', 'win64', 'osx64', 'linux32', 'linux64']; - const platform = getArguments().platform; - if (platform) { - if (defaultPlatforms.indexOf(platform) < 0) { - throw new Error(`Invalid platform "${platform}". Available ones are: ${defaultPlatforms}`) - } - return [platform]; - } - return defaultPlatforms; -} - -function execSync() { - const cmd = arguments[0]; - const args = Array.prototype.slice.call(arguments, 1); - const result = child_process.spawnSync(cmd, args, {stdio: 'inherit'}); - if (result.error) { - throw result.error; - } -} - -// Define build tasks dynamically based on the sources -// and output variables. -var buildCssTasks = []; -var buildJsTasks = []; -(function() { - // Convers fooBarBaz to foo-bar-baz - for (var k in output) { - (function (key) { - var name = get_task_name(key); - if (name.endsWith('-css')) { - buildCssTasks.push(name); - } else if (name.endsWith('-js')) { - buildJsTasks.push(name); - } else { - throw 'Invalid task name: "' + name + '": must end with -css or -js'; - } - gulp.task(name, function() { - return gulp.src(sources[key]) - .pipe(concat(output[key])) - .pipe(gulp.dest(outputDir)); - }); - })(k); - } -})(); - -gulp.task('build-all-js', gulp.parallel(buildJsTasks)) -gulp.task('build-all-css', gulp.parallel(buildCssTasks)); -gulp.task('build', gulp.parallel('build-all-css', 'build-all-js')); - -gulp.task('clean', function() { return del(['./build/**', './dist/**'], {force: true}); }); - -// Real work for dist task. Done in another task to call it via -// run-sequence. -gulp.task('dist-build', gulp.series('build', function() { - var distSources = [ - './package.json', // For NW.js - './manifest.json', // For Chrome app - './eventPage.js', - './*.html', - './tabs/*.html', - './images/**/*', - './_locales/**/*', - './build/*', - './src/css/font-awesome/webfonts/*', - './src/css/opensans_webfontkit/*.{eot,svg,ttf,woff,woff2}', - './resources/*.json', - './resources/models/*', - './resources/osd/analogue/*.mcm', - './resources/motor_order/*.svg', - './resources/sitl/windows/*', - './resources/sitl/linux/*' - ]; - return gulp.src(distSources, { base: '.' }) - .pipe(gulp.dest(distDir)); -})); - -gulp.task('dist', gulp.series('clean', 'dist-build')); - -// Create app directories in ./apps -gulp.task('apps', gulp.series('dist', function(done) { - var builder = new NwBuilder({ - files: './dist/**/*', - buildDir: appsDir, - platforms: getPlatforms(), - flavor: 'normal', - macIcns: './images/inav.icns', - winIco: './images/inav.ico', - version: get_nw_version(), - zip: false - }); - builder.on('log', console.log); - builder.build(function (err) { - if (err) { - console.log("Error building NW apps:" + err); - done(); - return; - } - // Package apps as .zip files - done(); - }); -})); - -function get_nw_version() { - return semver.valid(semver.coerce(require('./package.json').dependencies.nw)); -} - -function get_release_filename_base(platform) { - return 'INAV-Configurator_' + platform; -} - -function get_release_filename(platform, ext, addition = '') { - var pkg = require('./package.json'); - return get_release_filename_base(platform) + addition + '_' + pkg.version + '.' + ext; -} - -function build_win_zip(arch) { - return function build_win_zip_proc(done) { - var pkg = require('./package.json'); - - // Create ZIP - console.log(`Creating ${arch} ZIP file...`); - var src = path.join(appsDir, pkg.name, arch); - var output = fs.createWriteStream(path.join(appsDir, get_release_filename(arch, 'zip'))); - var archive = archiver('zip', { - zlib: { level: 9 } - }); - archive.on('warning', function(err) { throw err; }); - archive.on('error', function(err) { throw err; }); - archive.pipe(output); - archive.directory(src, 'INAV Configurator'); - return archive.finalize(); - } -} - -function build_win_iss(arch) { - return function build_win_iss_proc(done) { - if (!getArguments().installer) { - done(); - return null; - } - - // Create Installer - console.log(`Creating ${arch} Installer...`); - const innoSetup = require('@quanle94/innosetup'); - - const APPS_DIR = './apps/'; - const pkg = require('./package.json'); - - // Parameters passed to the installer script - const parameters = []; - - // Extra parameters to replace inside the iss file - parameters.push(`/Dversion=${pkg.version}`); - parameters.push(`/DarchName=${arch}`); - parameters.push(`/DarchAllowed=${(arch === 'win32') ? 'x86 x64' : 'x64'}`); - parameters.push(`/DarchInstallIn64bit=${(arch === 'win32') ? '' : 'x64'}`); - parameters.push(`/DsourceFolder=${APPS_DIR}`); - parameters.push(`/DtargetFolder=${APPS_DIR}`); - - // Show only errors in console - parameters.push(`/Q`); - - // Script file to execute - parameters.push("assets/windows/installer.iss"); - - innoSetup(parameters, {}, - function(error) { - if (error != null) { - console.error(`Installer for platform ${arch} finished with error ${error}`); - } else { - console.log(`Installer for platform ${arch} finished`); - } - done(); - }); - } -} - -gulp.task('release-win32', gulp.series(build_win_zip('win32'), build_win_iss('win32'))); -gulp.task('release-win64', gulp.series(build_win_zip('win64'), build_win_iss('win64'))); - -gulp.task('release-osx64', function(done) { - var pkg = require('./package.json'); - var src = path.join(appsDir, pkg.name, 'osx64', pkg.name + '.app'); - // Check if we want to sign the .app bundle - if (getArguments().codesign) { - // macapptool can be downloaded from - // https://github.com/fiam/macapptool - // - // Make sure the bundle is well formed - execSync('macapptool', '-v', '1', 'fix', src); - // Sign - const codesignArgs = ['macapptool', '-v', '1', 'sign']; - const codesignIdentity = getArguments()['codesign-identity']; - if (codesignIdentity) { - codesignArgs.push('-i', codesignIdentity); - } - codesignArgs.push('-e', 'entitlements.plist'); - codesignArgs.push(src) - execSync.apply(this, codesignArgs); - - // Check if the bundle is signed - const codesignCheckArgs = [ 'codesign', '-vvv', '--deep', '--strict', src ]; - execSync.apply(this, codesignCheckArgs); - } - - // 'old' .zip mode - if (!getArguments().installer) { - const zipFilename = path.join(appsDir, get_release_filename('macOS', 'zip')); - console.log('Creating ZIP file: ' + zipFilename); - var output = fs.createWriteStream(zipFilename); - var archive = archiver('zip', { - zlib: { level: 9 } - }); - archive.on('warning', function(err) { throw err; }); - archive.on('error', function(err) { throw err; }); - archive.pipe(output); - archive.directory(src, 'INAV Configurator.app'); - output.on('close', function() { - if (getArguments().notarize) { - console.log('Notarizing ZIP file: ' + zipFilename); - const notarizeArgs = ['xcrun', 'notarytool', 'submit']; - notarizeArgs.push(zipFilename); - const notarizationUsername = getArguments()['notarization-username']; - if (notarizationUsername) { - notarizeArgs.push('--apple-id', notarizationUsername) - } else { - throw new Error('Missing notarization username'); - } - const notarizationPassword = getArguments()['notarization-password']; - if (notarizationPassword) { - notarizeArgs.push('--password', notarizationPassword) - } else { - throw new Error('Missing notarization password'); - } - const notarizationTeamId = getArguments()['notarization-team-id']; - if (notarizationTeamId) { - notarizeArgs.push('--team-id', notarizationTeamId) - } else { - throw new Error('Missing notarization Team ID'); - } - notarizeArgs.push('--wait'); - - const notarizationWebhook = getArguments()['notarization-webhook']; - if (notarizationWebhook) { - notarizeArgs.push('--webhook', notarizationWebhook); - } - execSync.apply(this, notarizeArgs); - - console.log('Stapling ZIP file: ' + zipFilename); - const stapleArgs = ['macapptool', '-v', '1', 'staple']; - stapleArgs.push(zipFilename) - execSync.apply(this, stapleArgs); - } - done(); - }); - archive.finalize(); - } - // 'new' .dmg mode - else { - const appdmg = require('appdmg'); - - var target = path.join(appsDir, get_release_filename('macOS', 'dmg')); - console.log('Creating DMG file: ' + target); - var basepath = path.join(appsDir, pkg.name, 'osx64'); - console.log('Base path: ' + basepath); - - if (fs.existsSync(target)) { - fs.unlinkSync(target); - } - - var specs = {}; - - specs["title"] = "INAV Configurator"; - specs["contents"] = [ - { "x": 448, "y": 342, "type": "link", "path": "/Applications" }, - { "x": 192, "y": 344, "type": "file", "path": pkg.name + ".app", "name": "INAV Configurator.app" }, - ]; - specs["background"] = path.join(__dirname, 'assets/osx/dmg-background.png'); - specs["format"] = "UDZO"; - specs["window"] = { - "size": { - "width": 638, - "height": 479, - } - }; - - const codesignIdentity = getArguments()['codesign-identity']; - if (getArguments().codesign) { - specs['code-sign'] = { - 'signing-identity': codesignIdentity, - } - } - - const ee = appdmg({ - target: target, - basepath: basepath, - specification: specs, - }); - - ee.on('progress', function(info) { - //console.log(info); - }); - - ee.on('error', function(err) { - console.log(err); - }); - - ee.on('finish', function() { - if (getArguments().codesign) { - // Check if the bundle is signed - const codesignCheckArgs = [ 'codesign', '-vvv', '--deep', '--strict', target ]; - execSync.apply(this, codesignCheckArgs); - } - if (getArguments().notarize) { - console.log('Notarizing DMG file: ' + target); - const notarizeArgs = ['xcrun', 'notarytool', 'submit']; - notarizeArgs.push(target); - const notarizationUsername = getArguments()['notarization-username']; - if (notarizationUsername) { - notarizeArgs.push('--apple-id', notarizationUsername) - } else { - throw new Error('Missing notarization username'); - } - const notarizationPassword = getArguments()['notarization-password']; - if (notarizationPassword) { - notarizeArgs.push('--password', notarizationPassword) - } else { - throw new Error('Missing notarization password'); - } - const notarizationTeamId = getArguments()['notarization-team-id']; - if (notarizationTeamId) { - notarizeArgs.push('--team-id', notarizationTeamId) - } else { - throw new Error('Missing notarization Team ID'); - } - notarizeArgs.push('--wait'); - - const notarizationWebhook = getArguments()['notarization-webhook']; - if (notarizationWebhook) { - notarizeArgs.push('--webhook', notarizationWebhook); - } - execSync.apply(this, notarizeArgs); - - console.log('Stapling DMG file: ' + target); - const stapleArgs = ['xcrun', 'stapler', 'staple']; - stapleArgs.push(target); - execSync.apply(this, stapleArgs); - - console.log('Checking DMG file: ' + target); - const checkArgs = ['spctl', '-vvv', '--assess', '--type', 'install', target]; - execSync.apply(this, checkArgs); - } - done(); - }); - } -}); - -function post_build(arch, folder) { - return function post_build_linux(done) { - if ((arch === 'linux32') || (arch === 'linux64')) { - const metadata = require('./package.json'); - // Copy Ubuntu launcher scripts to destination dir - const launcherDir = path.join(folder, metadata.name, arch); - console.log(`Copy Ubuntu launcher scripts to ${launcherDir}`); - return gulp.src('assets/linux/**') - .pipe(gulp.dest(launcherDir)); - } - - return done(); - } -} - -// Create the dir directory, with write permissions -function createDirIfNotExists(dir) { - fs.mkdir(dir, '0775', function(err) { - if (err && err.code !== 'EEXIST') { - throw err; - } - }); -} - -function release_deb(arch) { - return function release_deb_proc(done) { - if (!getArguments().installer) { - done(); - return null; - } - - // Check if dpkg-deb exists - if (!commandExistsSync('dpkg-deb')) { - console.warn(`dpkg-deb command not found, not generating deb package for ${arch}`); - done(); - return null; - } - - const deb = require('gulp-debian'); - const LINUX_INSTALL_DIR = '/opt/inav'; - const metadata = require('./package.json'); - - console.log(`Generating deb package for ${arch}`); - - return gulp.src([path.join(appsDir, metadata.name, arch, '*')]) - .pipe(deb({ - package: metadata.name, - version: metadata.version, - section: 'base', - priority: 'optional', - architecture: getLinuxPackageArch('deb', arch), - maintainer: metadata.author, - description: metadata.description, - preinst: [`rm -rf ${LINUX_INSTALL_DIR}/${metadata.name}`], - postinst: [ - `chown root:root ${LINUX_INSTALL_DIR}`, - `chown -R root:root ${LINUX_INSTALL_DIR}/${metadata.name}`, - `xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${metadata.name}/${metadata.name}.desktop`, - ], - prerm: [`xdg-desktop-menu uninstall ${metadata.name}.desktop`], - depends: ['libatomic1'], - changelog: [], - _target: `${LINUX_INSTALL_DIR}/${metadata.name}`, - _out: appsDir, - _copyright: 'assets/linux/copyright', - _clean: true, - })); - } -} - -function post_release_deb(arch) { - return function post_release_linux_deb(done) { - if (!getArguments().installer) { - done(); - return null; - } - if ((arch === 'linux32') || (arch === 'linux64')) { - var rename = require("gulp-rename"); - const metadata = require('./package.json'); - const renameFrom = path.join(appsDir, metadata.name + '_' + metadata.version + '_' + getLinuxPackageArch('.deb', arch) + '.deb'); - const renameTo = path.join(appsDir, get_release_filename_base(arch) + '_' + metadata.version + '.deb'); - // Rename .deb build to common naming - console.log(`Renaming .deb installer ${renameFrom} to ${renameTo}`); - return gulp.src(renameFrom) - .pipe(rename(renameTo)) - .pipe(gulp.dest(".")); - } - - return done(); - } -} - -function release_rpm(arch) { - return function release_rpm_proc(done) { - if (!getArguments().installer) { - done(); - return null; - } - - // Check if rpmbuild exists - if (!commandExistsSync('rpmbuild')) { - console.warn(`rpmbuild command not found, not generating rpm package for ${arch}`); - done(); - return; - } - - const buildRpm = require('rpm-builder'); - const NAME_REGEX = /-/g; - const LINUX_INSTALL_DIR = '/opt/inav'; - const metadata = require('./package.json'); - - console.log(`Generating rpm package for ${arch}`); - - // The buildRpm does not generate the folder correctly, manually - createDirIfNotExists(appsDir); - - const options = { - name: get_release_filename_base(arch), // metadata.name, - version: metadata.version.replace(NAME_REGEX, '_'), // RPM does not like release candidate versions - buildArch: getLinuxPackageArch('rpm', arch), - vendor: metadata.author, - summary: metadata.description, - license: 'GNU General Public License v3.0', - requires: ['libatomic1'], - prefix: '/opt', - files: [{ - cwd: path.join(appsDir, metadata.name, arch), - src: '*', - dest: `${LINUX_INSTALL_DIR}/${metadata.name}`, - }], - postInstallScript: [`xdg-desktop-menu install ${LINUX_INSTALL_DIR}/${metadata.name}/${metadata.name}.desktop`], - preUninstallScript: [`xdg-desktop-menu uninstall ${metadata.name}.desktop`], - tempDir: path.join(appsDir, `tmp-rpm-build-${arch}`), - keepTemp: false, - verbose: false, - rpmDest: appsDir, - execOpts: { maxBuffer: 1024 * 1024 * 16 }, - }; - - buildRpm(options, function(err) { - if (err) { - console.error(`Error generating rpm package: ${err}`); - } - done(); - }); - } -} - -function getLinuxPackageArch(type, arch) { - let packArch; - - switch (arch) { - case 'linux32': - packArch = 'i386'; - break; - case 'linux64': - if (type === 'rpm') { - packArch = 'x86_64'; - } else { - packArch = 'amd64'; - } - break; - default: - console.error(`Package error, arch: ${arch}`); - process.exit(1); - break; - } - - return packArch; -} - -function releaseLinux(bits) { - return function() { - console.log(`Generating zip package for linux${bits}`); - var dirname = 'linux' + bits; - var pkg = require('./package.json'); - var src = path.join(appsDir, pkg.name, dirname); - var output = fs.createWriteStream(path.join(appsDir, get_release_filename(dirname, 'tar.gz'))); - var archive = archiver('tar', { - zlib: { level: 9 }, - gzip: true - }); - archive.on('warning', function(err) { throw err; }); - archive.on('error', function(err) { throw err; }); - archive.pipe(output); - archive.directory(src, 'INAV Configurator'); - return archive.finalize(); - } -} - -gulp.task('release-linux32', gulp.series(releaseLinux(32), post_build('linux32', appsDir), release_deb('linux32'), post_release_deb('linux32'))); -gulp.task('release-linux64', gulp.series(releaseLinux(64), post_build('linux64', appsDir), release_deb('linux64'), post_release_deb('linux64'), release_rpm('linux64'))); - -// Create distributable .zip files in ./apps -gulp.task('release', gulp.series('apps', getPlatforms().map(function(v) { return 'release-' + v; }))); - -gulp.task('watch', function () { - for(var k in output) { - gulp.watch(sources[k], gulp.series(get_task_name(k))); - } -}); - -gulp.task('default', gulp.series('build')); - diff --git a/index.html b/index.html index dd754662..acab4b1f 100644 --- a/index.html +++ b/index.html @@ -5,9 +5,11 @@ + + -
Stellen Sie sicher, dass der Mischer konfiguriert wurde, bevor Sie Presets anwenden!
Preset überschreibt ausgewählte Konfigurationswerte, einschließlich Mixer, Filterung, PIDs und andere. Einstellungen wie: Flugmodi, Funkeinstellungen, Failsafe und OSD werden nicht verändert. Die angewendeten Werte sollten NICHT als endgültige Werte behandelt werden, sondern als Einstiegspunkt für die endgültige Einstellung.
Überprüfen Sie die neue Konfiguration immer vor dem Fliegen!
').append(select)); customElementRowValue.append($(' | ').addClass('osdCustomElement-' + i + '-part-' + ii + '-value').append( - $('').addClass('value').addClass('text').attr('type', 'text').attr('maxlength', OSD_CUSTOM_ELEMENTS.settings.customElementTextSize).hide() + $('').addClass('value').addClass('text').attr('type', 'text').attr('maxlength', FC.OSD_CUSTOM_ELEMENTS.settings.customElementTextSize).hide() ).append( $('').addClass('value').addClass('ico').attr('min', 1).attr('max', 255).hide() ).append( @@ -3456,7 +3473,7 @@ function createCustomElements(){ valueBlock.find('.' + dataValue).show(); }); - customElementLabel.append($(' | ').attr('colspan', 2).append($('').html(chrome.i18n.getMessage("custom_element") + ' ' + (i + 1)))); + customElementLabel.append($(' | ').attr('colspan', 2).append($('').html(i18n.getMessage("custom_element") + ' ' + (i + 1)))); customElementTable.append(customElementRowType).append(customElementRowValue).append(customElementLabel); label.append(customElementTable); @@ -3468,38 +3485,38 @@ function createCustomElements(){ } function fillCustomElementsValues() { - for (var i = 0; i < OSD_CUSTOM_ELEMENTS.settings.customElementsCount; i++) { + for (var i = 0; i < FC.OSD_CUSTOM_ELEMENTS.settings.customElementsCount; i++) { for (var ii = 0; ii < 3; ii++) { - $('.osdCustomElement-' + i + '-part-' + ii + '-type').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].type).trigger('change'); + $('.osdCustomElement-' + i + '-part-' + ii + '-type').val(FC.OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].type).trigger('change'); var valueCell = $('.osdCustomElement-' + i + '-part-' + ii + '-value'); - switch (OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].type){ + switch (FC.OSD_CUSTOM_ELEMENTS .items[i].customElementItems[ii].type){ case 1: - valueCell.find('.text').val(OSD_CUSTOM_ELEMENTS.items[i].customElementText).trigger('change'); + valueCell.find('.text').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementText).trigger('change'); break; case 2: - valueCell.find('.ico').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].value).trigger('change'); + valueCell.find('.ico').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementItems[ii].value).trigger('change'); break; case 3: - valueCell.find('.ico_gv').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].value).trigger('change'); + valueCell.find('.ico_gv').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementItems[ii].value).trigger('change'); break; case 4: case 5: case 6: case 7: - valueCell.find('.gv').val(OSD_CUSTOM_ELEMENTS.items[i].customElementItems[ii].value).trigger('change'); + valueCell.find('.gv').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementItems[ii].value).trigger('change'); break; } } - $('.osdCustomElement-' + i + '-visibility-type').val(OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.type).trigger('change'); + $('.osdCustomElement-' + i + '-visibility-type').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementVisibility.type).trigger('change'); var valueVisibilityCell = $('.osdCustomElement-' + i + '-visibility-value'); - switch (OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.type){ + switch (FC.OSD_CUSTOM_ELEMENTS .items[i].customElementVisibility.type){ case 1: - valueVisibilityCell.find('.gv').val(OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.value).trigger('change'); + valueVisibilityCell.find('.gv').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementVisibility.value).trigger('change'); break; case 2: - valueVisibilityCell.find('.lc').val(OSD_CUSTOM_ELEMENTS.items[i].customElementVisibility.value).trigger('change'); + valueVisibilityCell.find('.lc').val(FC.OSD_CUSTOM_ELEMENTS .items[i].customElementVisibility.value).trigger('change'); break; } @@ -3613,7 +3630,7 @@ function customElementGetDataForRow(row){ data.push8(parseInt(elementVisibilityType.val())); data.push16(visibilityValue); - for(var i = 0; i < OSD_CUSTOM_ELEMENTS.settings.customElementTextSize; i++){ + for(var i = 0; i < FC.OSD_CUSTOM_ELEMENTS .settings.customElementTextSize; i++){ if(i < text.length){ data.push8(text.charCodeAt(i)) }else{ @@ -3716,7 +3733,7 @@ function updatePanServoPreview() { } // Update the panServoOutput select to be visibly easier to use - let servoRules = SERVO_RULES; + let servoRules = FC.SERVO_RULES; $('#panServoOutput option').each(function() { let servoIndex = $(this).val(); diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index ad1483f4..0021c76d 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -1,6 +1,23 @@ -/*global chrome,helper,mspHelper*/ 'use strict'; +const path = require('path'); +const Store = require('electron-store'); +const store = new Store() + +const MSPChainerClass = require('./../js/msp/MSPchainer'); +const mspHelper = require('./../js/msp/MSPHelper'); +const MSPCodes = require('./../js/msp/MSPCodes'); +const MSP = require('./../js/msp'); +const { GUI, TABS } = require('./../js/gui'); +const features = require('./../js/feature_framework'); +const tabs = require('./../js/tabs'); +const FC = require('./../js/fc'); +const Settings = require('./../js/settings'); +const i18n = require('./../js/localization'); +const { scaleRangeInt } = require('./../js/helpers'); +const SerialBackend = require('./../js/serial_backend'); +const BitHelper = require('./../js/bitHelper'); + TABS.pid_tuning = { }; @@ -30,12 +47,12 @@ TABS.pid_tuning.initialize = function (callback) { } function load_html() { - GUI.load(path.join(__dirname, "tabs/pid_tuning.html"), Settings.processHtml(process_html)); + GUI.load(path.join(__dirname, "pid_tuning.html"), Settings.processHtml(process_html)); } function pid_and_rc_to_form() { - // Fill in the data from PIDs array + // Fill in the data from FC.PIDs array var pidNames = FC.getPidNames(); $('[data-pid-bank-position]').each(function () { @@ -46,22 +63,22 @@ TABS.pid_tuning.initialize = function (callback) { $this.find('td:first').text(pidNames[bankPosition]); $this.find('input').each(function (index) { - $(this).val(PIDs[bankPosition][index]); + $(this).val(FC.PIDs[bankPosition][index]); }); } }); - // Fill in data from RC_tuning object - $('#rate-roll').val(RC_tuning.roll_rate); - $('#rate-pitch').val(RC_tuning.pitch_rate); - $('#rate-yaw').val(RC_tuning.yaw_rate); + // Fill in data from FC.RC_tuning object + $('#rate-roll').val(FC.RC_tuning.roll_rate); + $('#rate-pitch').val(FC.RC_tuning.pitch_rate); + $('#rate-yaw').val(FC.RC_tuning.yaw_rate); - $('#rate-manual-roll').val(RC_tuning.manual_roll_rate); - $('#rate-manual-pitch').val(RC_tuning.manual_pitch_rate); - $('#rate-manual-yaw').val(RC_tuning.manual_yaw_rate); + $('#rate-manual-roll').val(FC.RC_tuning.manual_roll_rate); + $('#rate-manual-pitch').val(FC.RC_tuning.manual_pitch_rate); + $('#rate-manual-yaw').val(FC.RC_tuning.manual_yaw_rate); - $('#tpa').val(RC_tuning.dynamic_THR_PID); - $('#tpa-breakpoint').val(RC_tuning.dynamic_THR_breakpoint); + $('#tpa').val(FC.RC_tuning.dynamic_THR_PID); + $('#tpa-breakpoint').val(FC.RC_tuning.dynamic_THR_breakpoint); } function form_to_pid_and_rc() { @@ -75,58 +92,58 @@ TABS.pid_tuning.initialize = function (callback) { return; } - if (PIDs[bankPosition]) { + if (FC.PIDs[bankPosition]) { $this.find('input').each(function (index) { - PIDs[bankPosition][index] = parseFloat($(this).val()); + FC.PIDs[bankPosition][index] = parseFloat($(this).val()); }); } }); - // catch RC_tuning changes - RC_tuning.roll_rate = parseFloat($('#rate-roll').val()); - RC_tuning.pitch_rate = parseFloat($('#rate-pitch').val()); - RC_tuning.yaw_rate = parseFloat($('#rate-yaw').val()); + // catch FC.RC_tuning changes + FC.RC_tuning.roll_rate = parseFloat($('#rate-roll').val()); + FC.RC_tuning.pitch_rate = parseFloat($('#rate-pitch').val()); + FC.RC_tuning.yaw_rate = parseFloat($('#rate-yaw').val()); - RC_tuning.dynamic_THR_PID = parseInt($('#tpa').val()); - RC_tuning.dynamic_THR_breakpoint = parseInt($('#tpa-breakpoint').val()); + FC.RC_tuning.dynamic_THR_PID = parseInt($('#tpa').val()); + FC.RC_tuning.dynamic_THR_breakpoint = parseInt($('#tpa-breakpoint').val()); - RC_tuning.manual_roll_rate = $('#rate-manual-roll').val(); - RC_tuning.manual_pitch_rate = $('#rate-manual-pitch').val(); - RC_tuning.manual_yaw_rate = $('#rate-manual-yaw').val(); + FC.RC_tuning.manual_roll_rate = $('#rate-manual-roll').val(); + FC.RC_tuning.manual_pitch_rate = $('#rate-manual-pitch').val(); + FC.RC_tuning.manual_yaw_rate = $('#rate-manual-yaw').val(); // Rate Dynamics - RATE_DYNAMICS.sensitivityCenter = parseInt($('#rate_dynamics_center_sensitivity').val()); - RATE_DYNAMICS.sensitivityEnd = parseInt($('#rate_dynamics_end_sensitivity').val()); - RATE_DYNAMICS.correctionCenter = parseInt($('#rate_dynamics_center_correction').val()); - RATE_DYNAMICS.correctionEnd = parseInt($('#rate_dynamics_end_correction').val()); - RATE_DYNAMICS.weightCenter = parseInt($('#rate_dynamics_center_weight').val()); - RATE_DYNAMICS.weightEnd = parseInt($('#rate_dynamics_end_weight').val()); + FC.RATE_DYNAMICS.sensitivityCenter = parseInt($('#rate_dynamics_center_sensitivity').val()); + FC.RATE_DYNAMICS.sensitivityEnd = parseInt($('#rate_dynamics_end_sensitivity').val()); + FC.RATE_DYNAMICS.correctionCenter = parseInt($('#rate_dynamics_center_correction').val()); + FC.RATE_DYNAMICS.correctionEnd = parseInt($('#rate_dynamics_end_correction').val()); + FC.RATE_DYNAMICS.weightCenter = parseInt($('#rate_dynamics_center_weight').val()); + FC.RATE_DYNAMICS.weightEnd = parseInt($('#rate_dynamics_end_weight').val()); } function hideUnusedPids(sensors_detected) { $('.tab-pid_tuning table.pid_tuning').hide(); $('#pid_main').show(); - if (have_sensor(sensors_detected, 'acc')) { + if (SerialBackend.have_sensor(sensors_detected, 'acc')) { $('#pid_accel').show(); } - if (have_sensor(sensors_detected, 'baro')) { + if (SerialBackend.have_sensor(sensors_detected, 'baro')) { $('#pid_baro').show(); } - if (have_sensor(sensors_detected, 'mag')) { + if (SerialBackend.have_sensor(sensors_detected, 'mag')) { $('#pid_mag').show(); } - if (bit_check(FEATURES, 7)) { + if (BitHelper.bit_check(FC.FEATURES, 7)) { $('#pid_gps').show(); } - if (have_sensor(sensors_detected, 'sonar')) { + if (SerialBackend.have_sensor(sensors_detected, 'sonar')) { $('#pid_baro').show(); } } function process_html() { // translate to user-selected language - if (EZ_TUNE.enabled) { + if (FC.EZ_TUNE.enabled) { $("#tuning-wrapper").remove(); $("#tuning-footer").remove(); $('#note-wrapper').show(); @@ -136,10 +153,10 @@ TABS.pid_tuning.initialize = function (callback) { i18n.localize();; - helper.tabs.init($('.tab-pid_tuning')); - helper.features.updateUI($('.tab-pid_tuning'), FEATURES); + tabs.init($('.tab-pid_tuning')); + features.updateUI($('.tab-pid_tuning'), FC.FEATURES); - hideUnusedPids(CONFIG.activeSensors); + hideUnusedPids(FC.CONFIG.activeSensors); $('#showAllPids').on('click', function(){ if($(this).text() == "Show all PIDs") { @@ -147,7 +164,7 @@ TABS.pid_tuning.initialize = function (callback) { $(this).text('Hide unused PIDs'); $('.show').addClass('unusedPIDsHidden'); } else { - hideUnusedPids(CONFIG.activeSensors); + hideUnusedPids(FC.CONFIG.activeSensors); $(this).text('Show all PIDs'); $('.show').removeClass('unusedPIDsHidden'); } @@ -157,7 +174,7 @@ TABS.pid_tuning.initialize = function (callback) { if (confirm(i18n.getMessage('confirm_reset_pid'))) { MSP.send_message(MSPCodes.MSP_SET_RESET_CURR_PID, false, false, false); - updateActivatedTab(); + GUI.updateActivatedTab(); } }); @@ -215,7 +232,7 @@ TABS.pid_tuning.initialize = function (callback) { } $(this).parent().find('input[name="value-input"]').val(val); - PIDs[$(this).parent().data('axis')][$(this).parent().data('bank')] = val; + FC.PIDs[$(this).parent().data('axis')][$(this).parent().data('bank')] = val; }); $(".pid-slider-row [name='value-input']").on('change', function () { @@ -230,7 +247,7 @@ TABS.pid_tuning.initialize = function (callback) { } $(this).parent().find('input[name="value-slider"]').val(newVal); - PIDs[$(this).parent().data('axis')][$(this).parent().data('bank')] = $(this).val(); + FC.PIDs[$(this).parent().data('axis')][$(this).parent().data('bank')] = $(this).val(); }); let axis = 0; @@ -243,21 +260,21 @@ TABS.pid_tuning.initialize = function (callback) { let $this = $(this); $this.data('axis', axis); $this.data('bank', bank); - $this.find('input[name="value-input"]').val(PIDs[axis][bank]).trigger('change'); + $this.find('input[name="value-input"]').val(FC.PIDs[axis][bank]).trigger('change'); bank++; }); axis++; }); - GUI.sliderize($('#rate_dynamics_center_sensitivity'), RATE_DYNAMICS.sensitivityCenter, 25, 175); - GUI.sliderize($('#rate_dynamics_end_sensitivity'), RATE_DYNAMICS.sensitivityEnd, 25, 175); + GUI.sliderize($('#rate_dynamics_center_sensitivity'), FC.RATE_DYNAMICS.sensitivityCenter, 25, 175); + GUI.sliderize($('#rate_dynamics_end_sensitivity'), FC.RATE_DYNAMICS.sensitivityEnd, 25, 175); - GUI.sliderize($('#rate_dynamics_center_correction'), RATE_DYNAMICS.correctionCenter, 10, 95); - GUI.sliderize($('#rate_dynamics_end_correction'), RATE_DYNAMICS.correctionEnd, 10, 95); + GUI.sliderize($('#rate_dynamics_center_correction'), FC.RATE_DYNAMICS.correctionCenter, 10, 95); + GUI.sliderize($('#rate_dynamics_end_correction'), FC.RATE_DYNAMICS.correctionEnd, 10, 95); - GUI.sliderize($('#rate_dynamics_center_weight'), RATE_DYNAMICS.weightCenter, 0, 95); - GUI.sliderize($('#rate_dynamics_end_weight'), RATE_DYNAMICS.weightEnd, 0, 95); + GUI.sliderize($('#rate_dynamics_center_weight'), FC.RATE_DYNAMICS.weightCenter, 0, 95); + GUI.sliderize($('#rate_dynamics_end_weight'), FC.RATE_DYNAMICS.weightEnd, 0, 95); if (!FC.isRpyFfComponentUsed()) { $('.rpy_ff').prop('disabled', 'disabled'); @@ -314,9 +331,9 @@ TABS.pid_tuning.initialize = function (callback) { }); } - helper.features.reset(); - helper.features.fromUI($('.tab-pid_tuning')); - helper.features.execute(function () { + features.reset(); + features.fromUI($('.tab-pid_tuning')); + features.execute(function () { mspHelper.savePidData(send_rc_tuning_changes); }); }); diff --git a/tabs/ports.js b/tabs/ports.js index ccaebf48..4b2effd7 100644 --- a/tabs/ports.js +++ b/tabs/ports.js @@ -2,6 +2,14 @@ const path = require('path'); +const mspHelper = require('./../js/msp/MSPHelper'); +const MSPCodes = require('./../js/msp/MSPCodes'); +const MSP = require('./../js/msp'); +const { GUI, TABS } = require('./../js/gui'); +const FC = require('./../js/fc'); +const i18n = require('./../js/localization'); +const serialPortHelper = require('./../js/serialPortHelper'); + TABS.ports = {}; TABS.ports.initialize = function (callback) { @@ -13,7 +21,7 @@ TABS.ports.initialize = function (callback) { } mspHelper.loadSerialPorts(function () { - GUI.load("./tabs/ports.html", on_tab_loaded_handler) + GUI.load(path.join(__dirname, "ports.html"), on_tab_loaded_handler) }); function update_ui() { @@ -24,31 +32,31 @@ TABS.ports.initialize = function (callback) { $elements; $elements = $('select.sensors_baudrate'); - for (i = 0; i < helper.serialPortHelper.getBauds('SENSOR').length; i++) { - $elements.append(''); + for (i = 0; i < serialPortHelper.getBauds('SENSOR').length; i++) { + $elements.append(''); } $elements = $('select.msp_baudrate'); - for (i = 0; i < helper.serialPortHelper.getBauds('MSP').length; i++) { - $elements.append(''); + for (i = 0; i < serialPortHelper.getBauds('MSP').length; i++) { + $elements.append(''); } $elements = $('select.telemetry_baudrate'); - for (i = 0; i < helper.serialPortHelper.getBauds('TELEMETRY').length; i++) { - $elements.append(''); + for (i = 0; i < serialPortHelper.getBauds('TELEMETRY').length; i++) { + $elements.append(''); } $elements = $('select.peripherals_baudrate'); - for (i = 0; i < helper.serialPortHelper.getBauds('PERIPHERAL').length; i++) { - $elements.append(''); + for (i = 0; i < serialPortHelper.getBauds('PERIPHERAL').length; i++) { + $elements.append(''); } var ports_e = $('.tab-ports .ports'); var port_configuration_template_e = $('#tab-ports-templates .portConfiguration'); - for (var portIndex = 0; portIndex < SERIAL_CONFIG.ports.length; portIndex++) { + for (var portIndex = 0; portIndex < FC.SERIAL_CONFIG.ports.length; portIndex++) { var port_configuration_e = port_configuration_template_e.clone(); - var serialPort = SERIAL_CONFIG.ports[portIndex]; + var serialPort = FC.SERIAL_CONFIG.ports[portIndex]; port_configuration_e.data('serialPort', serialPort); @@ -60,7 +68,7 @@ TABS.ports.initialize = function (callback) { port_configuration_e.find('select.sensors_baudrate').val(serialPort.sensors_baudrate); port_configuration_e.find('select.peripherals_baudrate').val(serialPort.peripherals_baudrate); - port_configuration_e.find('.identifier').text(helper.serialPortHelper.getPortName(serialPort.identifier)); + port_configuration_e.find('.identifier').text(serialPortHelper.getPortName(serialPort.identifier)); if (serialPort.identifier >= 30) { port_configuration_e.find('.softSerialWarning').css("display", "inline") } else { @@ -77,8 +85,8 @@ TABS.ports.initialize = function (callback) { let functions_e_id = "portFunc-" + column + "-" + portIndex; functions_e.attr("id", functions_e_id); - for (i = 0; i < helper.serialPortHelper.getRules().length; i++) { - var functionRule = helper.serialPortHelper.getRules()[i]; + for (i = 0; i < serialPortHelper.getRules().length; i++) { + var functionRule = serialPortHelper.getRules()[i]; var functionName = functionRule.name; if (functionRule.groups.indexOf(column) == -1) { @@ -102,9 +110,14 @@ TABS.ports.initialize = function (callback) { select_e = functions_e.find(selectElementSelector); if (select_e.length == 0) { - functions_e.prepend(''); + functions_e.prepend(''); + + functions_e.find('#' + selectElementName).on('change', () => { + updateDefaultBaud(functions_e_id, column); + }); + select_e = functions_e.find(selectElementSelector); - var disabledText = chrome.i18n.getMessage('portsTelemetryDisabled'); + var disabledText = i18n.getMessage('portsTelemetryDisabled'); select_e.append(''); } select_e.append(''); @@ -128,7 +141,7 @@ TABS.ports.initialize = function (callback) { let $cT = $(e.currentTarget); let functionName = $cT.val(); - let rule = helper.serialPortHelper.getRuleByName($cT.val()); + let rule = serialPortHelper.getRuleByName($cT.val()); //if type is checkbox then process only if selected if ($cT.is('input[type="checkbox"]') && !$cT.is(':checked')) { @@ -177,7 +190,7 @@ TABS.ports.initialize = function (callback) { function on_save_handler() { //Clear ports of any previous for serials different than USB VCP - SERIAL_CONFIG.ports = SERIAL_CONFIG.ports.filter(item => item.identifier == 20) + FC.SERIAL_CONFIG.ports = FC.SERIAL_CONFIG.ports.filter(item => item.identifier == 20) $('.tab-ports .portConfiguration').each(function () { @@ -216,7 +229,7 @@ TABS.ports.initialize = function (callback) { peripherals_baudrate: $(portConfiguration_e).find('.peripherals_baudrate').val(), identifier: oldSerialPort.identifier }; - SERIAL_CONFIG.ports.push(serialPort); + FC.SERIAL_CONFIG.ports.push(serialPort); }); mspHelper.saveSerialPorts(save_to_eeprom); @@ -245,7 +258,7 @@ function updateDefaultBaud(baudSelect, column) { let portName = section.find('.function-' + column).val(); let baudRate = (column === 'telemetry') ? "AUTO" : 115200;; - let rule = helper.serialPortHelper.getRuleByName(portName); + let rule = serialPortHelper.getRuleByName(portName); if (rule && typeof rule.defaultBaud !== 'undefined') { baudRate = rule.defaultBaud; diff --git a/tabs/programming.js b/tabs/programming.js index c7cc9321..8ca1ca58 100644 --- a/tabs/programming.js +++ b/tabs/programming.js @@ -1,6 +1,16 @@ -/*global TABS,MSPChainerClass,mspHelper,GUI,LOGIC_CONDITIONS,PROGRAMMING_PID,GLOBAL_VARIABLES_STATUS,helper,LOGIC_CONDITIONS_STATUS,PROGRAMMING_PID_STATUS*/ 'use strict'; +const path = require('path'); + +const MSPChainerClass = require('./../js/msp/MSPchainer'); +const mspBalancedInterval = require('./../js/msp_balanced_interval'); +const mspHelper = require('./../js/msp/MSPHelper'); +const { GUI, TABS } = require('./../js/gui'); +const FC = require('./../js/fc'); +const tabs = require('./../js/tabs'); +const i18n = require('./../js/localization'); + + TABS.programming = {}; TABS.programming.initialize = function (callback, scrollPosition) { @@ -35,28 +45,30 @@ TABS.programming.initialize = function (callback, scrollPosition) { statusChainer.setExitPoint(onStatusPullDone); function loadHtml() { - GUI.load(path.join(__dirname, "tabs/programming.html"), processHtml); + GUI.load(path.join(__dirname, "programming.html"), processHtml); } function processHtml() { - LOGIC_CONDITIONS.init($('#subtab-lc')); - LOGIC_CONDITIONS.render(); + FC.LOGIC_CONDITIONS.init($('#subtab-lc')); + FC.LOGIC_CONDITIONS.render(); + GUI.switchery(); - PROGRAMMING_PID.init($('#subtab-pid')); - PROGRAMMING_PID.render(); + FC.PROGRAMMING_PID.init($('#subtab-pid')); + FC.PROGRAMMING_PID.render(); + GUI.switchery(); - GLOBAL_VARIABLES_STATUS.init($(".gvar__container")); + FC.GLOBAL_VARIABLES_STATUS.init($(".gvar__container")); - helper.tabs.init($('.tab-programming')); + tabs.init($('.tab-programming')); - i18n.localize();; + i18n.localize();; $('#save-button').on('click', function () { saveChainer.execute(); GUI.log(i18n.getMessage('programmingEepromSaved')); }); - helper.mspBalancedInterval.add('logic_conditions_pull', 100, 1, function () { + mspBalancedInterval.add('logic_conditions_pull', 100, 1, function () { statusChainer.execute(); }); @@ -64,9 +76,9 @@ TABS.programming.initialize = function (callback, scrollPosition) { } function onStatusPullDone() { - LOGIC_CONDITIONS.update(LOGIC_CONDITIONS_STATUS); - GLOBAL_VARIABLES_STATUS.update($('.tab-programming')); - PROGRAMMING_PID.update(PROGRAMMING_PID_STATUS); + FC.LOGIC_CONDITIONS.update(FC.LOGIC_CONDITIONS_STATUS); + FC.GLOBAL_VARIABLES_STATUS.update($('.tab-programming')); + FC.PROGRAMMING_PID.update(FC.PROGRAMMING_PID_STATUS); } } diff --git a/tabs/receiver.js b/tabs/receiver.js index 97386f0a..ce090b04 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -1,7 +1,19 @@ -/*global chrome*/ - 'use strict'; +const path = require('path'); + +const MSPChainerClass = require('./../js/msp/MSPchainer'); +const mspHelper = require('./../js/msp/MSPHelper'); +const mspQueue = require('./../js/serial_queue'); +const mspBalancedInterval = require('./../js/msp_balanced_interval'); +const MSPCodes = require('./../js/msp/MSPCodes'); +const MSP = require('./../js/msp'); +const { GUI, TABS } = require('./../js/gui'); +const FC = require('./../js/fc'); +const CONFIGURATOR = require('./../js/data_storage'); +const Settings = require('./../js/settings'); +const i18n = require('./../js/localization'); + TABS.receiver = { rateChartHeight: 117 }; @@ -29,7 +41,7 @@ TABS.receiver.initialize = function (callback) { loadChainer.execute(); function load_html() { - GUI.load(path.join(__dirname, "tabs/receiver.html"), Settings.processHtml(process_html)); + GUI.load(path.join(__dirname, "receiver.html"), Settings.processHtml(process_html)); } function saveSettings(onComplete) { @@ -106,17 +118,17 @@ TABS.receiver.initialize = function (callback) { $receiverMode.trigger("change"); // fill in data from RC_tuning - $('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2)); - $('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2)); + $('.tunings .throttle input[name="mid"]').val(FC.RC_tuning.throttle_MID.toFixed(2)); + $('.tunings .throttle input[name="expo"]').val(FC.RC_tuning.throttle_EXPO.toFixed(2)); - $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); - $('.tunings .yaw_rate input[name="yaw_expo"]').val(RC_tuning.RC_YAW_EXPO.toFixed(2)); + $('.tunings .rate input[name="expo"]').val(FC.RC_tuning.RC_EXPO.toFixed(2)); + $('.tunings .yaw_rate input[name="yaw_expo"]').val(FC.RC_tuning.RC_YAW_EXPO.toFixed(2)); - $('.tunings .rate input[name="manual_expo"]').val(RC_tuning.manual_RC_EXPO.toFixed(2)); - $('.tunings .yaw_rate input[name="manual_yaw_expo"]').val(RC_tuning.manual_RC_YAW_EXPO.toFixed(2)); + $('.tunings .rate input[name="manual_expo"]').val(FC.RC_tuning.manual_RC_EXPO.toFixed(2)); + $('.tunings .yaw_rate input[name="manual_yaw_expo"]').val(FC.RC_tuning.manual_RC_YAW_EXPO.toFixed(2)); - $('.deadband input[name="yaw_deadband"]').val(RC_deadband.yaw_deadband); - $('.deadband input[name="deadband"]').val(RC_deadband.deadband); + $('.deadband input[name="yaw_deadband"]').val(FC.RC_deadband.yaw_deadband); + $('.deadband input[name="deadband"]').val(FC.RC_deadband.deadband); // generate bars var bar_names = [ @@ -127,7 +139,7 @@ TABS.receiver.initialize = function (callback) { ], bar_container = $('.tab-receiver .bars'); - for (var i = 0; i < RC.active_channels; i++) { + for (var i = 0; i < FC.RC.active_channels; i++) { var name; if (i < bar_names.length) { name = bar_names[i]; @@ -181,8 +193,8 @@ TABS.receiver.initialize = function (callback) { // handle rcmap & rssi aux channel var strBuffer = [], rcMapLetters = FC.getRcMapLetters(); - for (var i = 0; i < RC_MAP.length; i++) { - strBuffer[RC_MAP[i]] = rcMapLetters[i]; + for (var i = 0; i < FC.RC_MAP.length; i++) { + strBuffer[FC.RC_MAP[i]] = rcMapLetters[i]; } // reconstruct @@ -223,11 +235,11 @@ TABS.receiver.initialize = function (callback) { // rssi var rssi_channel_e = $('select[name="rssi_channel"]'); rssi_channel_e.append(''); - for (var i = 5; i < RC.active_channels + 1; i++) { + for (var i = 5; i < FC.RC.active_channels + 1; i++) { rssi_channel_e.append(''); } - $('select[name="rssi_channel"]').val(MISC.rssi_channel); + $('select[name="rssi_channel"]').val(FC.MISC.rssi_channel); var rateHeight = TABS.receiver.rateChartHeight; @@ -281,29 +293,29 @@ TABS.receiver.initialize = function (callback) { $('a.update').on('click', function () { // catch RC_tuning changes - RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); - RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); + FC.RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); + FC.RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); - RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val()); - RC_tuning.RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="yaw_expo"]').val()); + FC.RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val()); + FC.RC_tuning.RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="yaw_expo"]').val()); - RC_tuning.manual_RC_EXPO = parseFloat($('.tunings .rate input[name="manual_expo"]').val()); - RC_tuning.manual_RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="manual_yaw_expo"]').val()); + FC.RC_tuning.manual_RC_EXPO = parseFloat($('.tunings .rate input[name="manual_expo"]').val()); + FC.RC_tuning.manual_RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="manual_yaw_expo"]').val()); - RC_deadband.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val()); - RC_deadband.deadband = parseInt($('.deadband input[name="deadband"]').val()); + FC.RC_deadband.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val()); + FC.RC_deadband.deadband = parseInt($('.deadband input[name="deadband"]').val()); // catch rc map var rcMapValue = $('input[name="rcmap"]').val(); var strBuffer = rcMapValue.split(''); - for (var i = 0; i < RC_MAP.length; i++) { - RC_MAP[i] = strBuffer.indexOf(FC.getRcMapLetters()[i]); + for (var i = 0; i < FC.RC_MAP.length; i++) { + FC.RC_MAP[i] = strBuffer.indexOf(FC.getRcMapLetters()[i]); } // catch rssi aux - MISC.rssi_channel = parseInt($('select[name="rssi_channel"]').val()); + FC.MISC.rssi_channel = parseInt($('select[name="rssi_channel"]').val()); function save_rc_map() { MSP.send_message(MSPCodes.MSP_SET_RX_MAP, mspHelper.crunch(MSPCodes.MSP_SET_RX_MAP), false, save_misc); @@ -338,7 +350,7 @@ TABS.receiver.initialize = function (callback) { }); $("a.sticks").on('click', function () { - var mspWin = window.open("tabs/receiver_msp.html", "receiver_msp", "width=420,height=720,menubar=no,contextIsolation=no,nodeIntegration=yes"); + var mspWin = window.open("tabs/receiver_msp.html", "receiver_msp", "width=420,height=760,menubar=no,contextIsolation=no,nodeIntegration=yes"); mspWin.window.setRawRx = function (channels) { if (CONFIGURATOR.connectionValid && GUI.active_tab != 'cli') { @@ -362,7 +374,7 @@ TABS.receiver.initialize = function (callback) { /* * Throttling */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_ui(); return; } @@ -374,14 +386,14 @@ TABS.receiver.initialize = function (callback) { var i; // update bars with latest data - for (let i = 0; i < RC.active_channels; i++) { - meter_fill_array[i].css('width', ((RC.channels[i] - meter_scale.min) / (meter_scale.max - meter_scale.min) * 100).clamp(0, 100) + '%'); - meter_label_array[i].text(RC.channels[i]); + for (let i = 0; i < FC.RC.active_channels; i++) { + meter_fill_array[i].css('width', ((FC.RC.channels[i] - meter_scale.min) / (meter_scale.max - meter_scale.min) * 100).clamp(0, 100) + '%'); + meter_label_array[i].text(FC.RC.channels[i]); } } - helper.mspBalancedInterval.add('receiver_pull', 35, 1, get_rc_data); + mspBalancedInterval.add('receiver_pull', 35, 1, get_rc_data); GUI.content_ready(callback); } diff --git a/tabs/receiver_msp.html b/tabs/receiver_msp.html index b7d312bb..99c4b92d 100644 --- a/tabs/receiver_msp.html +++ b/tabs/receiver_msp.html @@ -1,7 +1,5 @@ - - diff --git a/tabs/receiver_msp.js b/tabs/receiver_msp.js index d207c3a6..68fc2a0f 100644 --- a/tabs/receiver_msp.js +++ b/tabs/receiver_msp.js @@ -1,7 +1,6 @@ "use strict"; window.$ = window.jQuery = require('jquery'); -//const { i18n } = require('.js/i18n.js'); var CHANNEL_MIN_VALUE = 1000, @@ -121,19 +120,19 @@ function localizeAxisNames() { var gimbal = gimbalElems.get(gimbalIndex); - // $(".gimbal-label-vert", gimbal).text(i18n.getMessage("controlAxis" + gimbals[gimbalIndex][0])); - // $(".gimbal-label-horz", gimbal).text(i18n.getMessage("controlAxis" + gimbals[gimbalIndex][1])); + $(".gimbal-label-vert", gimbal).text(gimbals[gimbalIndex][0]); + $(".gimbal-label-horz", gimbal).text(gimbals[gimbalIndex][1]); } for (var sliderIndex = 0; sliderIndex < 8; sliderIndex++) { - // $(".slider-label", sliderElems.get(sliderIndex)).text(i18n.getMessage("radioChannelShort") + (sliderIndex + 5)); + $(".slider-label", sliderElems.get(sliderIndex)).text("CH " + (sliderIndex + 5)); } } -$(document).ready(function() { +$(function() { $("a.button-enable").on('click', function () { - + var shrinkHeight = $(".warning").height(); $(".warning").slideUp("short", function() { diff --git a/tabs/sensors.js b/tabs/sensors.js index 96901abd..a5358ed2 100644 --- a/tabs/sensors.js +++ b/tabs/sensors.js @@ -1,5 +1,19 @@ 'use strict'; +const path = require('path'); +const Store = require('electron-store'); +const store = new Store(); + +const MSPCodes = require('./../js/msp/MSPCodes'); +const MSP = require('./../js/msp'); +const mspQueue = require('./../js/serial_queue'); +const { GUI, TABS } = require('./../js/gui'); +const FC = require('./../js/fc'); +const CONFIGURATOR = require('./../js/data_storage'); +const interval = require('./../js/intervals'); +const i18n = require('./../js/localization'); +const BitHelper = require('./../js/bitHelper'); + TABS.sensors = {}; TABS.sensors.initialize = function (callback) { var self = this; @@ -10,14 +24,14 @@ TABS.sensors.initialize = function (callback) { function initSensorData(){ for (var i = 0; i < 3; i++) { - SENSOR_DATA.accelerometer[i] = 0; - SENSOR_DATA.gyroscope[i] = 0; - SENSOR_DATA.magnetometer[i] = 0; - SENSOR_DATA.sonar = 0; - SENSOR_DATA.air_speed = 0; - SENSOR_DATA.altitude = 0; - SENSOR_DATA.temperature[i] = 0; - SENSOR_DATA.debug[i] = 0; + FC.SENSOR_DATA.accelerometer[i] = 0; + FC.SENSOR_DATA.gyroscope[i] = 0; + FC.SENSOR_DATA.magnetometer[i] = 0; + FC.SENSOR_DATA.sonar = 0; + FC.SENSOR_DATA.air_speed = 0; + FC.SENSOR_DATA.altitude = 0; + FC.SENSOR_DATA.temperature[i] = 0; + FC.SENSOR_DATA.debug[i] = 0; } } @@ -197,24 +211,24 @@ TABS.sensors.initialize = function (callback) { } } - GUI.load(path.join(__dirname, "tabs/sensors.html"), function load_html() { + GUI.load(path.join(__dirname, "sensors.html"), function load_html() { // translate to user-selected language i18n.localize();; // disable graphs for sensors that are missing var checkboxes = $('.tab-sensors .info .checkboxes input'); - if (!bit_check(CONFIG.activeSensors, 2)) { // mag + if (!BitHelper.bit_check(FC.CONFIG.activeSensors, 2)) { // mag checkboxes.eq(2).prop('disabled', true); } - if (!bit_check(CONFIG.activeSensors, 4)) { // sonar + if (!BitHelper.bit_check(FC.CONFIG.activeSensors, 4)) { // sonar checkboxes.eq(4).prop('disabled', true); } - if (!bit_check(CONFIG.activeSensors, 6)) { // airspeed + if (!BitHelper.bit_check(FC.CONFIG.activeSensors, 6)) { // airspeed checkboxes.eq(5).prop('disabled', true); } - if (!bit_check(CONFIG.activeSensors, 7)) { + if (!BitHelper.bit_check(FC.CONFIG.activeSensors, 7)) { checkboxes.eq(6).prop('disabled', true); } @@ -254,21 +268,21 @@ TABS.sensors.initialize = function (callback) { checkboxes.push($(this).prop('checked')); }); - $('.tab-sensors .rate select:first').trigger('change'); + startPolling(); store.set('graphs_enabled', checkboxes); }); - store.get('graphs_enabled', function (result) { - if (result.graphs_enabled) { - var checkboxes = $('.tab-sensors .info .checkboxes input'); - for (var i = 0; i < result.graphs_enabled.length; i++) { - checkboxes.eq(i).not(':disabled').prop('checked', result.graphs_enabled[i]).trigger('change'); - } - } else { - $('.tab-sensors .info input:lt(4):not(:disabled)').prop('checked', true).trigger('change'); + var graphs_enabled = store.get('graphs_enabled', false); + if (graphs_enabled) { + var checkboxes = $('.tab-sensors .info .checkboxes input'); + for (var i = 0; i < graphs_enabled.length; i++) { + checkboxes.eq(i).not(':disabled').prop('checked', graphs_enabled[i]).trigger('change'); } - }); + } else { + $('.tab-sensors .info input:lt(4):not(:disabled)').prop('checked', true).trigger('change'); + } + // Always start with default/empty sensor data array, clean slate all initSensorData(); @@ -372,14 +386,18 @@ TABS.sensors.initialize = function (callback) { $('.tab-sensors select[name="debug_refresh_rate"]').val(sensor_settings.rates.debug); // start polling data by triggering refresh rate change event - $('.tab-sensors .rate select:first').trigger('change'); + startPolling(); } else { // start polling immediatly (as there is no configuration saved in the storage) - $('.tab-sensors .rate select:first').trigger('change'); + startPolling(); } $('.tab-sensors .rate select, .tab-sensors .scale select').on('change', function () { + startPolling(); + }); + + function startPolling() { // if any of the select fields change value, all of the select values are grabbed // and timers are re-initialized with the new settings var rates = { @@ -419,16 +437,16 @@ TABS.sensors.initialize = function (callback) { }); // timer initialization - helper.interval.killAll(['status_pull', 'global_data_refresh', 'msp-load-update']); + interval.killAll(['status_pull', 'global_data_refresh', 'msp-load-update']); // data pulling timers if (checkboxes[0] || checkboxes[1] || checkboxes[2]) { - helper.interval.add('IMU_pull', function () { + interval.add('IMU_pull', function () { /* * Enable balancer */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_imu_graphs(); return; } @@ -438,12 +456,12 @@ TABS.sensors.initialize = function (callback) { } if (checkboxes[3]) { - helper.interval.add('altitude_pull', function altitude_data_pull() { + interval.add('altitude_pull', function altitude_data_pull() { /* * Enable balancer */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_altitude_graph(); return; } @@ -453,12 +471,12 @@ TABS.sensors.initialize = function (callback) { } if (checkboxes[4]) { - helper.interval.add('sonar_pull', function sonar_data_pull() { + interval.add('sonar_pull', function sonar_data_pull() { /* * Enable balancer */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_sonar_graphs(); return; } @@ -468,12 +486,12 @@ TABS.sensors.initialize = function (callback) { } if (checkboxes[5]) { - helper.interval.add('airspeed_pull', function airspeed_data_pull() { + interval.add('airspeed_pull', function airspeed_data_pull() { /* * Enable balancer */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_airspeed_graphs(); return; } @@ -483,12 +501,12 @@ TABS.sensors.initialize = function (callback) { } if (checkboxes[6]) { - helper.interval.add('temperature_pull', function temperature_data_pull() { + interval.add('temperature_pull', function temperature_data_pull() { /* * Enable balancer */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_temperature_graphs(); return; } @@ -498,12 +516,12 @@ TABS.sensors.initialize = function (callback) { } if (checkboxes[7]) { - helper.interval.add('debug_pull', function debug_data_pull() { + interval.add('debug_pull', function debug_data_pull() { /* * Enable balancer */ - if (helper.mspQueue.shouldDrop()) { + if (mspQueue.shouldDrop()) { update_debug_graphs(); return; } @@ -516,65 +534,65 @@ TABS.sensors.initialize = function (callback) { if (checkboxes[0]) { updateGraphHelperSize(gyroHelpers); - samples_gyro_i = addSampleToData(gyro_data, samples_gyro_i, SENSOR_DATA.gyroscope); + samples_gyro_i = addSampleToData(gyro_data, samples_gyro_i, FC.SENSOR_DATA.gyroscope); drawGraph(gyroHelpers, gyro_data, samples_gyro_i); - raw_data_text_ements.x[0].text(SENSOR_DATA.gyroscope[0].toFixed(2)); - raw_data_text_ements.y[0].text(SENSOR_DATA.gyroscope[1].toFixed(2)); - raw_data_text_ements.z[0].text(SENSOR_DATA.gyroscope[2].toFixed(2)); + raw_data_text_ements.x[0].text(FC.SENSOR_DATA.gyroscope[0].toFixed(2)); + raw_data_text_ements.y[0].text(FC.SENSOR_DATA.gyroscope[1].toFixed(2)); + raw_data_text_ements.z[0].text(FC.SENSOR_DATA.gyroscope[2].toFixed(2)); } if (checkboxes[1]) { updateGraphHelperSize(accelHelpers); - samples_accel_i = addSampleToData(accel_data, samples_accel_i, SENSOR_DATA.accelerometer); + samples_accel_i = addSampleToData(accel_data, samples_accel_i, FC.SENSOR_DATA.accelerometer); drawGraph(accelHelpers, accel_data, samples_accel_i); - raw_data_text_ements.x[1].text(SENSOR_DATA.accelerometer[0].toFixed(2)); - raw_data_text_ements.y[1].text(SENSOR_DATA.accelerometer[1].toFixed(2)); - raw_data_text_ements.z[1].text(SENSOR_DATA.accelerometer[2].toFixed(2)); + raw_data_text_ements.x[1].text(FC.SENSOR_DATA.accelerometer[0].toFixed(2)); + raw_data_text_ements.y[1].text(FC.SENSOR_DATA.accelerometer[1].toFixed(2)); + raw_data_text_ements.z[1].text(FC.SENSOR_DATA.accelerometer[2].toFixed(2)); } if (checkboxes[2]) { updateGraphHelperSize(magHelpers); - samples_mag_i = addSampleToData(mag_data, samples_mag_i, SENSOR_DATA.magnetometer); + samples_mag_i = addSampleToData(mag_data, samples_mag_i, FC.SENSOR_DATA.magnetometer); drawGraph(magHelpers, mag_data, samples_mag_i); - raw_data_text_ements.x[2].text(SENSOR_DATA.magnetometer[0].toFixed(2)); - raw_data_text_ements.y[2].text(SENSOR_DATA.magnetometer[1].toFixed(2)); - raw_data_text_ements.z[2].text(SENSOR_DATA.magnetometer[2].toFixed(2)); + raw_data_text_ements.x[2].text(FC.SENSOR_DATA.magnetometer[0].toFixed(2)); + raw_data_text_ements.y[2].text(FC.SENSOR_DATA.magnetometer[1].toFixed(2)); + raw_data_text_ements.z[2].text(FC.SENSOR_DATA.magnetometer[2].toFixed(2)); } } function update_altitude_graph() { updateGraphHelperSize(altitudeHelpers); - samples_altitude_i = addSampleToData(altitude_data, samples_altitude_i, [SENSOR_DATA.altitude, SENSOR_DATA.barometer]); + samples_altitude_i = addSampleToData(altitude_data, samples_altitude_i, [FC.SENSOR_DATA.altitude, FC.SENSOR_DATA.barometer]); drawGraph(altitudeHelpers, altitude_data, samples_altitude_i); - raw_data_text_ements.x[3].text(SENSOR_DATA.altitude.toFixed(2)); - raw_data_text_ements.y[3].text(SENSOR_DATA.barometer.toFixed(2)); + raw_data_text_ements.x[3].text(FC.SENSOR_DATA.altitude.toFixed(2)); + raw_data_text_ements.y[3].text(FC.SENSOR_DATA.barometer.toFixed(2)); } function update_sonar_graphs() { updateGraphHelperSize(sonarHelpers); - samples_sonar_i = addSampleToData(sonar_data, samples_sonar_i, [SENSOR_DATA.sonar]); + samples_sonar_i = addSampleToData(sonar_data, samples_sonar_i, [FC.SENSOR_DATA.sonar]); drawGraph(sonarHelpers, sonar_data, samples_sonar_i); - raw_data_text_ements.x[4].text(SENSOR_DATA.sonar.toFixed(2)); + raw_data_text_ements.x[4].text(FC.SENSOR_DATA.sonar.toFixed(2)); } function update_airspeed_graphs() { updateGraphHelperSize(airspeedHelpers); - samples_airspeed_i = addSampleToData(airspeed_data, samples_airspeed_i, [SENSOR_DATA.air_speed]); + samples_airspeed_i = addSampleToData(airspeed_data, samples_airspeed_i, [FC.SENSOR_DATA.air_speed]); drawGraph(airspeedHelpers, airspeed_data, samples_airspeed_i); - raw_data_text_ements.x[5].text(SENSOR_DATA.air_speed); + raw_data_text_ements.x[5].text(FC.SENSOR_DATA.air_speed); } function update_temperature_graphs() { for (var i = 0; i < 8; i++) { updateGraphHelperSize(temperatureHelpers[i]); - addSampleToData(temperature_data[i], samples_temperature_i, [SENSOR_DATA.temperature[i]]); + addSampleToData(temperature_data[i], samples_temperature_i, [FC.SENSOR_DATA.temperature[i]]); drawGraph(temperatureHelpers[i], temperature_data[i], samples_temperature_i); - raw_data_text_ements.x[6 + i].text(SENSOR_DATA.temperature[i]); + raw_data_text_ements.x[6 + i].text(FC.SENSOR_DATA.temperature[i]); } samples_temperature_i++; } @@ -583,34 +601,19 @@ TABS.sensors.initialize = function (callback) { for (var i = 0; i < 8; i++) { updateGraphHelperSize(debugHelpers[i]); - addSampleToData(debug_data[i], samples_debug_i, [SENSOR_DATA.debug[i]]); + addSampleToData(debug_data[i], samples_debug_i, [FC.SENSOR_DATA.debug[i]]); drawGraph(debugHelpers[i], debug_data[i], samples_debug_i); - raw_data_text_ements.x[6 + 8 + i].text(SENSOR_DATA.debug[i]); + raw_data_text_ements.x[6 + 8 + i].text(FC.SENSOR_DATA.debug[i]); } samples_debug_i++; } - }); + } $("a.debug-trace").on('click', function () { - var windowWidth = 500; - var windowHeight = 510; - - window.open("/tabs/debug_trace.html", { - id: "debug_trace", - innerBounds: { - minWidth: windowWidth, minHeight: windowHeight, - width: windowWidth, height: windowHeight, - }, - alwaysOnTop: true - }, function (createdWindow) { - createdWindow.contentWindow.getDebugTrace = function () { return DEBUG_TRACE || ''; }; - return true; - }); - return false; + var debugWin = window.open("tabs/debug_trace.html", "receiver_msp", "width=500,height=510,menubar=no,contextIsolation=no,nodeIntegration=yes"); + debugWin.window.getDebugTrace = function () { return FC.DEBUG_TRACE || ''; }; }); - - GUI.content_ready(callback); }); }; diff --git a/tabs/setup.js b/tabs/setup.js index b355b9a4..f8a56199 100755 --- a/tabs/setup.js +++ b/tabs/setup.js @@ -13,7 +13,6 @@ const mspBalancedInterval = require('./../js/msp_balanced_interval'); const interval = require('./../js/intervals'); const mspQueue = require('./../js/serial_queue'); const SerialBackend = require('./../js/serial_backend'); - const { mixer } = require('./../js/model'); const BitHelper = require('./../js/bitHelper') @@ -255,7 +254,7 @@ TABS.setup.initialize3D = function () { if (useWebGlRenderer) { if (FC.MIXER_CONFIG.appliedMixerPreset === -1) { model_file = 'custom'; - GUI_control.prototype.log("" + i18n.getMessage("mixerNotConfigured") + ""); + GUI.log("" + i18n.getMessage("mixerNotConfigured") + ""); } else { model_file = mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).model; } |