From 3e833b3bdcf0e23460777bc383d2c165c507dc85 Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Wed, 10 Aug 2016 13:46:42 +0200 Subject: [PATCH] Rearranged some code into getY --- htdocs/openwebrx.js | 47 +++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 13171fc..5955be6 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1795,17 +1795,28 @@ var mathbox_clear_data = function() mathbox_data_current_depth = 0; } -var mathbox_get_data_line = function(x) //x counts from 0 to mathbox_data_current_depth +//var mathbox_get_data_line = function(x) //x counts from 0 to mathbox_data_current_depth +//{ +// return (mathbox_data_max_depth + mathbox_data_index - mathbox_data_current_depth + x - 1) % mathbox_data_max_depth; +//} +// +//var mathbox_data_index_valid = function(x) //x counts from 0 to mathbox_data_current_depth +//{ +// return xmathbox_data_max_depth-mathbox_data_current_depth; } + function waterfall_add(data) { if(!waterfall_setup_done) return; @@ -1998,23 +2009,31 @@ function mathbox_init() //var remap = function (v) { return Math.sqrt(.5 + .5 * v); }; - var points = view.area({ - expr: function (emit, x, z, i, j, t) { - var xIndex = ((x+1)/2.0)*fft_size; //x: frequency - var zIndex = z*(mathbox_data_max_depth-1); //z: time + var getY = function(x,z) + { + var xIndex = Math.trunc(((x+1)/2.0)*fft_size); //x: frequency + var zIndex = Math.trunc(z*(mathbox_data_max_depth-1)); //z: time var realZIndex = mathbox_get_data_line(zIndex); - if(!mathbox_data_index_valid(zIndex)) return; - if(realZIndex>=(mathbox_data_max_depth-1)) console.log("realZIndexundef", realZIndex, zIndex); + if(!mathbox_data_index_valid(zIndex)) return undefined; + //if(realZIndex>=(mathbox_data_max_depth-1)) console.log("realZIndexundef", realZIndex, zIndex); var index = Math.trunc(xIndex + realZIndex * fft_size); - if(mathbox_data[index]==undefined) console.log("Undef", index, mathbox_data.length, zIndex, + /*if(mathbox_data[index]==undefined) console.log("Undef", index, mathbox_data.length, zIndex, realZIndex, mathbox_data_max_depth, - mathbox_data_current_depth, mathbox_data_index); - var dBValue = mathbox_data[index]; + mathbox_data_current_depth, mathbox_data_index);*/ + var dBValue = mathbox_data[index]; + //y=1; if(dBValue>waterfall_max_level) y = 1; else if(dBValue