Working waterfall with channel selection

This commit is contained in:
ha7ilm 2017-05-07 16:30:41 +02:00
parent 5b99240944
commit 33f5f57524
5 changed files with 85 additions and 5 deletions

View File

@ -135,6 +135,10 @@ class dsp:
return int(round(self.if_samp_rate()/31.25))
return 0
def secondary_bw(self):
if self.secondary_demodulator == "bpsk31":
return 31.25
def start_secondary_demodulator(self):
if(not self.secondary_demodulator): return
print "[openwebrx] starting secondary demodulator from IF input sampled at %d"%self.if_samp_rate()

View File

@ -153,7 +153,9 @@
<br />We're working on the code right now, so the application might fail.
</div>
<div class="openwebrx-panel" id="openwebrx-panel-digimodes" data-panel-name="digimodes" data-panel-pos="left" data-panel-order="2" data-panel-size="619,210">
<div id="openwebrx-digimode-canvas-container"></div>
<div id="openwebrx-digimode-canvas-container">
<div id="openwebrx-digimode-select-channel"></div>
</div>
<div id="openwebrx-digimode-content-container">
<div class="gradient"></div>
<div id="openwebrx-digimode-content">

View File

@ -830,6 +830,7 @@ img.openwebrx-mirror-img
#openwebrx-digimode-canvas-container canvas
{
position: absolute;
pointer-events: none;
}
#openwebrx-secondary-demod-listbox
@ -944,3 +945,18 @@ img.openwebrx-mirror-img
0%{ transform: rotateX(0deg) rotateY(-90deg) translateX(-5px) scale(1.3); }
100%{ transform: rotateX(0deg) rotateY(0deg) translateX(0) scale(1); }
}
#openwebrx-digimode-select-channel
{
transition: all 500ms;
background-color: Yellow;
display: block;
position: absolute;
pointer-events: none;
height: 100%;
width: 0px;
top: 0px;
left: 0px;
opacity: 0.7;
}

View File

@ -1206,6 +1206,12 @@ function on_ws_recv(evt)
break;
case "secondary_setup":
secondary_demod_init_canvases();
break;
case "if_samp_rate":
if_samp_rate=parseInt(param[1]);
break;
case "secondary_bw":
secondary_bw=parseFloat(param[1]);
break;
case "fft_fps":
fft_fps=parseInt(param[1]);
@ -2241,13 +2247,13 @@ function secondary_demod_create_canvas()
new_canvas.style.height=$(secondary_demod_canvas_container).height()+"px";
console.log(new_canvas.width, new_canvas.height, new_canvas.style.width, new_canvas.style.height);
secondary_demod_current_canvas_actual_line=new_canvas.height-1;
$(secondary_demod_canvas_container).append(new_canvas);
$(secondary_demod_canvas_container).children().last().before(new_canvas);
return new_canvas;
}
function secondary_demod_remove_canvases()
{
$(secondary_demod_canvas_container).children().remove();
$(secondary_demod_canvas_container).children("canvas").remove();
}
function secondary_demod_init_canvases()
@ -2263,6 +2269,7 @@ function secondary_demod_init_canvases()
secondary_demod_current_canvas_actual_line=$(secondary_demod_canvas_container).height()-1;
secondary_demod_current_canvas_index=0;
secondary_demod_canvases_initialized=true;
secondary_demod_update_marker();
}
function secondary_demod_canvases_update_top()
@ -2283,6 +2290,12 @@ function secondary_demod_init()
{
$("#openwebrx-panel-digimodes")[0].openwebrxHidden = true;
secondary_demod_canvas_container = $("#openwebrx-digimode-canvas-container")[0];
$(secondary_demod_canvas_container)
.mousemove(secondary_demod_canvas_container_mousemove)
.mouseup(secondary_demod_canvas_container_mouseup)
.mousedown(secondary_demod_canvas_container_mousedown)
.mouseenter(secondary_demod_canvas_container_mousein)
.mouseleave(secondary_demod_canvas_container_mouseout);
}
function secondary_demod_start(subtype)
@ -2390,3 +2403,48 @@ function secondary_demod_listbox_update()
console.log("update");
secondary_demod_listbox_updating = false;
}
secondary_demod_channel_freq=1000;
function secondary_demod_update_marker()
{
var width = Math.max( (secondary_bw / if_samp_rate) * $(secondary_demod_canvas_container).width(), 5);
var center_at = (secondary_demod_channel_freq / if_samp_rate) * $(secondary_demod_canvas_container).width();
var left = center_at-width / 2;
console.log("sdum", width, left);
$("#openwebrx-digimode-select-channel").width(width).css("left",left+"px")
}
function secondary_demod_update_channel_freq_from_event(evt)
{
var relativeX=(evt.offsetX)?evt.offsetX:evt.layerX;
//console.log("ize", evt, e);
secondary_demod_channel_freq=(relativeX/$(secondary_demod_canvas_container).width()) * if_samp_rate;
secondary_demod_update_marker();
}
secondary_demod_mousedown=false;
function secondary_demod_canvas_container_mousein()
{
$("#openwebrx-digimode-select-channel").css("opacity","0.7");
}
function secondary_demod_canvas_container_mouseout()
{
$("#openwebrx-digimode-select-channel").css("opacity","0");
}
function secondary_demod_canvas_container_mousemove(evt)
{
if(secondary_demod_mousedown) secondary_demod_update_channel_freq_from_event(evt);
}
function secondary_demod_canvas_container_mousedown(evt)
{
if(evt.which==1) secondary_demod_mousedown=true;
}
function secondary_demod_canvas_container_mouseup(evt)
{
if(evt.which==1) secondary_demod_mousedown=false;
secondary_demod_update_channel_freq_from_event(evt);
}

View File

@ -522,7 +522,7 @@ class WebRXHandler(BaseHTTPRequestHandler):
try:
secondary_spectrum_data=dsp.read_secondary_fft(dsp.get_secondary_fft_bytes_to_read())
if len(secondary_spectrum_data) == 0: break
print "len(secondary_spectrum_data)", len(secondary_spectrum_data) #TODO digimodes
# print "len(secondary_spectrum_data)", len(secondary_spectrum_data) #TODO digimodes
rxws.send(self, secondary_spectrum_data, "FFTS")
except: break
myclient.loopstat=42
@ -589,7 +589,7 @@ class WebRXHandler(BaseHTTPRequestHandler):
else:
dsp.set_secondary_demodulator(param_value)
do_secondary_demod = True
rxws.send(self, "MSG secondary_fft_size={0} secondary_setup".format(cfg.digimodes_fft_size))
rxws.send(self, "MSG secondary_fft_size={0} if_samp_rate={1} secondary_bw={2} secondary_setup".format(cfg.digimodes_fft_size, dsp.if_samp_rate(), dsp.secondary_bw()))
if dsp_initialized: dsp.start()
elif param_name=="secondary_offset_freq" and 0 <= int(param_value) <= dsp.if_samp_rate()/2 and cfg.digimodes_enable:
dsp.set_secondary_offset_freq(int(param_value))