From fb84fefac6926ba831e9a48c3e5dfaa4fe8e5d1d Mon Sep 17 00:00:00 2001 From: Peter Prince Date: Mon, 10 Jan 2022 11:48:29 +0000 Subject: [PATCH] Add 1.6.0 changes --- about.html | 1 + about.js | 16 ++ constants.js | 9 +- expansion/expansion.html | 10 +- expansion/split.html | 8 +- expansion/uiCommon.js | 10 +- expansion/uiExpansion.js | 15 +- expansion/uiSplit.js | 4 +- index.html | 20 +-- lifeDisplay.js | 30 +++- main.js | 37 ++++ package.json | 2 +- packetReader.js | 31 +++- saveLoad.js | 347 +++++++++++++++++++++++++++++--------- schedule/dateInput.js | 3 +- schedule/timeInput.js | 30 ++-- schedule/uiSchedule.js | 56 +++--- settings/advanced.html | 29 ++++ settings/durationInput.js | 9 +- settings/filtering.html | 62 +++---- settings/uiAdvanced.js | 71 ++++++++ settings/uiFiltering.js | 111 ++++++------ settings/uiSettings.js | 19 ++- ui.css | 27 +-- ui.js | 19 +-- uiIndex.js | 157 ++++++++++------- uiNight.css | 18 +- 27 files changed, 797 insertions(+), 354 deletions(-) diff --git a/about.html b/about.html index 6e21e64..494bda6 100644 --- a/about.html +++ b/about.html @@ -3,6 +3,7 @@ + About AudioMoth Configuration App diff --git a/about.js b/about.js index 5519038..94c1f64 100644 --- a/about.js +++ b/about.js @@ -11,6 +11,8 @@ const electron = require('electron'); const audiomoth = require('audiomoth-hid'); +const nightMode = require('./nightMode.js'); + const versionDisplay = document.getElementById('version-display'); const electronVersionDisplay = document.getElementById('electron-version-display'); const audiomothHidVersionDisplay = document.getElementById('audiomoth-hid-version-display'); @@ -20,6 +22,20 @@ versionDisplay.textContent = 'Version ' + electron.remote.app.getVersion(); electronVersionDisplay.textContent = 'Running on Electron version ' + electron.remote.process.versions.electron; audiomothHidVersionDisplay.textContent = 'AudioMoth-HID module ' + audiomoth.version; +electron.ipcRenderer.on('night-mode', (e, nm) => { + + if (nm !== undefined) { + + nightMode.setNightMode(nm); + + } else { + + nightMode.toggle(); + + } + +}); + websiteLink.addEventListener('click', function () { electron.shell.openExternal('https://openacousticdevices.info'); diff --git a/constants.js b/constants.js index af0d86c..fabd158 100644 --- a/constants.js +++ b/constants.js @@ -122,6 +122,11 @@ exports.oldConfigurations = [{ sampleRateDivider: 4 }]; +/* GPS energy consumption */ + +exports.GPS_FIX_TIME = 1.0 / 60.0; +exports.GPS_FIX_CONSUMPTION = 30.0; + /* Packet lengths for each version */ exports.packetLengthVersions = [{ @@ -191,5 +196,5 @@ exports.getFirmwareClassification = (desc) => { /* Version number for the latest firmware */ -exports.latestFirmwareVersionArray = [1, 6, 0]; -exports.latestFirmwareVersionString = '1.6.0'; +exports.latestFirmwareVersionArray = [1, 7, 0]; +exports.latestFirmwareVersionString = '1.7.0'; diff --git a/expansion/expansion.html b/expansion/expansion.html index 95827fb..b785153 100644 --- a/expansion/expansion.html +++ b/expansion/expansion.html @@ -59,7 +59,7 @@ - Maximum file length: + Maximum file length: @@ -137,7 +137,7 @@ - Maximum file length: + Maximum file length: @@ -207,12 +207,12 @@
- +
- +
@@ -232,7 +232,7 @@
- Writing WAV files to source folder. + Writing WAV files to source folder.
diff --git a/expansion/split.html b/expansion/split.html index bc875cb..91d2c48 100644 --- a/expansion/split.html +++ b/expansion/split.html @@ -79,12 +79,12 @@
- +
- +
@@ -104,7 +104,7 @@
- Writing WAV files to source folder. + Writing WAV files to source folder.
@@ -156,7 +156,7 @@
- No AudioMoth WAV files selected. + No AudioMoth WAV files selected.
diff --git a/expansion/uiCommon.js b/expansion/uiCommon.js index 04d35eb..b6f2442 100644 --- a/expansion/uiCommon.js +++ b/expansion/uiCommon.js @@ -164,7 +164,7 @@ prefixInput.addEventListener('keydown', (e) => { } - var reg = /[^A-Za-z_0-9]{1}/g; + var reg = /[^A-Za-z-_0-9]{1}/g; if (reg.test(e.key)) { @@ -206,14 +206,14 @@ prefixCheckbox.addEventListener('change', () => { if (prefixCheckbox.checked) { - prefixLabel.style.color = ''; - prefixInput.style.color = ''; + prefixLabel.classList.remove('grey'); + prefixInput.classList.remove('grey'); prefixInput.disabled = false; } else { - prefixLabel.style.color = 'lightgray'; - prefixInput.style.color = 'lightgray'; + prefixLabel.classList.add('grey'); + prefixInput.classList.add('grey'); prefixInput.disabled = true; } diff --git a/expansion/uiExpansion.js b/expansion/uiExpansion.js index 1689220..7a4edce 100644 --- a/expansion/uiExpansion.js +++ b/expansion/uiExpansion.js @@ -149,7 +149,16 @@ function updateFileMaxLengthUI (elementClass, checkbox) { for (let i = 0; i < maxLengthElements.length; i++) { maxLengthElements[i].disabled = !maxLengthEnabled; - maxLengthElements[i].style.color = maxLengthEnabled ? '' : 'lightgrey'; + + if (maxLengthEnabled) { + + maxLengthElements[i].classList.remove('grey'); + + } else { + + maxLengthElements[i].classList.add('grey'); + + } } @@ -473,12 +482,12 @@ outputCheckbox.addEventListener('change', () => { if (outputCheckbox.checked) { - outputLabel.style.color = ''; + outputLabel.classList.remove('grey'); outputButton.disabled = false; } else { - outputLabel.style.color = 'lightgray'; + outputLabel.classList.add('grey'); outputButton.disabled = true; outputDir = ''; ui.updateOutputLabel(outputDir); diff --git a/expansion/uiSplit.js b/expansion/uiSplit.js index 5c587f9..00158db 100644 --- a/expansion/uiSplit.js +++ b/expansion/uiSplit.js @@ -250,12 +250,12 @@ outputCheckbox.addEventListener('change', () => { if (outputCheckbox.checked) { - outputLabel.style.color = ''; + outputLabel.classList.remove('grey'); outputButton.disabled = false; } else { - outputLabel.style.color = 'lightgray'; + outputLabel.classList.add('grey'); outputButton.disabled = true; outputDir = ''; ui.updateOutputLabel(outputDir); diff --git a/index.html b/index.html index 5d84a9d..bf7fd5b 100644 --- a/index.html +++ b/index.html @@ -16,8 +16,8 @@
-
-
+
+
@@ -28,34 +28,34 @@
- Device ID: + Device ID:
- - + -
- Firmware description: + Firmware description:
- - + -
- Firmware version: + Firmware version:
- - + -
- Battery: + Battery:
- - + -
diff --git a/lifeDisplay.js b/lifeDisplay.js index 806e4f5..3d57ebb 100644 --- a/lifeDisplay.js +++ b/lifeDisplay.js @@ -6,6 +6,8 @@ 'use strict'; +const constants = require('./constants.js'); + /* global document */ const MAX_WAV_SIZE = 4294966806; @@ -143,7 +145,7 @@ function getFileSize (sampleRate, sampleRateDivider, secs) { /* Update storage and energy usage values in life display box */ -exports.updateLifeDisplay = (schedule, configuration, recLength, sleepLength, amplitudeThresholdingEnabled, dutyEnabled, energySaverChecked) => { +exports.updateLifeDisplay = (schedule, configuration, recLength, sleepLength, amplitudeThresholdingEnabled, dutyEnabled, energySaverChecked, gpsEnabled) => { /* If no recording periods exist, do not perform energy calculations */ @@ -334,6 +336,14 @@ exports.updateLifeDisplay = (schedule, configuration, recLength, sleepLength, am const sleepEnergyUsage = totalSleepTime * sleepCurrent / 3600; + let gpsEnergyUsage = 0.0; + + if (gpsEnabled) { + + gpsEnergyUsage = schedule.length * constants.GPS_FIX_TIME * constants.GPS_FIX_CONSUMPTION; + + } + if (amplitudeThresholdingEnabled) { let minEnergyUsed = 0; @@ -348,6 +358,12 @@ exports.updateLifeDisplay = (schedule, configuration, recLength, sleepLength, am minEnergyUsed = Math.round(minEnergyUsed / minEnergyPrecision) * minEnergyPrecision; + // Add GPS energy after rounding so it's clear what the effect of the GPS on energy consumption is + + minEnergyUsed += gpsEnergyUsage; + + minEnergyUsed = Math.round(minEnergyUsed); + let maxEnergyUsed = 0; maxEnergyUsed += fileOpenEnergyUsage; @@ -360,6 +376,12 @@ exports.updateLifeDisplay = (schedule, configuration, recLength, sleepLength, am maxEnergyUsed = Math.round(maxEnergyUsed / maxEnergyPrecision) * maxEnergyPrecision; + // Add GPS energy after rounding so it's clear what the effect of the GPS on energy consumption is + + maxEnergyUsed += gpsEnergyUsage; + + maxEnergyUsed = Math.round(maxEnergyUsed); + text += 'Daily energy consumption will be between ' + minEnergyUsed + ' and ' + maxEnergyUsed + ' mAh.'; } else { @@ -376,6 +398,12 @@ exports.updateLifeDisplay = (schedule, configuration, recLength, sleepLength, am energyUsed = Math.round(energyUsed / energyPrecision) * energyPrecision; + // Add GPS energy after rounding so it's clear what the effect of the GPS on energy consumption is + + energyUsed += gpsEnergyUsage; + + energyUsed = Math.round(energyUsed); + text += 'Daily energy consumption will be approximately ' + energyUsed + ' mAh.'; } diff --git a/main.js b/main.js index e2e7c48..b6a1a11 100644 --- a/main.js +++ b/main.js @@ -193,6 +193,22 @@ function openAboutWindow () { }); + aboutWindow.webContents.on('dom-ready', function () { + + mainWindow.webContents.send('poll-night-mode'); + + }); + + ipcMain.on('night-mode-poll-reply', (e, nightMode) => { + + if (aboutWindow) { + + aboutWindow.webContents.send('night-mode', nightMode); + + } + + }); + } function toggleNightMode () { @@ -205,6 +221,18 @@ function toggleNightMode () { } + if (aboutWindow) { + + aboutWindow.webContents.send('night-mode'); + + } + + if (splitWindow) { + + splitWindow.webContents.send('night-mode'); + + } + } app.on('ready', function () { @@ -383,6 +411,15 @@ app.on('ready', function () { mainWindow.webContents.send('update-check'); + } + }, { + type: 'separator' + }, { + label: 'AudioMoth Filter Playground', + click: function () { + + shell.openExternal('https://playground.openacousticdevices.info/'); + } }, { type: 'separator' diff --git a/package.json b/package.json index 2eb1b79..b2f5061 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "AudioMoth-Config", - "version": "1.5.1", + "version": "1.6.0", "description": "The configuration app for the AudioMoth acoustic monitoring device.", "main": "main.js", "author": "openacousticdevices.info", diff --git a/packetReader.js b/packetReader.js index 5677101..218f2e6 100644 --- a/packetReader.js +++ b/packetReader.js @@ -69,7 +69,7 @@ typedef struct { typedef struct { uint32_t time; - uint8_t gain; + AM_gainSetting_t gain; uint8_t clockDivider; uint8_t acquisitionCycles; uint8_t oversampleRate; @@ -90,14 +90,19 @@ typedef struct { uint16_t lowerFilterFreq; uint16_t higherFilterFreq; uint16_t amplitudeThreshold; - uint8_t requireAcousticConfiguration; - AM_batteryLevelDisplayType_t batteryLevelDisplayType; - uint8_t minimumAmplitudeThresholdDuration; + uint8_t requireAcousticConfiguration : 1; + AM_batteryLevelDisplayType_t batteryLevelDisplayType : 1; + uint8_t minimumTriggerDuration : 6; uint8_t enableAmplitudeThresholdDecibelScale : 1; - uint8_t amplitudeThresholdDecibels : 7; + uint8_t amplitudeThresholdDecibels : 7; uint8_t enableAmplitudeThresholdPercentageScale : 1; - uint8_t amplitudeThresholdPercentageMantissa : 4; - int8_t amplitudeThresholdPercentageExponent : 3; + uint8_t amplitudeThresholdPercentageMantissa : 4; + int8_t amplitudeThresholdPercentageExponent : 3; + uint8_t enableEnergySaverMode : 1; + uint8_t disable48HzDCBlockingFilter : 1; + uint8_t enableTimeSettingFromGPS : 1; + uint8_t enableMagneticSwitch : 1; + uint8_t enableLowGainRange : 1; } configSettings_t; */ @@ -212,6 +217,12 @@ exports.read = (packet) => { const disable48DCFilter = (packedByte3 >> 1) & 1; + const timeSettingFromGPSEnabled = (packedByte3 >> 2) & 1; + + const magneticSwitchEnabled = (packedByte3 >> 3) & 1; + + const lowGainRangeEnabled = (packedByte3 >> 4) & 1; + /* Display configuration */ console.log('Current time: ', formatDate(time)); @@ -277,4 +288,10 @@ exports.read = (packet) => { console.log('48 Hz DC blocking filter disabled:', disable48DCFilter === 1); + console.log('GPS clock setting enabled:', timeSettingFromGPSEnabled === 1); + + console.log('Magnetic switch delay enabled:', magneticSwitchEnabled === 1); + + console.log('Low gain range enabled: ', lowGainRangeEnabled === 1); + }; diff --git a/saveLoad.js b/saveLoad.js index 00916b7..4401f4d 100644 --- a/saveLoad.js +++ b/saveLoad.js @@ -15,36 +15,45 @@ const Validator = require('jsonschema').Validator; const constants = require('./constants.js'); -const defaultSettings = { +const DEFAULT_SETTINGS = { + timePeriods: [], + ledEnabled: true, + lowVoltageCutoffEnabled: true, + batteryLevelCheckEnabled: true, sampleRate: 48000, gain: 2, - dutyEnabled: true, recordDuration: 55, sleepDuration: 5, + localTime: false, + firstRecordingDateEnabled: false, + lastRecordingDateEnabled: false, + dutyEnabled: true, passFiltersEnabled: false, - filterTypeIndex: 1, - lowerFilter: 0, - higherFilter: 24000, + filterType: 'band', + lowerFilter: 6000, + higherFilter: 18000, amplitudeThresholdingEnabled: false, - amplitudeThreshold: 0, + amplitudeThreshold: 0.001, requireAcousticConfig: false, displayVoltageRange: false, minimumAmplitudeThresholdDuration: 0, - amplitudeThresholdingScaleIndex: 0, + amplitudeThresholdingScale: 'percentage', energySaverModeEnabled: false, - disable48DCFilter: false + lowGainRangeEnabled: false, + disable48DCFilter: false, + timeSettingFromGPSEnabled: false, + magneticSwitchEnabled: false }; -exports.defaultSettings = defaultSettings; /* Save configuration settings in UI to .config file */ -function saveConfiguration (timePeriods, ledEnabled, lowVoltageCutoffEnabled, batteryLevelCheckEnabled, sampleRateIndex, gain, recordDuration, sleepDuration, localTime, firstRecordingDate, lastRecordingDate, dutyEnabled, passFiltersEnabled, filterTypeIndex, lowerFilter, higherFilter, amplitudeThresholdingEnabled, amplitudeThreshold, requireAcousticConfig, displayVoltageRange, minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex, energySaverModeEnabled, disable48DCFilter, callback) { +function saveConfiguration (currentConfig, callback) { - const sampleRate = constants.configurations[sampleRateIndex].trueSampleRate * 1000; + const sampleRate = constants.configurations[currentConfig.sampleRateIndex].trueSampleRate * 1000; let filterType; - switch (filterTypeIndex) { + switch (currentConfig.filterTypeIndex) { case 0: filterType = 'low'; @@ -60,7 +69,7 @@ function saveConfiguration (timePeriods, ledEnabled, lowVoltageCutoffEnabled, ba let amplitudeThresholdingScale; - switch (amplitudeThresholdingScaleIndex) { + switch (currentConfig.amplitudeThresholdingScaleIndex) { case 0: amplitudeThresholdingScale = 'percentage'; @@ -77,33 +86,39 @@ function saveConfiguration (timePeriods, ledEnabled, lowVoltageCutoffEnabled, ba const versionString = electron.remote.app.getVersion(); let configuration = '{\n'; - configuration += '"timePeriods": ' + JSON.stringify(timePeriods) + ',\n'; - configuration += '"ledEnabled": ' + ledEnabled + ',\n'; - configuration += '"lowVoltageCutoffEnabled": ' + lowVoltageCutoffEnabled + ',\n'; - configuration += '"batteryLevelCheckEnabled": ' + batteryLevelCheckEnabled + ',\n'; + configuration += '"timePeriods": ' + JSON.stringify(currentConfig.timePeriods) + ',\n'; + configuration += '"ledEnabled": ' + currentConfig.ledEnabled + ',\n'; + configuration += '"lowVoltageCutoffEnabled": ' + currentConfig.lowVoltageCutoffEnabled + ',\n'; + configuration += '"batteryLevelCheckEnabled": ' + currentConfig.batteryLevelCheckEnabled + ',\n'; configuration += '"sampleRate": ' + sampleRate + ',\n'; - configuration += '"gain": ' + gain + ',\n'; - configuration += '"recordDuration": ' + recordDuration + ',\n'; - configuration += '"sleepDuration": ' + sleepDuration + ',\n'; - configuration += '"localTime": ' + localTime + ',\n'; + configuration += '"gain": ' + currentConfig.gain + ',\n'; + configuration += '"recordDuration": ' + currentConfig.recordDuration + ',\n'; + configuration += '"sleepDuration": ' + currentConfig.sleepDuration + ',\n'; + configuration += '"localTime": ' + currentConfig.localTime + ',\n'; + + configuration += '"firstRecordingDateEnabled": ' + currentConfig.firstRecordingDateEnabled + ',\n'; + configuration += '"lastRecordingDateEnabled": ' + currentConfig.lastRecordingDateEnabled + ',\n'; - configuration += (firstRecordingDate !== '') ? '"firstRecordingDate": \"' + firstRecordingDate + '\",\n' : ''; - configuration += (lastRecordingDate !== '') ? '"lastRecordingDate": \"' + lastRecordingDate + '\",\n' : ''; + configuration += currentConfig.firstRecordingDateEnabled ? '"firstRecordingDate": \"' + currentConfig.firstRecordingDate + '\",\n' : ''; + configuration += currentConfig.lastRecordingDateEnabled ? '"lastRecordingDate": \"' + currentConfig.lastRecordingDate + '\",\n' : ''; - configuration += '"dutyEnabled": ' + dutyEnabled + ',\n'; - configuration += '"passFiltersEnabled": ' + passFiltersEnabled + ',\n'; + configuration += '"dutyEnabled": ' + currentConfig.dutyEnabled + ',\n'; + configuration += '"passFiltersEnabled": ' + currentConfig.passFiltersEnabled + ',\n'; configuration += '"filterType": \"' + filterType + '\",\n'; - configuration += '"lowerFilter": ' + lowerFilter + ',\n'; - configuration += '"higherFilter": ' + higherFilter + ',\n'; - configuration += '"amplitudeThresholdingEnabled": ' + amplitudeThresholdingEnabled + ',\n'; - configuration += '"amplitudeThreshold": ' + amplitudeThreshold + ',\n'; - configuration += '"requireAcousticConfig": ' + requireAcousticConfig + ',\n'; - configuration += '"displayVoltageRange": ' + displayVoltageRange + ',\n'; - configuration += '"minimumAmplitudeThresholdDuration": ' + minimumAmplitudeThresholdDuration + ',\n'; + configuration += '"lowerFilter": ' + currentConfig.lowerFilter + ',\n'; + configuration += '"higherFilter": ' + currentConfig.higherFilter + ',\n'; + configuration += '"amplitudeThresholdingEnabled": ' + currentConfig.amplitudeThresholdingEnabled + ',\n'; + configuration += '"amplitudeThreshold": ' + currentConfig.amplitudeThreshold + ',\n'; + configuration += '"requireAcousticConfig": ' + currentConfig.requireAcousticConfig + ',\n'; + configuration += '"displayVoltageRange": ' + currentConfig.displayVoltageRange + ',\n'; + configuration += '"minimumAmplitudeThresholdDuration": ' + currentConfig.minimumAmplitudeThresholdDuration + ',\n'; configuration += '"amplitudeThresholdingScale": \"' + amplitudeThresholdingScale + '\",\n'; configuration += '"version": \"' + versionString + '\",\n'; - configuration += '"energySaverModeEnabled": ' + energySaverModeEnabled + ',\n'; - configuration += '"disable48DCFilter": ' + disable48DCFilter + '\n'; + configuration += '"energySaverModeEnabled": ' + currentConfig.energySaverModeEnabled + ',\n'; + configuration += '"disable48DCFilter": ' + currentConfig.disable48DCFilter + ',\n'; + configuration += '"lowGainRangeEnabled": ' + currentConfig.lowGainRangeEnabled + ',\n'; + configuration += '"timeSettingFromGPSEnabled": ' + currentConfig.timeSettingFromGPSEnabled + ',\n'; + configuration += '"magneticSwitchEnabled": ' + currentConfig.magneticSwitchEnabled + '\n'; configuration += '}'; const fileName = dialog.showSaveDialogSync({ @@ -128,18 +143,26 @@ exports.saveConfiguration = saveConfiguration; /* Newer save files save the sample rate itself rather than the index, handle that by detecting empty JSON objects */ -function getSampleRateIndex (jsonSampleRateIndex, jsonSampleRate) { +function getSampleRateIndex (jsonSampleRateIndex, jsonSampleRate, replacementSampleRate) { if (typeof jsonSampleRateIndex === 'undefined') { - jsonSampleRate /= 1000; + let sampleRate = jsonSampleRate; + + if (typeof jsonSampleRate === 'undefined') { + + sampleRate = replacementSampleRate; + + } + + sampleRate /= 1000; let minDistance = -1; let closestIndex = 0; for (let i = 0; i < constants.configurations.length; i++) { - const distance = Math.abs(constants.configurations[i].trueSampleRate - jsonSampleRate); + const distance = Math.abs(constants.configurations[i].trueSampleRate - sampleRate); if (minDistance === -1 || distance < minDistance) { @@ -162,7 +185,7 @@ function getSampleRateIndex (jsonSampleRateIndex, jsonSampleRate) { /* Take data obtained from a loaded .config file and duplicate settings in the UI */ -function useLoadedConfiguration (err, data, callback) { +function useLoadedConfiguration (err, currentConfig, data, callback) { if (err) { @@ -236,9 +259,15 @@ function useLoadedConfiguration (err, data, callback) { localTime: { type: 'boolean' }, + firstRecordingDateEnabled: { + type: 'boolean' + }, firstRecordingDate: { type: 'string' }, + lastRecordingDateEnabled: { + type: 'boolean' + }, lastRecordingDate: { type: 'string' }, @@ -283,9 +312,18 @@ function useLoadedConfiguration (err, data, callback) { }, disable48DCFilter: { type: 'boolean' + }, + lowGainRangeEnabled: { + type: 'boolean' + }, + timeSettingFromGPSEnabled: { + type: 'boolean' + }, + magneticSwitchEnabled: { + type: 'boolean' } }, - required: ['timePeriods', 'ledEnabled', 'sleepDuration'] + required: [] }; try { @@ -301,79 +339,218 @@ function useLoadedConfiguration (err, data, callback) { console.log(jsonObj); - const timePeriods = jsonObj.timePeriods; + /* Values to use if a setting is missing */ + + let replacementValues = DEFAULT_SETTINGS; + replacementValues.timePeriods = []; + + let isMissingValues = (typeof jsonObj.timePeriods === 'undefined'); + isMissingValues |= (typeof jsonObj.ledEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.lowVoltageCutoffEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.batteryLevelCheckEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.gain === 'undefined'); + isMissingValues |= (typeof jsonObj.dutyEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.sleepDuration === 'undefined'); + isMissingValues |= (typeof jsonObj.recordDuration === 'undefined'); + isMissingValues |= (typeof jsonObj.localTime === 'undefined'); + isMissingValues |= (typeof jsonObj.passFiltersEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.filterType === 'undefined'); + isMissingValues |= (typeof jsonObj.lowerFilter === 'undefined'); + isMissingValues |= (typeof jsonObj.higherFilter === 'undefined'); + isMissingValues |= (typeof jsonObj.amplitudeThresholdingEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.amplitudeThreshold === 'undefined'); + isMissingValues |= (typeof jsonObj.requireAcousticConfig === 'undefined'); + isMissingValues |= (typeof jsonObj.displayVoltageRange === 'undefined'); + isMissingValues |= (typeof jsonObj.minimumAmplitudeThresholdDuration === 'undefined'); + isMissingValues |= (typeof jsonObj.amplitudeThresholdingScale === 'undefined'); + isMissingValues |= (typeof jsonObj.energySaverModeEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.disable48DCFilter === 'undefined'); + isMissingValues |= (typeof jsonObj.lowGainRangeEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.timeSettingFromGPSEnabled === 'undefined'); + isMissingValues |= (typeof jsonObj.magneticSwitchEnabled === 'undefined'); + + if (isMissingValues) { + + const buttonIndex = dialog.showMessageBoxSync({ + type: 'warning', + buttons: ['Keep Current Settings', 'Set to Default'], + title: 'Configuration file with missing settings loaded', + message: 'This configuration file contains a subset of the full settings. Missing settings can either be set to their default values or keep their current values.', + cancelId: -1 + }); + + if (buttonIndex === 0) { + + replacementValues = currentConfig; + + } else if (buttonIndex === -1) { + + console.log('Cancelled opening configuration file'); + return; - const ledEnabled = jsonObj.ledEnabled; - const lowVoltageCutoffEnabled = (typeof jsonObj.lowVoltageCutoffEnabled === 'undefined') ? jsonObj.batteryCheckEnabled : jsonObj.lowVoltageCutoffEnabled; - const batteryLevelCheckEnabled = jsonObj.batteryLevelCheckEnabled; + } + + } - const sampleRateIndex = getSampleRateIndex(jsonObj.sampleRateIndex, jsonObj.sampleRate); + const timePeriods = (typeof jsonObj.timePeriods === 'undefined') ? replacementValues.timePeriods : jsonObj.timePeriods; - const gain = (typeof jsonObj.gain === 'undefined') ? jsonObj.gainIndex : jsonObj.gain; + const ledEnabled = (typeof jsonObj.ledEnabled === 'undefined') ? replacementValues.ledEnabled : jsonObj.ledEnabled; - const dutyEnabled = (typeof jsonObj.dutyEnabled === 'undefined') ? true : jsonObj.dutyEnabled; + let lowVoltageCutoffEnabled = (typeof jsonObj.lowVoltageCutoffEnabled === 'undefined') ? jsonObj.batteryCheckEnabled : jsonObj.lowVoltageCutoffEnabled; + lowVoltageCutoffEnabled = (typeof lowVoltageCutoffEnabled === 'undefined') ? replacementValues.lowVoltageCutoffEnabled : lowVoltageCutoffEnabled; - let sleepDuration, recordDuration; + const batteryLevelCheckEnabled = (typeof jsonObj.batteryLevelCheckEnabled === 'undefined') ? replacementValues.batteryLevelCheckEnabled : jsonObj.batteryLevelCheckEnabled; - if (dutyEnabled) { + const sampleRateIndex = getSampleRateIndex(jsonObj.sampleRateIndex, jsonObj.sampleRate, replacementValues.sampleRate); - sleepDuration = jsonObj.sleepDuration; - recordDuration = (typeof jsonObj.recordDuration === 'undefined') ? jsonObj.recDuration : jsonObj.recordDuration; + /* If gain is undefined, it's either missing and should be replaced, or using the old gainIndex name */ + + let gain = (typeof jsonObj.gain === 'undefined') ? jsonObj.gainIndex : jsonObj.gain; + gain = (typeof gain === 'undefined') ? replacementValues.gain : gain; + + const dutyEnabled = (typeof jsonObj.dutyEnabled === 'undefined') ? replacementValues.dutyEnabled : jsonObj.dutyEnabled; + + const sleepDuration = (typeof jsonObj.sleepDuration === 'undefined') ? replacementValues.sleepDuration : jsonObj.sleepDuration; + + let recordDuration = (typeof jsonObj.recordDuration === 'undefined') ? jsonObj.recDuration : jsonObj.recordDuration; + recordDuration = (typeof recordDuration === 'undefined') ? replacementValues.recordDuration : recordDuration; + + const localTime = (typeof jsonObj.localTime === 'undefined') ? replacementValues.localTime : jsonObj.localTime; + + let firstRecordingDateEnabled; + + // In older versions of the app, whether or not the first/last date is enabled was specified in the save file by just the presence of the date + + if (typeof jsonObj.firstRecordingDateEnabled === 'undefined') { + + if (typeof jsonObj.firstRecordingDate === 'undefined') { + + firstRecordingDateEnabled = false; + + } else { + + firstRecordingDateEnabled = true; + + } } else { - sleepDuration = 0; - recordDuration = 1; + firstRecordingDateEnabled = jsonObj.firstRecordingDateEnabled; } - const localTime = jsonObj.localTime; - const firstRecordingDate = (typeof jsonObj.firstRecordingDate === 'undefined') ? '' : jsonObj.firstRecordingDate; - const lastRecordingDate = (typeof jsonObj.lastRecordingDate === 'undefined') ? '' : jsonObj.lastRecordingDate; + let lastRecordingDateEnabled; - const passFiltersEnabled = (typeof jsonObj.passFiltersEnabled === 'undefined') ? false : jsonObj.passFiltersEnabled; + // In older versions of the app, whether or not the first/last date is enabled was specified in the save file by just the presence of the date - let filterTypeIndex; + if (typeof jsonObj.lastRecordingDateEnabled === 'undefined') { + + if (typeof jsonObj.lastRecordingDate === 'undefined') { + + lastRecordingDateEnabled = false; + + } else { + + lastRecordingDateEnabled = true; + + } + + } else { + + lastRecordingDateEnabled = jsonObj.lastRecordingDateEnabled; + + } + + const today = new Date(); + + const year = ('000' + today.getUTCFullYear()).slice(-4); + const month = ('0' + (today.getUTCMonth() + 1)).slice(-2); + const day = ('0' + today.getUTCDate()).slice(-2); + const todayString = year + '-' + month + '-' + day; + + let replacementFirstRecordingDate; + + if (typeof replacementValues.firstRecordingDate === 'undefined' || replacementValues.firstRecordingDate === '') { + + if (typeof jsonObj.lastRecordingDate === 'undefined') { - if (passFiltersEnabled) { + replacementFirstRecordingDate = todayString; - switch (jsonObj.filterType) { + } else { - case 'low': - filterTypeIndex = 0; - break; - case 'band': - filterTypeIndex = 1; - break; - case 'high': - filterTypeIndex = 2; - break; + replacementFirstRecordingDate = jsonObj.lastRecordingDate; } } else { + replacementFirstRecordingDate = replacementValues.firstRecordingDate; + + } + + const firstRecordingDate = (typeof jsonObj.firstRecordingDate === 'undefined') ? replacementFirstRecordingDate : jsonObj.firstRecordingDate; + + let replacementLastRecordingDate; + + if (typeof replacementValues.lastRecordingDate === 'undefined' || replacementValues.lastRecordingDate === '') { + + if (typeof jsonObj.firstRecordingDate === 'undefined') { + + replacementLastRecordingDate = todayString; + + } else { + + replacementLastRecordingDate = jsonObj.firstRecordingDate; + + } + + } else { + + replacementLastRecordingDate = replacementValues.lastRecordingDate; + + } + + const lastRecordingDate = (typeof jsonObj.lastRecordingDate === 'undefined') ? replacementLastRecordingDate : jsonObj.lastRecordingDate; + + const passFiltersEnabled = (typeof jsonObj.passFiltersEnabled === 'undefined') ? replacementValues.passFiltersEnabled : jsonObj.passFiltersEnabled; + + const filterType = (typeof jsonObj.filterType === 'undefined') ? replacementValues.filterType : jsonObj.filterType; + + let filterTypeIndex; + + switch (filterType) { + + case 'low': filterTypeIndex = 0; + break; + case 'band': + filterTypeIndex = 1; + break; + case 'high': + filterTypeIndex = 2; + break; } - const lowerFilter = (typeof jsonObj.lowerFilter === 'undefined') ? -1 : jsonObj.lowerFilter; - const higherFilter = (typeof jsonObj.higherFilter === 'undefined') ? -1 : jsonObj.higherFilter; + const lowerFilter = (typeof jsonObj.lowerFilter === 'undefined') ? replacementValues.lowerFilter : jsonObj.lowerFilter; + const higherFilter = (typeof jsonObj.higherFilter === 'undefined') ? replacementValues.higherFilter : jsonObj.higherFilter; + + const amplitudeThresholdingEnabled = (typeof jsonObj.amplitudeThresholdingEnabled === 'undefined') ? replacementValues.amplitudeThresholdingEnabled : jsonObj.amplitudeThresholdingEnabled; + const amplitudeThreshold = (typeof jsonObj.amplitudeThreshold === 'undefined') ? replacementValues.amplitudeThreshold : jsonObj.amplitudeThreshold; - const amplitudeThresholdingEnabled = (typeof jsonObj.amplitudeThresholdingEnabled === 'undefined') ? false : jsonObj.amplitudeThresholdingEnabled; - const amplitudeThreshold = amplitudeThresholdingEnabled ? jsonObj.amplitudeThreshold : 0; + const requireAcousticConfig = (typeof jsonObj.requireAcousticConfig === 'undefined') ? replacementValues.requireAcousticConfig : jsonObj.requireAcousticConfig; - const requireAcousticConfig = (typeof jsonObj.requireAcousticConfig === 'undefined') ? false : jsonObj.requireAcousticConfig; + const displayVoltageRange = (typeof jsonObj.displayVoltageRange === 'undefined') ? replacementValues.displayVoltageRange : jsonObj.displayVoltageRange; - const displayVoltageRange = (typeof jsonObj.displayVoltageRange === 'undefined') ? false : jsonObj.displayVoltageRange; + const minimumAmplitudeThresholdDuration = (typeof jsonObj.minimumAmplitudeThresholdDuration === 'undefined') ? replacementValues.minimumAmplitudeThresholdDuration : jsonObj.minimumAmplitudeThresholdDuration; - const minimumAmplitudeThresholdDuration = (typeof jsonObj.minimumAmplitudeThresholdDuration === 'undefined') ? 0 : jsonObj.minimumAmplitudeThresholdDuration; + const amplitudeThresholdingScale = (typeof jsonObj.amplitudeThresholdingScale === 'undefined') ? replacementValues.amplitudeThresholdingScale : jsonObj.amplitudeThresholdingScale; let amplitudeThresholdingScaleIndex; /* Previous versions of the app used 0 - 32768 as the amplitude threshold scale. If the scale index isn't in the save file, assume it's from an older app version and match threshold and scale to old range */ - switch (jsonObj.amplitudeThresholdingScale) { + switch (amplitudeThresholdingScale) { case 'percentage': amplitudeThresholdingScaleIndex = 0; @@ -390,15 +567,21 @@ function useLoadedConfiguration (err, data, callback) { } - const energySaverModeEnabled = (jsonObj.energySaverModeEnabled === 'undefined') ? false : jsonObj.energySaverModeEnabled; + const energySaverModeEnabled = (typeof jsonObj.energySaverModeEnabled === 'undefined') ? replacementValues.energySaverModeEnabled : jsonObj.energySaverModeEnabled; + + const disable48DCFilter = (typeof jsonObj.disable48DCFilter === 'undefined') ? replacementValues.disable48DCFilter : jsonObj.disable48DCFilter; + + const lowGainRangeEnabled = (typeof jsonObj.lowGainRangeEnabled === 'undefined') ? replacementValues.lowGainRangeEnabled : jsonObj.lowGainRangeEnabled; + + const timeSettingFromGPSEnabled = (typeof jsonObj.timeSettingFromGPSEnabled === 'undefined') ? replacementValues.timeSettingFromGPSEnabled : jsonObj.timeSettingFromGPSEnabled; - const disable48DCFilter = (jsonObj.disable48DCFilter === 'undefined') ? false : jsonObj.disable48DCFilter; + const magneticSwitchEnabled = (typeof jsonObj.magneticSwitchEnabled === 'undefined') ? replacementValues.magneticSwitchEnabled : jsonObj.magneticSwitchEnabled; const version = (typeof jsonObj.version === 'undefined') ? '< 1.5.0' : jsonObj.version; - callback(timePeriods, ledEnabled, lowVoltageCutoffEnabled, batteryLevelCheckEnabled, sampleRateIndex, gain, dutyEnabled, recordDuration, sleepDuration, localTime, firstRecordingDate, lastRecordingDate, passFiltersEnabled, filterTypeIndex, lowerFilter, higherFilter, amplitudeThresholdingEnabled, amplitudeThreshold, requireAcousticConfig, displayVoltageRange, minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex, energySaverModeEnabled, disable48DCFilter); + callback(timePeriods, ledEnabled, lowVoltageCutoffEnabled, batteryLevelCheckEnabled, sampleRateIndex, gain, dutyEnabled, recordDuration, sleepDuration, localTime, firstRecordingDateEnabled, firstRecordingDate, lastRecordingDateEnabled, lastRecordingDate, passFiltersEnabled, filterTypeIndex, lowerFilter, higherFilter, amplitudeThresholdingEnabled, amplitudeThreshold, requireAcousticConfig, displayVoltageRange, minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex, energySaverModeEnabled, disable48DCFilter, lowGainRangeEnabled, timeSettingFromGPSEnabled, magneticSwitchEnabled); - console.log('Loaded config created by Configuration App version ' + version); + console.log('Loaded configuration file'); } catch (usageErr) { @@ -418,7 +601,7 @@ function useLoadedConfiguration (err, data, callback) { /* Display open dialog to allow users to load a .config file */ -exports.loadConfiguration = (callback) => { +exports.loadConfiguration = (currentConfig, callback) => { const fileName = dialog.showOpenDialogSync({ title: 'Open configuration', @@ -435,7 +618,7 @@ exports.loadConfiguration = (callback) => { fs.readFile(fileName[0], function (err, data) { - useLoadedConfiguration(err, data, callback); + useLoadedConfiguration(err, currentConfig, data, callback); }); diff --git a/schedule/dateInput.js b/schedule/dateInput.js index 8111c02..fc18fee 100644 --- a/schedule/dateInput.js +++ b/schedule/dateInput.js @@ -114,10 +114,11 @@ function handleFocusOut (e) { if (!input.disabled) { - input.style.color = ''; + input.classList.remove('grey'); } + input.style.color = ''; input.style.border = ''; }, 1000); diff --git a/schedule/timeInput.js b/schedule/timeInput.js index a451d30..f302532 100644 --- a/schedule/timeInput.js +++ b/schedule/timeInput.js @@ -55,11 +55,11 @@ exports.setEnabled = (div, setting) => { textInput.style.backgroundColor = ''; textInput.style.border = ''; - hourSpan.style.color = ''; + hourSpan.classList.remove('grey'); hourSpan.style.backgroundColor = ''; - colonSpan.style.color = ''; + colonSpan.classList.remove('grey'); colonSpan.style.backgroundColor = ''; - minuteSpan.style.color = ''; + minuteSpan.classList.remove('grey'); minuteSpan.style.backgroundColor = ''; textInput.tabIndex = 0; @@ -72,20 +72,20 @@ exports.setEnabled = (div, setting) => { case 'win32': textInput.style.backgroundColor = '#EBEBE4'; textInput.style.border = '1px solid #cccccc'; - hourSpan.style.color = 'grey'; + hourSpan.classList.add('grey'); hourSpan.style.backgroundColor = '#EBEBE4'; - colonSpan.style.color = 'grey'; + colonSpan.classList.add('grey'); colonSpan.style.backgroundColor = '#EBEBE4'; - minuteSpan.style.color = 'grey'; + minuteSpan.classList.add('grey'); minuteSpan.style.backgroundColor = '#EBEBE4'; break; case 'darwin': - hourSpan.style.color = 'grey'; + hourSpan.classList.add('grey'); hourSpan.style.backgroundColor = 'white'; - colonSpan.style.color = 'grey'; + colonSpan.classList.add('grey'); colonSpan.style.backgroundColor = 'white'; - minuteSpan.style.color = 'grey'; + minuteSpan.classList.add('grey'); minuteSpan.style.backgroundColor = 'white'; break; @@ -185,21 +185,25 @@ function highlightInput (node) { hourSpan.style.backgroundColor = 'Highlight'; hourSpan.style.color = 'HighlightText'; minuteSpan.style.backgroundColor = deselectedColor; - minuteSpan.style.color = ''; + minuteSpan.classList.remove('grey'); } else if (index === 1) { - hourSpan.style.backgroundColor = deselectedColor; hourSpan.style.color = ''; + minuteSpan.style.color = ''; + hourSpan.style.backgroundColor = deselectedColor; + hourSpan.classList.remove('grey'); minuteSpan.style.backgroundColor = 'Highlight'; minuteSpan.style.color = 'HighlightText'; } else { - hourSpan.style.backgroundColor = deselectedColor; hourSpan.style.color = ''; - minuteSpan.style.backgroundColor = deselectedColor; minuteSpan.style.color = ''; + hourSpan.style.backgroundColor = deselectedColor; + hourSpan.classList.remove('grey'); + minuteSpan.style.backgroundColor = deselectedColor; + minuteSpan.classList.remove('grey'); } diff --git a/schedule/uiSchedule.js b/schedule/uiSchedule.js index c9fe3cd..264b6ee 100644 --- a/schedule/uiSchedule.js +++ b/schedule/uiSchedule.js @@ -56,8 +56,14 @@ function startlastRecordingDateError (input) { setTimeout(function () { - input.style.border = ''; + if (!input.disabled) { + + input.classList.remove('grey'); + + } + input.style.color = ''; + input.style.border = ''; }, 1000); @@ -89,14 +95,14 @@ function updateFirstRecordingDateUI () { if (firstRecordingDateCheckbox.checked) { - firstRecordingDateLabel.style.color = ''; - firstRecordingDateInput.style.color = ''; + firstRecordingDateLabel.classList.remove('grey'); + firstRecordingDateInput.classList.remove('grey'); firstRecordingDateInput.disabled = false; } else { - firstRecordingDateLabel.style.color = 'lightgrey'; - firstRecordingDateInput.style.color = 'lightgrey'; + firstRecordingDateLabel.classList.add('grey'); + firstRecordingDateInput.classList.add('grey'); firstRecordingDateInput.disabled = true; } @@ -109,51 +115,59 @@ function updateLastRecordingDateUI () { if (lastRecordingDateCheckbox.checked) { - lastRecordingDateLabel.style.color = ''; - lastRecordingDateInput.style.color = ''; + lastRecordingDateLabel.classList.remove('grey'); + lastRecordingDateInput.classList.remove('grey'); lastRecordingDateInput.disabled = false; } else { - lastRecordingDateLabel.style.color = 'lightgrey'; - lastRecordingDateInput.style.color = 'lightgrey'; + lastRecordingDateLabel.classList.add('grey'); + lastRecordingDateInput.classList.add('grey'); lastRecordingDateInput.disabled = true; } } +exports.isFirstRecordingDateEnabled = () => { + + return firstRecordingDateCheckbox.checked; + +}; + +exports.isLastRecordingDateEnabled = () => { + + return lastRecordingDateCheckbox.checked; + +}; + exports.getFirstRecordingDate = () => { - return firstRecordingDateCheckbox.checked ? firstRecordingDateInput.value : ''; + return firstRecordingDateInput.value; }; exports.getLastRecordingDate = () => { - return lastRecordingDateCheckbox.checked ? lastRecordingDateInput.value : ''; + return lastRecordingDateInput.value; }; -exports.setFirstRecordingDate = (firstRecordingDate) => { +exports.setFirstRecordingDate = (firstRecordingDateEnabled, firstRecordingDate) => { - const today = new Date(); - - firstRecordingDateCheckbox.checked = (firstRecordingDate !== ''); + firstRecordingDateCheckbox.checked = firstRecordingDateEnabled; updateFirstRecordingDateUI(); - firstRecordingDateInput.value = (firstRecordingDate !== '') ? firstRecordingDate : dateToString(today); + firstRecordingDateInput.value = firstRecordingDate; }; -exports.setLastRecordingDate = (lastRecordingDate) => { - - const today = new Date(); +exports.setLastRecordingDate = (lastRecordingDateEnabled, lastRecordingDate) => { - lastRecordingDateCheckbox.checked = (lastRecordingDate !== ''); + lastRecordingDateCheckbox.checked = lastRecordingDateEnabled; updateLastRecordingDateUI(); - lastRecordingDateInput.value = (lastRecordingDate !== '') ? lastRecordingDate : dateToString(today); + lastRecordingDateInput.value = lastRecordingDate; }; diff --git a/settings/advanced.html b/settings/advanced.html index e371fa6..27bcde8 100644 --- a/settings/advanced.html +++ b/settings/advanced.html @@ -34,4 +34,33 @@ + +
+
+ Enable low gain range: +
+
+ +
+
+ + +
+
+
+ Enable magnetic switch for delayed start: +
+
+ +
+
+
+
+ Enable GPS for time setting: +
+
+ +
+
+ diff --git a/settings/durationInput.js b/settings/durationInput.js index 3179530..93d2a78 100644 --- a/settings/durationInput.js +++ b/settings/durationInput.js @@ -71,7 +71,7 @@ exports.setEnabled = (div, setting) => { textInput.style.backgroundColor = ''; textInput.style.border = ''; - span.style.color = ''; + span.classList.remove('grey'); span.style.backgroundColor = ''; textInput.tabIndex = 0; @@ -84,12 +84,12 @@ exports.setEnabled = (div, setting) => { case 'win32': textInput.style.backgroundColor = '#EBEBE4'; textInput.style.border = '1px solid #cccccc'; - span.style.color = 'grey'; + span.classList.add('grey'); span.style.backgroundColor = '#EBEBE4'; break; case 'darwin': - span.style.color = 'grey'; + span.classList.add('grey'); span.style.backgroundColor = 'white'; break; @@ -112,8 +112,9 @@ function highlightInput (node) { } else { - span.style.backgroundColor = ''; span.style.color = ''; + span.style.backgroundColor = ''; + span.classList.remove('grey'); } diff --git a/settings/filtering.html b/settings/filtering.html index 92f6c9c..f723666 100644 --- a/settings/filtering.html +++ b/settings/filtering.html @@ -19,12 +19,12 @@ - Low - Band - High + Low + Band + High - Filter type: + Filter type: @@ -51,10 +51,10 @@ 0kHz
- +
-
- 24kHz +
+ 24kHz
@@ -64,10 +64,10 @@ 0kHz
- +
-
- 24kHz +
+ 24kHz
@@ -77,10 +77,10 @@ 0kHz
- +
-
- 24kHz +
+ 24kHz
@@ -109,40 +109,40 @@ - - - - - - - - + + + + + + + + - +
012510153060012510153060
Minimum trigger duration (s):Minimum trigger duration (s): - + - + - + - + - + - + - + - +
@@ -155,7 +155,7 @@ 0.001%
- +
100% diff --git a/settings/uiAdvanced.js b/settings/uiAdvanced.js index 9ec2b66..70184af 100644 --- a/settings/uiAdvanced.js +++ b/settings/uiAdvanced.js @@ -4,10 +4,18 @@ * January 2021 *****************************************************************************/ +const electron = require('electron'); +const dialog = electron.remote.dialog; + const acousticConfigCheckBox = document.getElementById('acoustic-config-checkbox'); const voltageRangeCheckBox = document.getElementById('voltage-range-checkbox'); const energySaverModeCheckbox = document.getElementById('energy-saver-mode-checkbox'); +const lowGainRangeCheckbox = document.getElementById('low-gain-range-checkbox'); const disable48DCFilterCheckbox = document.getElementById('disable-48-dc-filter-checkbox'); +const gpsTimeCheckbox = document.getElementById('gps-time-checkbox'); +const magneticDelayCheckbox = document.getElementById('magnetic-delay-checkbox'); + +let hardwareWarningDisplayed = false; exports.isAcousticConfigRequired = () => { @@ -27,23 +35,86 @@ exports.isEnergySaverModeEnabled = () => { }; +exports.isLowGainRangeEnabled = () => { + + return lowGainRangeCheckbox.checked; + +} + exports.is48DCFilterDisabled = () => { return disable48DCFilterCheckbox.checked; }; +exports.istimeSettingFromGPSEnabled = () => { + + return gpsTimeCheckbox.checked; + +}; + +exports.ismagneticSwitchEnabled = () => { + + return magneticDelayCheckbox.checked; + +}; + exports.fillUI = (settings) => { acousticConfigCheckBox.checked = settings.requireAcousticConfig; voltageRangeCheckBox.checked = settings.displayVoltageRange; energySaverModeCheckbox.checked = settings.energySaverModeEnabled; + lowGainRangeCheckbox.checked = settings.lowGainRangeEnabled; disable48DCFilterCheckbox.checked = settings.disable48DCFilter; + gpsTimeCheckbox.checked = settings.timeSettingFromGPSEnabled; + magneticDelayCheckbox.checked = settings.magneticSwitchEnabled; }; exports.prepareUI = (changeFunction) => { energySaverModeCheckbox.addEventListener('change', changeFunction); + gpsTimeCheckbox.addEventListener('change', changeFunction); }; + +function displayAdditionalHardwareWarning () { + + if (hardwareWarningDisplayed) { + + return; + + } + + dialog.showMessageBox({ + type: 'warning', + buttons: ['OK'], + title: 'Additional hardware required', + message: 'Additional hardware is required to use the GPS time setting and magnetic switch features. Do not use these settings if this hardware is not present.' + }); + + hardwareWarningDisplayed = true; + +} + +exports.displayAdditionalHardwareWarning = displayAdditionalHardwareWarning; + +gpsTimeCheckbox.addEventListener('change', () => { + + if (gpsTimeCheckbox.checked) { + + displayAdditionalHardwareWarning(); + + } + +}); + +magneticDelayCheckbox.addEventListener('change', () => { + + if (magneticDelayCheckbox.checked) { + + displayAdditionalHardwareWarning(); + + } + +}); diff --git a/settings/uiFiltering.js b/settings/uiFiltering.js index bd68452..a0f45e5 100644 --- a/settings/uiFiltering.js +++ b/settings/uiFiltering.js @@ -14,9 +14,8 @@ const Slider = require('bootstrap-slider'); const FILTER_SLIDER_STEPS = [100, 100, 100, 100, 200, 500, 500, 1000]; -const filterTypeLabel = document.getElementById('filter-type-label'); -const filterRadioButtons = document.getElementsByName('filter-radio'); const filterRadioLabels = document.getElementsByName('filter-radio-label'); +const filterRadioButtons = document.getElementsByName('filter-radio'); const highPassRow = document.getElementById('high-pass-row'); const lowPassRow = document.getElementById('low-pass-row'); @@ -42,8 +41,8 @@ const amplitudeThresholdingMinLabel = document.getElementById('amplitude-thresho const amplitudeThresholdingCheckbox = document.getElementById('amplitude-thresholding-checkbox'); const amplitudeThresholdingSlider = new Slider('#amplitude-thresholding-slider', {}); const amplitudeThresholdingLabel = document.getElementById('amplitude-thresholding-label'); -const amplitudeThresholdingDurationTable = document.getElementById('amplitude-thresholding-duration-table'); const amplitudeThresholdingRadioButtons = document.getElementsByName('amplitude-thresholding-duration-radio'); +const amplitudeThresholdingRadioLabels = document.getElementsByName('amplitude-thresholding-duration-radio-label'); const VALID_AMPLITUDE_VALUES = [0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 88, 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256, 288, 320, 352, 384, 416, 448, 480, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360, 16384, 18432, 20480, 22528, 24576, 26624, 28672, 30720, 32768]; @@ -367,34 +366,30 @@ exports.setFilters = (enabled, lowerSliderValue, higherSliderValue, filterType) filterHasBeenEnabled = enabled; - if (enabled) { - - switch (filterType) { - - case FILTER_LOW: - setLowPassSliderValue(higherSliderValue); - break; + switch (filterType) { - case FILTER_HIGH: - setHighPassSliderValue(lowerSliderValue); - break; - - case FILTER_BAND: - setBandPass(lowerSliderValue, higherSliderValue); - break; + case FILTER_LOW: + setLowPassSliderValue(higherSliderValue); + break; - } + case FILTER_HIGH: + setHighPassSliderValue(lowerSliderValue); + break; - for (let i = 0; i < filterRadioButtons.length; i++) { + case FILTER_BAND: + setBandPass(lowerSliderValue, higherSliderValue); + break; - filterRadioButtons[i].checked = (i === filterType); + } - } + for (let i = 0; i < filterRadioButtons.length; i++) { - updateFilterLabel(); + filterRadioButtons[i].checked = (i === filterType); } + updateFilterLabel(); + }; exports.setAmplitudeThresholdScaleIndex = (scaleIndex) => { @@ -551,13 +546,17 @@ function updateAmplitudeThresholdingUI () { if (amplitudeThresholdingCheckbox.checked) { amplitudeThresholdingSlider.enable(); - amplitudeThresholdingMaxLabel.style.color = ''; - amplitudeThresholdingMinLabel.style.color = ''; + amplitudeThresholdingMaxLabel.classList.remove('grey'); + amplitudeThresholdingMinLabel.classList.remove('grey'); - amplitudeThresholdingLabel.style.color = ''; + amplitudeThresholdingLabel.classList.remove('grey'); updateAmplitudeThresholdingLabel(); - amplitudeThresholdingDurationTable.style.color = ''; + for (let i = 0; i < amplitudeThresholdingRadioLabels.length; i++) { + + amplitudeThresholdingRadioLabels[i].classList.remove('grey'); + + } for (let i = 0; i < amplitudeThresholdingRadioButtons.length; i++) { @@ -568,13 +567,17 @@ function updateAmplitudeThresholdingUI () { } else { amplitudeThresholdingSlider.disable(); - amplitudeThresholdingMaxLabel.style.color = 'grey'; - amplitudeThresholdingMinLabel.style.color = 'grey'; + amplitudeThresholdingMaxLabel.classList.add('grey'); + amplitudeThresholdingMinLabel.classList.add('grey'); + + amplitudeThresholdingLabel.classList.add('grey'); + amplitudeThresholdingLabel.textContent = 'All audio will be written to a WAV file.'; - amplitudeThresholdingLabel.style.color = 'grey'; - amplitudeThresholdingLabel.textContent = 'All audio will be written to a .WAV file.'; + for (let i = 0; i < amplitudeThresholdingRadioLabels.length; i++) { - amplitudeThresholdingDurationTable.style.color = 'grey'; + amplitudeThresholdingRadioLabels[i].classList.add('grey'); + + } for (let i = 0; i < amplitudeThresholdingRadioButtons.length; i++) { @@ -618,52 +621,58 @@ function updateFilterUI () { if (filterCheckbox.checked) { - filterTypeLabel.style.color = ''; + for (let i = 0; i < filterRadioLabels.length; i++) { + + filterRadioLabels[i].classList.remove('grey'); + + } for (let i = 0; i < filterRadioButtons.length; i++) { - filterRadioButtons[i].style.color = ''; + filterRadioButtons[i].classList.remove('grey'); filterRadioButtons[i].disabled = false; - filterRadioLabels[i].style.color = ''; } bandPassFilterSlider.enable(); lowPassFilterSlider.enable(); highPassFilterSlider.enable(); - bandPassMaxLabel.style.color = ''; - bandPassMinLabel.style.color = ''; - lowPassMaxLabel.style.color = ''; - lowPassMinLabel.style.color = ''; - highPassMaxLabel.style.color = ''; - highPassMinLabel.style.color = ''; + bandPassMaxLabel.classList.remove('grey'); + bandPassMinLabel.classList.remove('grey'); + lowPassMaxLabel.classList.remove('grey'); + lowPassMinLabel.classList.remove('grey'); + highPassMaxLabel.classList.remove('grey'); + highPassMinLabel.classList.remove('grey'); - filterLabel.style.color = ''; + filterLabel.classList.remove('grey'); } else { - filterTypeLabel.style.color = 'grey'; + for (let i = 0; i < filterRadioLabels.length; i++) { + + filterRadioLabels[i].classList.add('grey'); + + } for (let i = 0; i < filterRadioButtons.length; i++) { - filterRadioButtons[i].style.color = 'grey'; + filterRadioButtons[i].classList.add('grey'); filterRadioButtons[i].disabled = true; - filterRadioLabels[i].style.color = 'grey'; } bandPassFilterSlider.disable(); lowPassFilterSlider.disable(); highPassFilterSlider.disable(); - bandPassMaxLabel.style.color = 'grey'; - bandPassMinLabel.style.color = 'grey'; - lowPassMaxLabel.style.color = 'grey'; - lowPassMinLabel.style.color = 'grey'; - highPassMaxLabel.style.color = 'grey'; - highPassMinLabel.style.color = 'grey'; + bandPassMaxLabel.classList.add('grey'); + bandPassMinLabel.classList.add('grey'); + lowPassMaxLabel.classList.add('grey'); + lowPassMinLabel.classList.add('grey'); + highPassMaxLabel.classList.add('grey'); + highPassMinLabel.classList.add('grey'); filterLabel.textContent = 'Recordings will not be filtered.'; - filterLabel.style.color = 'grey'; + filterLabel.classList.add('grey'); } diff --git a/settings/uiSettings.js b/settings/uiSettings.js index ee3d28b..1d86535 100644 --- a/settings/uiSettings.js +++ b/settings/uiSettings.js @@ -51,18 +51,18 @@ function updateDutyCycleUI () { if (dutyCheckBox.checked) { durationInput.setEnabled(recordingDurationInput, true); - recordingDurationLabel.style.color = ''; + recordingDurationLabel.classList.remove('grey'); durationInput.setEnabled(sleepDurationInput, true); - sleepDurationLabel.style.color = ''; + sleepDurationLabel.classList.remove('grey'); } else { durationInput.setEnabled(recordingDurationInput, false); - recordingDurationLabel.style.color = 'lightgrey'; + recordingDurationLabel.classList.add('grey'); durationInput.setEnabled(sleepDurationInput, false); - sleepDurationLabel.style.color = 'lightgrey'; + sleepDurationLabel.classList.add('grey'); } @@ -158,7 +158,10 @@ exports.getSettings = () => { minimumAmplitudeThresholdDuration: uiFiltering.getMinimumAmplitudeThresholdDuration(), amplitudeThresholdingScaleIndex: uiFiltering.getAmplitudeThresholdScaleIndex(), energySaverModeEnabled: uiAdvanced.isEnergySaverModeEnabled(), - disable48DCFilter: uiAdvanced.is48DCFilterDisabled() + lowGainRangeEnabled: uiAdvanced.isLowGainRangeEnabled(), + disable48DCFilter: uiAdvanced.is48DCFilterDisabled(), + timeSettingFromGPSEnabled: uiAdvanced.istimeSettingFromGPSEnabled(), + magneticSwitchEnabled: uiAdvanced.ismagneticSwitchEnabled() }; return settings; @@ -191,6 +194,12 @@ exports.fillUI = (settings) => { uiAdvanced.fillUI(settings); + if (settings.timeSettingFromGPSEnabled || settings.magneticSwitchEnabled) { + + uiAdvanced.displayAdditionalHardwareWarning(); + + } + uiFiltering.setMinimumAmplitudeThresholdDuration(settings.minimumAmplitudeThresholdDuration); }; diff --git a/ui.css b/ui.css index cdbd293..2079888 100644 --- a/ui.css +++ b/ui.css @@ -21,32 +21,9 @@ body { } .slider-selection { - position: absolute; - background-image: -webkit-linear-gradient(top, #F5F5F5 0%, #F9F9F9 100%); - background-image: -o-linear-gradient(top, #F5F5F5 0%, #F9F9F9 100%); - background-image: linear-gradient(to bottom, #F5F5F5 0%, #F9F9F9 100%); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0); - background-repeat: repeat-x; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - border-radius: 4px; -} - -#low-pass-filter-slider .slider-selection { - background: rgb(173, 189, 241); -} - -#high-pass-filter-slider .slider-track { background: rgb(173, 189, 241); } -#band-pass-filter-slider .slider-selection { - background: rgb(173, 189, 241); -} - -#amplitude-thresholding-slider .slider-track { - background: rgb(173, 189, 241); +.grey { + color: #D3D3D3; } diff --git a/ui.js b/ui.js index 891a49d..4e0d3b9 100644 --- a/ui.js +++ b/ui.js @@ -95,9 +95,9 @@ exports.disableTimeDisplay = (blankValue) => { if (timeDisplay) { - timeDisplay.style.color = 'lightgrey'; + timeDisplay.classList.add('grey'); - timezoneLabel.style.color = 'lightgrey'; + timezoneLabel.classList.add('grey'); if (blankValue) { @@ -111,22 +111,11 @@ exports.disableTimeDisplay = (blankValue) => { exports.enableTimeDisplay = () => { - let textColor; - if (timeDisplay) { - if (nightMode.isEnabled()) { - - textColor = 'white'; - - } else { - - textColor = 'black'; - - } + timeDisplay.classList.remove('grey'); - timeDisplay.style.color = textColor; - timezoneLabel.style.color = textColor; + timezoneLabel.classList.remove('grey'); } diff --git a/uiIndex.js b/uiIndex.js index 3f1c4bb..78aefbc 100644 --- a/uiIndex.js +++ b/uiIndex.js @@ -420,7 +420,7 @@ function sendPacket (packet) { message: 'The connected AudioMoth did not respond correctly and the configuration may not have been applied. Please try again.' }); - configureButton.style.color = ''; + configureButton.classList.remove('grey'); }; @@ -612,12 +612,12 @@ function configureDevice () { const timezoneOffset = -60 * today.getTimezoneOffset(); - const firstRecordingDateText = uiSchedule.getFirstRecordingDate(); + const firstRecordingDateEnabled = uiSchedule.isFirstRecordingDateEnabled(); const firstRecordingDate = new Date(uiSchedule.getFirstRecordingDate()); let earliestRecordingTime; - if (firstRecordingDateText === '') { + if (!firstRecordingDateEnabled) { earliestRecordingTime = 0; @@ -637,12 +637,12 @@ function configureDevice () { } - const lastRecordingDateText = uiSchedule.getLastRecordingDate(); + const lastRecordingDateEnabled = uiSchedule.isLastRecordingDateEnabled(); const lastRecordingDate = new Date(uiSchedule.getLastRecordingDate()); let latestRecordingTime; - if (lastRecordingDateText === '') { + if (!lastRecordingDateEnabled) { latestRecordingTime = 0; @@ -849,8 +849,20 @@ function configureDevice () { /* Whether to turn off the 48Hz DC blocking filter which is on by default */ const disable48DCFilter = settings.disable48DCFilter ? 1 : 0; + /* Whether to enable the low gain range */ + const lowGainRangeEnabled = settings.lowGainRangeEnabled ? 1 : 0; + + /* Whether to allow the time to be updated via GPS */ + const timeSettingFromGPSEnabled = settings.timeSettingFromGPSEnabled ? 1 : 0; + + /* Whether to check the magnetic switch to start a delayed schedule */ + const magneticSwitchEnabled = settings.magneticSwitchEnabled ? 1 : 0; + let packedByte3 = energySaverModeEnabled & 1; packedByte3 |= (disable48DCFilter << 1); + packedByte3 |= (timeSettingFromGPSEnabled << 2); + packedByte3 |= (magneticSwitchEnabled << 3); + packedByte3 |= (lowGainRangeEnabled << 4); packet[index++] = packedByte3; @@ -913,14 +925,14 @@ function disableDisplay () { ui.disableTimeDisplay(false); - idLabel.style.color = 'lightgrey'; - idDisplay.style.color = 'lightgrey'; - firmwareVersionLabel.style.color = 'lightgrey'; - firmwareVersionDisplay.style.color = 'lightgrey'; - firmwareDescriptionLabel.style.color = 'lightgrey'; - firmwareDescriptionDisplay.style.color = 'lightgrey'; - batteryLabel.style.color = 'lightgrey'; - batteryDisplay.style.color = 'lightgrey'; + idLabel.classList.add('grey'); + idDisplay.classList.add('grey'); + firmwareVersionLabel.classList.add('grey'); + firmwareVersionDisplay.classList.add('grey'); + firmwareDescriptionLabel.classList.add('grey'); + firmwareDescriptionDisplay.classList.add('grey'); + batteryLabel.classList.add('grey'); + batteryDisplay.classList.add('grey'); configureButton.disabled = true; @@ -930,23 +942,14 @@ function disableDisplay () { function enableDisplay () { - const textColor = ui.isNightMode() ? 'white' : 'black'; - - idLabel.style.color = textColor; - - idDisplay.style.color = textColor; - - firmwareVersionLabel.style.color = textColor; - - firmwareVersionDisplay.style.color = textColor; - - firmwareDescriptionLabel.style.color = textColor; - - firmwareDescriptionDisplay.style.color = textColor; - - batteryLabel.style.color = textColor; - - batteryDisplay.style.color = textColor; + idLabel.classList.remove('grey'); + idDisplay.classList.remove('grey'); + firmwareVersionLabel.classList.remove('grey'); + firmwareVersionDisplay.classList.remove('grey'); + firmwareDescriptionLabel.classList.remove('grey'); + firmwareDescriptionDisplay.classList.remove('grey'); + batteryLabel.classList.remove('grey'); + batteryDisplay.classList.remove('grey'); configureButton.disabled = false; @@ -962,7 +965,7 @@ function updateIdDisplay (deviceId) { if (deviceId !== idDisplay.textContent) { - if (deviceId === null) { + if (deviceId === null || deviceId === undefined) { idDisplay.textContent = '-'; @@ -1010,7 +1013,7 @@ function updateFirmwareDisplay (version, description) { function updateBatteryDisplay (battery) { - if (battery === null) { + if (battery === null || battery === undefined) { batteryDisplay.textContent = '-'; @@ -1033,7 +1036,7 @@ function copyDeviceID () { setTimeout(function () { - idDisplay.style.color = ''; + idDisplay.classList.remove('grey'); }, 5000); @@ -1068,7 +1071,7 @@ function updateLifeDisplayOnChange () { const settings = uiSettings.getSettings(); - lifeDisplay.updateLifeDisplay(sortedPeriods, constants.configurations[settings.sampleRateIndex], settings.recordDuration, settings.sleepDuration, settings.amplitudeThresholdingEnabled, settings.dutyEnabled, settings.energySaverModeEnabled); + lifeDisplay.updateLifeDisplay(sortedPeriods, constants.configurations[settings.sampleRateIndex], settings.recordDuration, settings.sleepDuration, settings.amplitudeThresholdingEnabled, settings.dutyEnabled, settings.energySaverModeEnabled, settings.timeSettingFromGPSEnabled); } @@ -1078,50 +1081,69 @@ lifeDisplay.getPanel().addEventListener('click', function () { }); -/* Add listeners to save/load menu options */ +function getCurrentConfiguration () { -electron.ipcRenderer.on('save', function () { + const config = {}; - const timePeriods = scheduleBar.getTimePeriods(); + config.timePeriods = scheduleBar.getTimePeriods(); - const localTime = ui.isLocalTime(); + config.localTime = ui.isLocalTime(); - const ledEnabled = ledCheckbox.checked; - const lowVoltageCutoffEnabled = lowVoltageCutoffCheckbox.checked; - const batteryLevelCheckEnabled = batteryLevelCheckbox.checked; + config.ledEnabled = ledCheckbox.checked; + config.lowVoltageCutoffEnabled = lowVoltageCutoffCheckbox.checked; + config.batteryLevelCheckEnabled = batteryLevelCheckbox.checked; const settings = uiSettings.getSettings(); - const sampleRateIndex = settings.sampleRateIndex; - const gain = settings.gain; - const recordDuration = settings.recordDuration; - const sleepDuration = settings.sleepDuration; - const dutyEnabled = settings.dutyEnabled; + config.sampleRateIndex = settings.sampleRateIndex; + config.gain = settings.gain; + config.recordDuration = settings.recordDuration; + config.sleepDuration = settings.sleepDuration; + config.dutyEnabled = settings.dutyEnabled; - const passFiltersEnabled = settings.passFiltersEnabled; - const filterTypeIndex = settings.filterTypeIndex; - const lowerFilter = settings.lowerFilter; - const higherFilter = settings.higherFilter; + config.passFiltersEnabled = settings.passFiltersEnabled; + config.filterTypeIndex = settings.filterTypeIndex; + config.lowerFilter = settings.lowerFilter; + config.higherFilter = settings.higherFilter; - const amplitudeThresholdingEnabled = settings.amplitudeThresholdingEnabled; - const amplitudeThreshold = settings.amplitudeThreshold; + config.amplitudeThresholdingEnabled = settings.amplitudeThresholdingEnabled; + config.amplitudeThreshold = settings.amplitudeThreshold; - const firstRecordingDate = uiSchedule.getFirstRecordingDate(); - const lastRecordingDate = uiSchedule.getLastRecordingDate(); + config.firstRecordingDateEnabled = uiSchedule.isFirstRecordingDateEnabled(); + config.lastRecordingDateEnabled = uiSchedule.isLastRecordingDateEnabled(); - const requireAcousticConfig = settings.requireAcousticConfig; + config.firstRecordingDate = uiSchedule.getFirstRecordingDate(); + config.lastRecordingDate = uiSchedule.getLastRecordingDate(); - const displayVoltageRange = settings.displayVoltageRange; + config.requireAcousticConfig = settings.requireAcousticConfig; - const minimumAmplitudeThresholdDuration = settings.minimumAmplitudeThresholdDuration; + config.displayVoltageRange = settings.displayVoltageRange; - const amplitudeThresholdingScaleIndex = settings.amplitudeThresholdingScaleIndex; + config.minimumAmplitudeThresholdDuration = settings.minimumAmplitudeThresholdDuration; + + config.amplitudeThresholdingScaleIndex = settings.amplitudeThresholdingScaleIndex; + + config.energySaverModeEnabled = settings.energySaverModeEnabled; + + config.disable48DCFilter = settings.disable48DCFilter; + + config.lowGainRangeEnabled = settings.lowGainRangeEnabled; + + config.timeSettingFromGPSEnabled = settings.timeSettingFromGPSEnabled; + + config.magneticSwitchEnabled = settings.magneticSwitchEnabled; - const energySaverModeEnabled = settings.energySaverModeEnabled; + return config; - const disable48DCFilter = settings.disable48DCFilter; +} + +/* Add listeners to save/load menu options */ - saveLoad.saveConfiguration(timePeriods, ledEnabled, lowVoltageCutoffEnabled, batteryLevelCheckEnabled, sampleRateIndex, gain, recordDuration, sleepDuration, localTime, firstRecordingDate, lastRecordingDate, dutyEnabled, passFiltersEnabled, filterTypeIndex, lowerFilter, higherFilter, amplitudeThresholdingEnabled, amplitudeThreshold, requireAcousticConfig, displayVoltageRange, minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex, energySaverModeEnabled, disable48DCFilter, function (err) { +electron.ipcRenderer.on('save', function () { + + const currentConfig = getCurrentConfiguration(); + + saveLoad.saveConfiguration(currentConfig, function (err) { if (err) { @@ -1139,7 +1161,9 @@ electron.ipcRenderer.on('save', function () { electron.ipcRenderer.on('load', function () { - saveLoad.loadConfiguration(function (timePeriods, ledEnabled, lowVoltageCutoffEnabled, batteryLevelCheckEnabled, sampleRateIndex, gain, dutyEnabled, recordDuration, sleepDuration, localTime, start, end, passFiltersEnabled, filterType, lowerFilter, higherFilter, amplitudeThresholdingEnabled, amplitudeThreshold, requireAcousticConfig, displayVoltageRange, minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex, energySaverModeEnabled, disable48DCFilter) { + const currentConfig = getCurrentConfiguration(); + + saveLoad.loadConfiguration(currentConfig, function (timePeriods, ledEnabled, lowVoltageCutoffEnabled, batteryLevelCheckEnabled, sampleRateIndex, gain, dutyEnabled, recordDuration, sleepDuration, localTime, firstRecordingDateEnabled, firstRecordingDate, lastRecordingDateEnabled, lastRecordingDate, passFiltersEnabled, filterType, lowerFilter, higherFilter, amplitudeThresholdingEnabled, amplitudeThreshold, requireAcousticConfig, displayVoltageRange, minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex, energySaverModeEnabled, disable48DCFilter, lowGainRangeEnabled, timeSettingFromGPSEnabled, magneticSwitchEnabled) { let sortedPeriods = timePeriods; sortedPeriods = sortedPeriods.sort(function (a, b) { @@ -1153,8 +1177,8 @@ electron.ipcRenderer.on('load', function () { scheduleBar.setSchedule(sortedPeriods); uiSchedule.updateTimeList(); - uiSchedule.setFirstRecordingDate(start); - uiSchedule.setLastRecordingDate(end); + uiSchedule.setFirstRecordingDate(firstRecordingDateEnabled, firstRecordingDate); + uiSchedule.setLastRecordingDate(lastRecordingDateEnabled, lastRecordingDate); const settings = { sampleRateIndex: sampleRateIndex, @@ -1173,7 +1197,10 @@ electron.ipcRenderer.on('load', function () { minimumAmplitudeThresholdDuration: minimumAmplitudeThresholdDuration, amplitudeThresholdingScaleIndex: amplitudeThresholdingScaleIndex, energySaverModeEnabled: energySaverModeEnabled, - disable48DCFilter: disable48DCFilter + disable48DCFilter: disable48DCFilter, + lowGainRangeEnabled: lowGainRangeEnabled, + timeSettingFromGPSEnabled: timeSettingFromGPSEnabled, + magneticSwitchEnabled: magneticSwitchEnabled }; uiSettings.fillUI(settings); diff --git a/uiNight.css b/uiNight.css index 46922b1..cab2f5f 100644 --- a/uiNight.css +++ b/uiNight.css @@ -40,6 +40,22 @@ select { border: #FFFFFF; } -#filter-slider .slider-selection { +#low-pass-filter-slider .slider-selection { background: rgb(64, 100, 216); } + +#high-pass-filter-slider .slider-track { + background: rgb(64, 100, 216); +} + +#band-pass-filter-slider .slider-selection { + background: rgb(64, 100, 216); +} + +#amplitude-thresholding-slider .slider-track { + background: rgb(64, 100, 216); +} + +.grey { + color:#808080; +} \ No newline at end of file