diff --git a/htdocs/index.html b/htdocs/index.html index 6c076574..38a59bf3 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -43,9 +43,6 @@
${header}
-
- -
@@ -58,6 +55,9 @@
+
+ +
diff --git a/htdocs/lib/Spectrum.js b/htdocs/lib/Spectrum.js index 421b3c26..f1113634 100644 --- a/htdocs/lib/Spectrum.js +++ b/htdocs/lib/Spectrum.js @@ -1,9 +1,27 @@ -function Spectrum(id) { - this.el = document.getElementById(id); - this.ctx = this.el.getContext("2d"); +function Spectrum(el) { + this.el = el; + this.data = []; + this.ctx = this.el.getContext("2d"); + this.min = 0; + this.max = 0; + + this.ctx.fillStyle = "rgba(255, 255, 255, 0.4)"; } -Spectrum.prototype.draw = function(data) { +Spectrum.prototype.update = function(data) { + for(var j=0; j=this.data.length || data[j]>this.data[j]? + data[j] : this.data[j] + (data[j] - this.data[j]) / 10.0; + } + +// this.min = Math.min(...data); + this.min = waterfall_min_level; + this.max = Math.max(...data); +}; + +Spectrum.prototype.draw = function() { + if (this.el.clientHeight == 0) return; + var vis_freq = get_visible_freq_range(); var vis_center = vis_freq.center; var vis_start = 0.5 - (center_freq - vis_freq.start) / bandwidth; @@ -12,30 +30,25 @@ Spectrum.prototype.draw = function(data) { var data_start = Math.round(fft_size * vis_start); var data_end = Math.round(fft_size * vis_end); var data_width = data_end - data_start; - var data_height = Math.abs(waterfall_min_level - waterfall_max_level); - var spec_width = window.screen.width; - var spec_height = 100; + var data_height = Math.abs(this.max - this.min); + var spec_width = this.el.clientWidth; + var spec_height = this.el.clientHeight; - ctx.clearRect(0, 0, spec_width,spec_height); + this.ctx.clearRect(0, 0, spec_width, spec_height); - if(spec_width > data_width) - { + if(spec_width < data_width) { var x_ratio = data_width / spec_width; var y_ratio = spec_height / data_height; - for(var x=0; x