first attempt at an automatically calibrating waterfall

This commit is contained in:
Jakob Ketterl 2020-09-12 22:06:12 +02:00
parent 9f9a5ceaa3
commit b9e6ffe03d
4 changed files with 51 additions and 3 deletions

View File

@ -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 {

View File

@ -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% );*/

View File

@ -164,7 +164,7 @@
<div class="openwebrx-panel-line">
<div title="Mute on/off" id="openwebrx-mute-off" class="openwebrx-button" onclick="toggleMute();"><span class="sprite sprite-speaker openwebrx-sliderbtn-img"></span></div>
<input title="Volume" id="openwebrx-panel-volume" class="openwebrx-panel-slider" type="range" min="0" max="150" value="50" step="1" onchange="updateVolume()" oninput="updateVolume()">
<div title="Auto-adjust waterfall colors" id="openwebrx-waterfall-colors-auto" class="openwebrx-button" onclick="waterfall_measure_minmax_now=true;"><span class="sprite sprite-waterfall-auto openwebrx-sliderbtn-img"></span></div>
<div title="Auto-adjust waterfall colors (right-click for continuous)" id="openwebrx-waterfall-colors-auto" class="openwebrx-button"><span class="sprite sprite-waterfall-auto openwebrx-sliderbtn-img"></span></div>
<input title="Waterfall minimum level" id="openwebrx-waterfall-color-min" class="openwebrx-panel-slider" type="range" min="-200" max="100" value="50" step="1" onchange="updateWaterfallColors(0);" oninput="updateVolume()">
</div>
<div class="openwebrx-panel-line">

View File

@ -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() {