From b9e6ffe03db5709e7cd200fb53a993b0f48cd17e Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 12 Sep 2020 22:06:12 +0200 Subject: [PATCH] first attempt at an automatically calibrating waterfall --- htdocs/css/openwebrx-globals.css | 5 ++++ htdocs/css/openwebrx.css | 2 +- htdocs/index.html | 2 +- htdocs/openwebrx.js | 45 +++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/htdocs/css/openwebrx-globals.css b/htdocs/css/openwebrx-globals.css index 9868894..8417ffd 100644 --- a/htdocs/css/openwebrx-globals.css +++ b/htdocs/css/openwebrx-globals.css @@ -11,6 +11,11 @@ html, body display: inline-block; } +.openwebrx-button.highlighted .sprite { + background-image: linear-gradient(rgba(255,127,0,0.5), rgba(255,127,0,0.5)), url(../gfx/openwebrx-sprites.png); + background-blend-mode: overlay; +} + @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) { .sprite { diff --git a/htdocs/css/openwebrx.css b/htdocs/css/openwebrx.css index 93b26db..441d4e1 100644 --- a/htdocs/css/openwebrx.css +++ b/htdocs/css/openwebrx.css @@ -435,7 +435,7 @@ input[type=range]:disabled { display: inline-block; } -.openwebrx-button:hover, .openwebrx-demodulator-button.highlighted +.openwebrx-button:hover, .openwebrx-demodulator-button.highlighted, .openwebrx-button.highlighted { /*background:-webkit-gradient( linear, left top, left bottom, color-stop(0.0 , #3F3F3F), color-stop(1, #777777) ); background:-moz-linear-gradient( center top, #373737 5%, #4F4F4F 100% );*/ diff --git a/htdocs/index.html b/htdocs/index.html index e963e6d..ed05093 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -164,7 +164,7 @@
-
+
diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index c71c2df..d072c71 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -101,6 +101,7 @@ function waterfallColorsDefault() { waterfall_max_level = waterfall_max_level_default; $("#openwebrx-waterfall-color-min").val(waterfall_min_level); $("#openwebrx-waterfall-color-max").val(waterfall_max_level); + waterfallColorsContinuousReset(); } function waterfallColorsAuto(levels) { @@ -109,7 +110,32 @@ function waterfallColorsAuto(levels) { var max_level = levels.max + waterfall_auto_level_margin.max; max_level = Math.max(min_level + (waterfall_auto_level_margin.min_range || 0), max_level); $("#openwebrx-waterfall-color-max").val(max_level); - updateWaterfallColors(0); + waterfall_min_level = min_level; + waterfall_max_level = max_level; +} + +var waterfall_continuous = { + min: -150, + max: 0 +}; + +function waterfallColorsContinuousReset() { + waterfall_continuous.min = waterfall_min_level; + waterfall_continuous.max = waterfall_max_level; +} + +function waterfallColorsContinuous(levels) { + if (levels.max > waterfall_continuous.max + 1) { + waterfall_continuous.max += 1; + } else if (levels.max < waterfall_continuous.max - 1) { + waterfall_continuous.max -= .1; + } + if (levels.min < waterfall_continuous.min - 1) { + waterfall_continuous.min -= 1; + } else if (levels.min > waterfall_continuous.min + 1) { + waterfall_continuous.min += .1; + } + waterfallColorsAuto(waterfall_continuous); } function setSmeterRelativeValue(value) { @@ -1050,6 +1076,7 @@ function clear_metadata() { } var waterfall_measure_minmax_now = false; +var waterfall_measure_minmax_continuous = false; function waterfall_measure_minmax_do(what) { // this is based on an oversampling factor of about 1,25 @@ -1267,6 +1294,12 @@ function waterfall_add(data) { var levels = waterfall_measure_minmax_do(data); waterfall_measure_minmax_now = false; waterfallColorsAuto(levels); + waterfallColorsContinuousReset(); + } + + if (waterfall_measure_minmax_continuous) { + var level = waterfall_measure_minmax_do(data); + waterfallColorsContinuous(level); } //Add line to waterfall image @@ -1358,6 +1391,16 @@ function initSliders() { $slider.val(val + step); $slider.trigger('change'); }); + + var waterfallAutoButton = $('#openwebrx-waterfall-colors-auto'); + waterfallAutoButton.on('click', function(ev) { + waterfall_measure_minmax_now=true; + }).on('contextmenu', function(){ + waterfall_measure_minmax_continuous = !waterfall_measure_minmax_continuous; + waterfallColorsContinuousReset(); + waterfallAutoButton[(waterfall_measure_minmax_continuous ? 'add' : 'remove') + 'Class']('highlighted') + return false; + }); } function digimodes_init() {