diff --git a/package-lock.json b/package-lock.json index 10815c4..02380bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "AudioMoth-Config", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -260,9 +260,9 @@ "dev": true }, "audiomoth-hid": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/audiomoth-hid/-/audiomoth-hid-2.0.3.tgz", - "integrity": "sha512-YsWkr65N+xgqp28SDmRSIu1JHqbWzspMb6d4K/9CkwkX7OP/HvnMRqRzSBnAWkNxNAo4gn9RlbU+aDsrENUQNg==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/audiomoth-hid/-/audiomoth-hid-2.0.4.tgz", + "integrity": "sha512-O2tegtb281PAF/K7amgXV+sC3Q3QmmBWXHP05LpS07Zv7PINSvwT58hEKlhihA+FX6XD7tPyR+MUyLrwsfMpZQ==" }, "balanced-match": { "version": "1.0.0", diff --git a/package.json b/package.json index 93c0f8c..815cbc0 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "AudioMoth-Config", - "version": "1.3.0", + "version": "1.3.1", "description": "The configuration app for the AudioMoth acoustic monitoring device.", "main": "main.js", "author": "openacousticdevices.info", diff --git a/settings/uiFiltering.js b/settings/uiFiltering.js index 0360f55..cec52cf 100644 --- a/settings/uiFiltering.js +++ b/settings/uiFiltering.js @@ -144,6 +144,22 @@ function updateFilterLabel () { } +function calculateSliderPosition (thresholdValue) { + + if (!compressionThresholdValues) calculateCompressionThresholdValues(); + + for (let i = 0; i < compressionThresholdValues.length; i++) { + + if (compressionThresholdValues[i] === thresholdValue) { + + return i * 32768 / (compressionThresholdValues.length - 1); + + } + + } + +} + function calculateCompressionThresholdValues () { var i, j, step; @@ -213,11 +229,11 @@ exports.setFilters = function (enabled, lowerSliderValue, higherSliderValue, fil switch (filterType) { case FILTER_LOW: - setLowPassSliderValue(lowerSliderValue); + setLowPassSliderValue(higherSliderValue); break; case FILTER_HIGH: - setHighPassSliderValue(higherSliderValue); + setHighPassSliderValue(lowerSliderValue); break; case FILTER_BAND: @@ -226,14 +242,14 @@ exports.setFilters = function (enabled, lowerSliderValue, higherSliderValue, fil } - updateFilterLabel(); - for (i = 0; i < filterRadioButtons.length; i++) { filterRadioButtons[i].checked = (i === filterType); } + updateFilterLabel(); + } }; @@ -241,7 +257,8 @@ exports.setFilters = function (enabled, lowerSliderValue, higherSliderValue, fil exports.setAmplitudeThreshold = function (enabled, amplitudeThreshold) { amplitudeThresholdingCheckbox.checked = enabled; - amplitudeThresholdingSlider.setValue(amplitudeThreshold); + + amplitudeThresholdingSlider.setValue(calculateSliderPosition(amplitudeThreshold)); }; @@ -381,8 +398,6 @@ function updateFilterUI () { highPassMaxLabel.style.color = ''; highPassMinLabel.style.color = ''; - updateFilterSliders(); - updateFilterLabel(); filterLabel.style.color = ''; } else { @@ -410,8 +425,6 @@ function updateFilterUI () { filterLabel.textContent = 'Recordings will not be filtered.'; filterLabel.style.color = 'grey'; - updateFilterSliders(); - } } @@ -486,7 +499,13 @@ function addRadioButtonListeners () { for (i = 0; i < filterRadioButtons.length; i++) { - filterRadioButtons[i].addEventListener('change', updateFilterUI); + filterRadioButtons[i].addEventListener('change', function () { + + updateFilterUI(); + updateFilterSliders(); + updateFilterLabel(); + + }); } @@ -499,7 +518,12 @@ exports.prepareUI = function (changeFunction) { updateLifeDisplayOnChange = changeFunction; amplitudeThresholdingCheckbox.addEventListener('change', updateAmplitudeThresholdingUI); - filterCheckbox.addEventListener('change', updateFilterUI); + filterCheckbox.addEventListener('change', function () { + + updateFilterUI(); + updateFilterLabel(); + + }); addRadioButtonListeners(); diff --git a/settings/uiSettings.js b/settings/uiSettings.js index 2fc5b2c..38943e1 100644 --- a/settings/uiSettings.js +++ b/settings/uiSettings.js @@ -139,7 +139,7 @@ exports.fillUI = function (settings) { uiFiltering.setFilters(settings.passFiltersEnabled, settings.lowerFilter, settings.higherFilter, settings.filterType); uiFiltering.updateFilterUI(); - uiFiltering.setAmplitudeThreshold(settings.amplitudeThresholding, settings.amplitudeThreshold); + uiFiltering.setAmplitudeThreshold(settings.amplitudeThresholdingEnabled, settings.amplitudeThreshold); uiFiltering.updateAmplitudeThresholdingUI(); durationInput.setValue(sleepDurationInput, settings.sleepDuration);