more reliable JS + fixed broken second marks

master
Ondřej Hruška 8 years ago
parent 09aa63e5a0
commit f3611453ad
  1. 2
      esp_meas.pro.user
  2. 2
      html/css/app.css
  3. 4
      html/js/all.js
  4. 6
      html/pages/sgm.html
  5. 2
      html_src/css/app.css
  6. 2
      html_src/css/app.css.map
  7. 2
      html_src/js-src/lib/chibi.js
  8. 10
      html_src/js-src/notif.js
  9. 47
      html_src/js-src/page_spectrogram.js
  10. 28
      html_src/js-src/page_waveform.js
  11. 4
      html_src/js/all.js
  12. 2
      html_src/js/all.js.map
  13. 6
      html_src/page_spectrogram.php
  14. 6
      html_src/sass/pages/_wfm.scss
  15. 8
      user/page_waveform.c
  16. 3
      user/sampling.c

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.6.1, 2016-04-05T20:46:29. -->
<!-- Written by QtCreator 3.6.1, 2016-04-05T21:58:52. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -45,7 +45,7 @@
<label for="tile-x">Tile</label>
<input id="tile-x" type="number" min=1 step=1 value=4>
×
<input id="tile-y" type="number" min=1 step=1 value=4>
<input id="tile-y" type="number" min=1 step=1 value=1>
</div>
<div>
<label for="freq">f<sub>bw</sub> <span class="mq-normal-min nb">=</span><span class="mq-tablet-max nb">(Hz)</span></label>
@ -53,8 +53,8 @@
<span class="mq-normal-min">Hz</span>
</div>
<div>
<label for="interval">t<sub>s</sub> <span class="mq-normal-min nb">=</span><span class="mq-tablet-max" style="font-weight:normal;">(ms)</span></label>
<input id="interval" type="number" value="500" step=100 min=0>
<label for="interval">Interval <span class="mq-tablet-max" style="font-weight:normal;">(ms)</span></label>
<input id="interval" type="number" value="0" step=100 min=0>
<span class="mq-normal-min">ms</span>
</div>
<div>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -628,6 +628,8 @@
query = null;
}
// FIXME the XHR sometimes seemingly silently fails
xhr = new XMLHttpRequest(); // we dont support IE < 9
if (xhr) {

@ -2,19 +2,25 @@ var notify = (function () {
var nt = {};
var sel = '#notif';
var hideTmeo1;
var hideTmeo2;
nt.show = function (message, timeout) {
$(sel).html(message);
modal.show(sel);
clearTimeout(hideTmeo1);
clearTimeout(hideTmeo2);
if (!_.isUndefined(timeout)) {
setTimeout(nt.hide, timeout);
hideTmeo1 = setTimeout(nt.hide, timeout);
}
};
nt.hide = function () {
var $m = $(sel);
$m.removeClass('visible');
setTimeout(function () {
hideTmeo2 = setTimeout(function () {
$m.addClass('hidden');
}, 250); // transition time
};

@ -82,10 +82,11 @@ var page_spectrogram = (function () {
}
function shiftSg() {
var imageData = ctx.getImageData(plot.x+plot.dx, plot.y, plot.w-plot.dx, plot.h+6);
var imageData = ctx.getImageData(plot.x+plot.dx, plot.y, plot.w-plot.dx, plot.h+10);
ctx.fillStyle = 'black';
ctx.fillRect(plot.x, plot.y, plot.w, plot.h);
ctx.clearRect(plot.x, plot.y+plot.h+1, plot.w, 10); // clear the second marks box
ctx.putImageData(imageData, plot.x, plot.y);
}
@ -123,7 +124,7 @@ var page_spectrogram = (function () {
}
// mark every 10 s
console.log('remain',msElapsed(lastMarkMs));
//console.log('remain',msElapsed(lastMarkMs));
if (msElapsed(lastMarkMs) >= 950) {
lastMarkMs = msNow();
@ -138,8 +139,6 @@ var page_spectrogram = (function () {
ctx.moveTo(plot.x+plot.w-.5, plot.y+plot.h+1);
ctx.lineTo(plot.x+plot.w-.5, plot.y+plot.h+1+(long?6:2));
ctx.stroke();
} else {
ctx.clearRect(plot.x+plot.w-1, plot.y+plot.h+1,2,10);
}
}
@ -231,29 +230,25 @@ var page_spectrogram = (function () {
var totalBins = (plot.h / plot.dy);
var totalHz = totalBins*perBin;
console.log("perbin=",perBin,"totalBins=",totalBins,"totalHz=",totalHz);
//console.log("perbin=",perBin,"totalBins=",totalBins,"totalHz=",totalHz);
var step;
var steps = [
[200, 10],
[1000, 50],
[3000, 250],
[5000, 500],
[10000, 1000],
[25000, 2500],
[50000, 5000],
[100000, 10000],
[500000, 50000],
[1000000, 100000],
[1/0, 250000],
];
for(var i = 0; i <= steps.length; i++) {
if (totalHz <= steps[i][0]) {
step = steps[i][1];
break;
// get the best step size
var steps = [10, 25, 50];
var multiplier = 1;
var suc = false;
do {
for (var i = 0; i < steps.length; i++) {
if ((totalHz / (steps[i] * multiplier)) <= 21) {
step = (steps[i] * multiplier);
suc = true;
break;
}
}
}
if (suc) break;
multiplier *= 10;
} while (true);
step = step/perBin;
@ -263,8 +258,6 @@ var page_spectrogram = (function () {
ctx.strokeStyle = 'white';
ctx.textAlign = 'left';
var kilos = totalHz >= 10000;
// labels and dashes
for(var i = 0; i <= totalBins+step; i+= step) {
if (i >= totalBins) {
@ -332,13 +325,13 @@ var page_spectrogram = (function () {
var count = +$('#count').val();
var tile = Math.max(1, plot.h/(count/2));
$('#tile-x').val(tile);
$('#tile-x').val(Math.max(4, tile)); // use width 4 for smaller by default (rolls more nicely)
$('#tile-y').val(tile);
});
// chain Y with X
$('#tile-y').on('change', function() {
$('#tile-x').val($(this).val());
$('#tile-x').val(Math.max(4,$(this).val()));
});
$('#go-btn').on('click', function() {

@ -13,6 +13,8 @@ var page_waveform = (function () {
var zoomSavedX, zoomSavedY;
var readXhr; // read xhr
var opts = {
count: 0, // sample count
freq: 0 // sampling freq
@ -145,26 +147,17 @@ var page_waveform = (function () {
if (status != 200) {
errorMsg("Request failed.", 1000);
if (autoReload)
toggleAutoReload(); // turn it off.
} else {
var j = JSON.parse(resp);
if (!j.success) {
errorMsg("Sampling failed.", 1000);
if (autoReload)
toggleAutoReload(); // turn it off.
return;
} else {
buildChart(j);
}
buildChart(j);
if (autoReload)
arTimeout = setTimeout(requestReload, Math.max(0, autoReloadTime - msElapsed(lastLoadMs)));
}
if (autoReload)
arTimeout = setTimeout(requestReload, Math.max(0, autoReloadTime - msElapsed(lastLoadMs)));
}
function readInputs() {
@ -173,7 +166,10 @@ var page_waveform = (function () {
}
function requestReload() {
if (readoutPending) return false;
if (readoutPending) {
errorMsg("Request already pending - aborting.");
readXhr.abort();
}
readoutPending = true;
lastLoadMs = msNow();
@ -181,7 +177,7 @@ var page_waveform = (function () {
var n = opts.count;
var fs = opts.freq;
var url = _root+'/measure/'+dataFormat+'?n='+n+'&fs='+fs;
$().get(url, onRxData, estimateLoadTime(fs,n));
readXhr = $().get(url, onRxData, estimateLoadTime(fs,n));
return true;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -22,7 +22,7 @@
<label for="tile-x">Tile</label>
<input id="tile-x" type="number" min=1 step=1 value=4>
×
<input id="tile-y" type="number" min=1 step=1 value=4>
<input id="tile-y" type="number" min=1 step=1 value=1>
</div>
<div>
<label for="freq">f<sub>bw</sub> <span class="mq-normal-min nb">=</span><span class="mq-tablet-max nb">(Hz)</span></label>
@ -30,8 +30,8 @@
<span class="mq-normal-min">Hz</span>
</div>
<div>
<label for="interval">t<sub>s</sub> <span class="mq-normal-min nb">=</span><span class="mq-tablet-max" style="font-weight:normal;">(ms)</span></label>
<input id="interval" type="number" value="500" step=100 min=0>
<label for="interval">Interval <span class="mq-tablet-max" style="font-weight:normal;">(ms)</span></label>
<input id="interval" type="number" value="0" step=100 min=0>
<span class="mq-normal-min">ms</span>
</div>
<div>

@ -27,9 +27,15 @@
}
}
// -- spectrogram --
#tile-cfg input {
width: 3em;
}
#interval {
width: 4.5em;
}
}
.Box.chartbox {

@ -42,8 +42,14 @@ static int FLASH_FN tplSamplesJSON(MEAS_FORMAT fmt, HttpdConnData *connData, cha
tplReadSamplesJSON_state *st = *arg;
if (token == NULL) {
// end of template, cleanup
// end of template, or connection closed.
if (st != NULL) free(st);
// make sure resources are freed
if (!meas_is_closed()) {
meas_close();
}
return HTTPD_CGI_DONE; // cleanup
}

@ -226,8 +226,7 @@ bool FLASH_FN meas_request_data(MEAS_FORMAT format, uint16_t count, uint32_t fre
info("Requesting data capture - %d samples @ %d Hz, fmt %d.", count, freq, format);
if (rd.pending) {
error("Acquire request already in progress.");
return false;
warn("Acquire request already in progress; shouldn't happen, IGNORING");
}
if (sbmp_ep_handshake_status(dlnk_ep) != SBMP_HSK_SUCCESS) {

Loading…
Cancel
Save