mirror of
https://github.com/ADElectronics/RTL00_WEB_VS.git
synced 2024-11-22 07:14:14 +00:00
46 lines
1.3 KiB
HTML
46 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="dygraph.css">
|
|
<title>Get data ADC</title>
|
|
<script type="text/javascript" src="dygraph.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<h3 style="width:800px; text-align: center;">Read ADC RTL8711AM/RTL8195AM</h3>
|
|
<div id="div_g" style="width:800px; height:400px;"></div>
|
|
<script type="text/javascript">
|
|
var data = [];
|
|
var g = new Dygraph(document.getElementById("div_g"), data,
|
|
{ drawPoints: true,
|
|
showRangeSelector: true,
|
|
showRoller: true, labels: ['X', 'U']});
|
|
|
|
var oldblkid = 0;
|
|
var rdnextflg = false;
|
|
var cur_idx = 0;
|
|
ws = new WebSocket('ws://rtl871x0/web.cgi');
|
|
ws.binaryType = 'arraybuffer';
|
|
ws.onopen = function(){ws.send('adc');ws.send('adc')};
|
|
ws.onmessage = function (event) {
|
|
if(event.data instanceof ArrayBuffer) {
|
|
var wordarray = new Uint16Array(event.data);
|
|
if(wordarray.length > 2) {
|
|
var blksz = wordarray[0];
|
|
if(wordarray.length == blksz + 2) {
|
|
var blkid = wordarray[1];
|
|
if(rdnextflg) {
|
|
cur_idx += (blkid - oldblkid) & 0xFFFF;
|
|
} else rdnextflg = true;
|
|
oldblkid = blkid + blksz;
|
|
for (var i = 2; i < wordarray.length; i++) {
|
|
if(cur_idx > 10000 ) data.shift();
|
|
data.push([cur_idx++, wordarray[i]]);
|
|
}
|
|
g.updateOptions({'file':data});
|
|
}
|
|
}
|
|
if(cur_idx < 10000 ) ws.send("adc");
|
|
}
|
|
}
|
|
</script>
|
|
</body></html>
|