This commit is contained in:
pvvx 2017-10-17 17:42:32 +03:00
parent 3e8794a4a3
commit 20d954e09e
186 changed files with 357 additions and 447 deletions

View file

@ -3,12 +3,12 @@
<head>
<link rel="stylesheet" href="dygraph.css">
<title>Get data INA219</title>
<script type="text/javascript" src="dygraph.js"></script>
<script type="text/javascript" src="dygraph.min.js"></script>
</head>
<body>
<h3 style="width:800px; text-align: center;">Read regs U & I INA219</h3>
<div id="div_v" style="width:800px; height:400px;"></div>
<h3 style="width:1000px; text-align: center;">Read regs U & I INA219</h3>
<div id="div_v" style="width:1000px; height:400px;"></div>
<script type="text/javascript">
var datau = [];
//var datai = [];
@ -21,23 +21,27 @@ var gu = new Dygraph(
rollPeriod: 100,
// errorBars: true,
// showRoller: true,
y2label: 'U(mV)',
ylabel: 'I(mA)',
y2label: 'U(mV)',
series : {
'U': { axis: 'y2' }
}
// , axes: { y: {valueRange: [4500, 5500] }, y2: {valueRange: [75, 125] }}
, axes: { y2: {valueRange: [3000, 3500] }}
// , axes: { y2: {valueRange: [3000, 3500] }, y: {valueRange: [0, 2] }}
});
var oldblkid = 0;
var rdnextflg = false;
var cur_idx = 0;
var sig = 10;
var ttout = 100;
function wsping() { ws.send('ina219'); wstt = setTimeout(wsping, ttout);};
ws = new WebSocket('ws://rtl871x0/web.cgi');
ws.binaryType = 'arraybuffer';
ws.onopen = function(){ws.send('ina219'); ws.send('pr=0')};
ws.onopen = function(){ws.send('user=rtl871x:supervisor'); ws.send('sys_debug=0'); wstt = setTimeout(wsping, ttout)};
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];
@ -48,14 +52,14 @@ ws.onmessage = function (event) {
} 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, wordarray[i+1], wordarray[i]*0.5 ]);
if(cur_idx > 50000 ) datau.shift();
datau.push([cur_idx, wordarray[i+1]*0.1+0.35, wordarray[i]*0.5 ]);
cur_idx++;
}
gu.updateOptions({'file':datau});
}
}
ws.send("ina219");
wstt = setTimeout(wsping, ttout);
}
}
</script>

View file

@ -3,7 +3,7 @@
<head>
<link rel="stylesheet" href="dygraph.css">
<title>Get data INA219</title>
<script type="text/javascript" src="dygraph.js"></script>
<script type="text/javascript" src="dygraph.min.js"></script>
</head>
<body>
@ -19,26 +19,28 @@ var gu = new Dygraph(
showRangeSelector: true,
labels: ['X', 'U', 'I'],
// drawPoints: true,
rollPeriod: 5,
// rollPeriod: 2,
// errorBars: true,
// showRoller: true,
ylabel: 'U(mV)',
y2label: 'I(mA)',
y2label: 'I(mA)',
series : {
'I': { axis: 'y2' }
}
// , axes: { y: {valueRange: [4500, 5500] }, y2: {valueRange: [75, 125] }}
// , axes: { y: {valueRange: [3000, 3500] }, y2: {valueRange: [0, 30] }}
});
var oldblkid = 0;
var rdnextflg = false;
var cur_idx = 0;
var sig = 10;
function wsping() {ws.send('ina219'); wstt = setTimeout(wsping, 50);};
ws = new WebSocket('ws://rtl871x0/web.cgi');
ws.binaryType = 'arraybuffer';
ws.onopen = function(){ws.send('ina219'); ws.send('pr=0')};
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];
@ -49,14 +51,14 @@ ws.onmessage = function (event) {
} else rdnextflg = true;
oldblkid = blkid + blksz;
for (var i=2; i<wordarray.length; i+=2) {
if(cur_idx > 50000 ) datau.shift();
datau.push([cur_idx, wordarray[i]*0.5, wordarray[i+1]*0.1]);
if(cur_idx > 10000 ) datau.shift();
datau.push([cur_idx*0.001, wordarray[i]*0.5, wordarray[i+1]*0.1]);
cur_idx++;
}
gu.updateOptions({'file':datau});
}
wstt = setTimeout(wsping, 50);
}
ws.send("ina219");
}
}
</script>