mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2024-11-24 23:14:19 +00:00
67 lines
1.8 KiB
HTML
67 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="dygraph.css">
|
|
<title>Get data MLX90614</title>
|
|
<script type="text/javascript" src="dygraph.js"></script>
|
|
|
|
</head>
|
|
<body>
|
|
<h3 style="width:800px; text-align: center;">Read regs Ta & Tobj1 MLX90614</h3>
|
|
<div id="div_v" style="width:800px; height:400px;"></div>
|
|
<script type="text/javascript">
|
|
var datau = [];
|
|
//var datai = [];
|
|
var gu = new Dygraph(
|
|
document.getElementById("div_v"),
|
|
datau,
|
|
{
|
|
labels: ['T', 'Ta', 'To'],
|
|
// drawPoints: true,
|
|
rollPeriod: 10,
|
|
// errorBars: true,
|
|
// showRoller: true,
|
|
y2label: 'To(C°)',
|
|
ylabel: 'Ta(C°)',
|
|
xlabel: 'T(sec)',
|
|
series : {
|
|
'To': { axis: 'y2' }
|
|
}
|
|
// , axes: { y: {valueRange: [4500, 5500] }, y2: {valueRange: [75, 125] }}
|
|
});
|
|
|
|
var oldblkid = 0;
|
|
var rdnextflg = false;
|
|
var cur_idx = 0;
|
|
var sig = 10;
|
|
var wstt;
|
|
function wsping() {ws.send('mlx90614'); wstt = setTimeout(wsping, 50);}
|
|
ws = new WebSocket('ws://rtl871x0/web.cgi');
|
|
ws.binaryType = 'arraybuffer';
|
|
ws.onopen = function(){ ws.send('user=rtl871x:supervisor'); ws.send('sys_debug=0'); wstt = setTimeout(wsping, 50);};
|
|
ws.onmessage = function (event) {
|
|
if(event.data instanceof ArrayBuffer) {
|
|
clearTimeout(wstt);
|
|
var wordarray = new Int16Array(event.data);
|
|
if(wordarray.length > 2) {
|
|
var blksz = wordarray[0];
|
|
if(wordarray.length == blksz*2 + 2) {
|
|
var blkid = wordarray[1] & 0xFFFF;
|
|
if(rdnextflg) {
|
|
cur_idx += (blkid - oldblkid) & 0xFFFF;
|
|
} else rdnextflg = true;
|
|
oldblkid = blkid + blksz;
|
|
for (var i=2; i<wordarray.length; i+=2) {
|
|
if(cur_idx >= 10000 ) datau.shift();
|
|
datau.push([cur_idx * 0.01, (wordarray[i+1]*0.02)-273.15, (wordarray[i]*0.02)-273.15]);
|
|
cur_idx++;
|
|
}
|
|
gu.updateOptions({'file':datau});
|
|
}
|
|
}
|
|
wstt = setTimeout(wsping, 50);
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|