mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2026-03-23 11:04:50 +00:00
update
This commit is contained in:
parent
1c773d745a
commit
2bc9cc61b3
22 changed files with 1244 additions and 108 deletions
6
WEBFiles/dygraph.min.js
vendored
Normal file
6
WEBFiles/dygraph.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
110
WEBFiles/i219ws.htm
Normal file
110
WEBFiles/i219ws.htm
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
~inc:grfx1.inc~
|
||||
<td width="50%">U: <span id="xdata1" style="font-weight:bold">?</span> V, I: <span id="xdata2" style="font-weight:bold">?</span> mA</td>
|
||||
<td style="font-size:10pt">
|
||||
<div id="sl"></div>Scale: <span id="toutid" style="font-weight:bold">?</span> ms per line</td></tr></table>
|
||||
<canvas id="mycanvas1" width="620pt" height="150pt"></canvas>
|
||||
<canvas id="mycanvas2" width="620pt" height="250pt"></canvas>
|
||||
SampleRate: <span id="smprate" style="font-weight:bold">?</span> sps
|
||||
</div>
|
||||
<script src="/smoothie.js" type="text/javascript"></script>
|
||||
<script src="/slider.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var line1 = new TimeSeries();
|
||||
var line2 = new TimeSeries();
|
||||
var oldtimeout = 20;
|
||||
var smoothie1 = new SmoothieChart({ millisPerPixel: oldtimeout, maxValueScale:1.05, interpolation:'linear', maxDataSetLength: 2000,
|
||||
grid: { strokeStyle:'rgb(75, 75, 75)', lineWidth: 1, millisPerLine: oldtimeout*50, verticalSections: 6 },
|
||||
labels: { fillStyle:'rgb(255, 255, 255)' }
|
||||
});
|
||||
var smoothie2 = new SmoothieChart({ millisPerPixel: oldtimeout, maxValueScale:1.05, interpolation:'linear', maxDataSetLength: 2000,
|
||||
grid: { strokeStyle:'rgb(75, 75, 75)', lineWidth: 1, millisPerLine: oldtimeout*50, verticalSections: 6 },
|
||||
labels: { fillStyle:'rgb(255, 255, 255)' }
|
||||
});
|
||||
smoothie1.addTimeSeries(line1, { strokeStyle:'rgb(0, 255, 0)', lineWidth: 2 });
|
||||
smoothie2.addTimeSeries(line2, { strokeStyle:'rgb(255, 0, 255)', lineWidth: 2 });
|
||||
smoothie1.streamTo(document.getElementById("mycanvas1"));
|
||||
smoothie2.streamTo(document.getElementById("mycanvas2"));
|
||||
var mysl1 = new slider('sl', 333, 1, 200, 0);
|
||||
var ttout = 20;
|
||||
function NewTimeScale(t) {
|
||||
if(oldtimeout != t) {
|
||||
oldtimeout = t;
|
||||
smoothie1.options.grid.millisPerLine = t*50;
|
||||
smoothie1.options.millisPerPixel = t;
|
||||
smoothie2.options.grid.millisPerLine = t*50;
|
||||
smoothie2.options.millisPerPixel = t
|
||||
ttout = t*2;
|
||||
if(ttout < 2) ttout = 2;
|
||||
else if(ttout > 250) ttout = 250;
|
||||
document.getElementById('toutid').innerHTML = t*50; //+'/'+ttout
|
||||
} }
|
||||
mysl1.setValue(oldtimeout);
|
||||
var wstt;
|
||||
function wsSendMsg() {
|
||||
ws.send('ina219');
|
||||
wstt = setTimeout(wsSendMsg, 1000);
|
||||
}
|
||||
var smprate = 1000;
|
||||
var sttim;
|
||||
var fsmpr = 0;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
var cur_idx = 0;
|
||||
var sig = 10;
|
||||
function onMessage(evt) {
|
||||
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;
|
||||
if(!fsmpr) {
|
||||
sttim = new Date().getTime();
|
||||
fsmpr = 1;
|
||||
setInterval(wsSmpRate, 1000);
|
||||
} else {
|
||||
u = 0; s = 0; cnt = 0;
|
||||
tt = new Date().getTime();
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
u += wordarray[i];
|
||||
s += wordarray[i+1];
|
||||
cnt++;
|
||||
}
|
||||
cur_idx += cnt;
|
||||
u = u*0.0005/cnt;
|
||||
s = 0.15 + s*0.1/cnt;
|
||||
line1.append(new Date().getTime(), u, true);
|
||||
document.getElementById('xdata1').innerHTML = u.toFixed(3);
|
||||
line2.append(new Date().getTime(), s, true);
|
||||
document.getElementById('xdata2').innerHTML = s.toFixed(2);
|
||||
} } }
|
||||
wstt = setTimeout(wsSendMsg, ttout);
|
||||
} }
|
||||
function wsSmpRate() {
|
||||
smprate = (new Date().getTime() - sttim) * 1000 / cur_idx;
|
||||
document.getElementById('smprate').innerHTML = smprate.toFixed(1);
|
||||
}
|
||||
function onOpen(evt) {
|
||||
ctim = new Date().getTime();
|
||||
ws.binaryType = 'arraybuffer';
|
||||
document.getElementById('xdata1').style.color = 'rgb(0, 155, 100)';
|
||||
document.getElementById('xdata2').style.color = 'rgb(155, 0, 100)';
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('sys_debug=0');
|
||||
wstt = setTimeout(wsSendMsg, ttout);
|
||||
}
|
||||
var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
function RunWebSocket() {
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.onopen = function(evt) {onOpen(evt)};
|
||||
ws.onmessage = function(evt) {onMessage(evt)};
|
||||
}
|
||||
RunWebSocket();
|
||||
</script>
|
||||
~inc:footer.inc~
|
||||
</body></html>
|
||||
119
WEBFiles/ina2.css
Normal file
119
WEBFiles/ina2.css
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* Default styles for the dygraphs charting library.
|
||||
*/
|
||||
|
||||
.dygraph-legend {
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
width: 250px; /* labelsDivWidth */
|
||||
/*
|
||||
dygraphs determines these based on the presence of chart labels.
|
||||
It might make more sense to create a wrapper div around the chart proper.
|
||||
top: 0px;
|
||||
right: 2px;
|
||||
*/
|
||||
background: white;
|
||||
line-height: normal;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* styles for a solid line in the legend */
|
||||
.dygraph-legend-line {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: .5ex;
|
||||
padding-left: 1em;
|
||||
height: 1px;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
/* border-bottom-color is set based on the series color */
|
||||
}
|
||||
|
||||
/* styles for a dashed line in the legend, e.g. when strokePattern is set */
|
||||
.dygraph-legend-dash {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: .5ex;
|
||||
height: 1px;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
/* border-bottom-color is set based on the series color */
|
||||
/* margin-right is set based on the stroke pattern */
|
||||
/* padding-left is set based on the stroke pattern */
|
||||
}
|
||||
|
||||
.dygraph-roller {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* This class is shared by all annotations, including those with icons */
|
||||
.dygraph-annotation {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* This class only applies to annotations without icons */
|
||||
/* Old class name: .dygraphDefaultAnnotation */
|
||||
.dygraph-default-annotation {
|
||||
border: 1px solid black;
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dygraph-axis-label {
|
||||
/* position: absolute; */
|
||||
/* font-size: 14px; */
|
||||
z-index: 10;
|
||||
line-height: normal;
|
||||
overflow: hidden;
|
||||
color: black; /* replaces old axisLabelColor option */
|
||||
}
|
||||
|
||||
.dygraph-axis-label-x {
|
||||
}
|
||||
|
||||
.dygraph-axis-label-y {
|
||||
color: rgb(51,204,204);
|
||||
}
|
||||
|
||||
.dygraph-axis-label-y2 {
|
||||
color: rgb(255,100,100);
|
||||
}
|
||||
|
||||
.dygraph-title {
|
||||
font-weight: bold;
|
||||
z-index: 10;
|
||||
text-align: center;
|
||||
/* font-size: based on titleHeight option */
|
||||
}
|
||||
|
||||
.dygraph-xlabel {
|
||||
text-align: center;
|
||||
/* font-size: based on xLabelHeight option */
|
||||
}
|
||||
|
||||
/* For y-axis label */
|
||||
.dygraph-label-rotate-left {
|
||||
text-align: center;
|
||||
/* See http://caniuse.com/#feat=transforms2d */
|
||||
transform: rotate(90deg);
|
||||
-webkit-transform: rotate(90deg);
|
||||
-moz-transform: rotate(90deg);
|
||||
-o-transform: rotate(90deg);
|
||||
-ms-transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* For y2-axis label */
|
||||
.dygraph-label-rotate-right {
|
||||
text-align: center;
|
||||
/* See http://caniuse.com/#feat=transforms2d */
|
||||
transform: rotate(-90deg);
|
||||
-webkit-transform: rotate(-90deg);
|
||||
-moz-transform: rotate(-90deg);
|
||||
-o-transform: rotate(-90deg);
|
||||
-ms-transform: rotate(-90deg);
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<div class="content">
|
||||
<h2 class="title">Debug and Tests</h2>
|
||||
<p class="center">
|
||||
Chart <a href="/heap.htm">'heap'</a>, <a href="/tst.htm">ST-AP RSSI</a>, <a href="/i219ws.htm">INA219</a><br><br>
|
||||
Chart <a href="/heap.htm">'heap'</a>, <a href="/tst.htm">ST-AP RSSI</a>, <a href="/wso_audio.htm">ADC Audio</a><br><br>
|
||||
<a href='/protect/timeout.htm?sys_restart=12345'>System Restart</a><br><br>
|
||||
Counter erase the last flash sector config: ~sys_rdec0x980FE000~<br><br>
|
||||
</p>
|
||||
|
|
|
|||
BIN
WEBFiles/rtl2.gif
Normal file
BIN
WEBFiles/rtl2.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
166
WEBFiles/wso_audio.htm
Normal file
166
WEBFiles/wso_audio.htm
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="ina2.css">
|
||||
<title>Get ADC data</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: auto; width: auto; text-align: center;">
|
||||
<div id='div_v' style="height:512px;">
|
||||
<canvas id='scope' width=976 height=512></canvas>
|
||||
</div>
|
||||
Window: <span id='wdsize'>?</span> sec, Sample Rate: <span id='smprate'>?</span> sps
|
||||
<div>
|
||||
<span id='labdiv'>?</span>
|
||||
<input type="button" id="butOnOff" value="Stop">
|
||||
<input type="button" id="butSave" value="Save data.csv"><br>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
var $ = function(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
var ctx = $('scope').getContext('2d');
|
||||
//===================================
|
||||
// | adc1 adc2 adc4 adc8
|
||||
//----+------------------------------
|
||||
//adca| 12200 6100 3050 1525
|
||||
//adcb| 24400 12200 6100 3050
|
||||
//adcc| 48800 24400 12200 6100
|
||||
//adcd| 97600 48800 24400 12200
|
||||
//===================================
|
||||
var data_ch1 = [];
|
||||
var smprate = 0;
|
||||
var smpbuffer = ctx.canvas.width*10;
|
||||
zero_level = 10500;
|
||||
trigger = 32768-zero_level/2;
|
||||
var sttim = 0;
|
||||
var cur_idx = 0;
|
||||
var old_idx = 0;
|
||||
var frend = 0;
|
||||
function wsSmpRate() {
|
||||
var idx = cur_idx, tt = new Date().getTime();
|
||||
var sps = (idx - old_idx) * 2000/ (tt - sttim);
|
||||
sttim = tt; old_idx = idx;
|
||||
if(smprate) smprate = smprate * 0.9 + sps * 0.1;
|
||||
else smprate = sps;
|
||||
$('smprate').innerHTML = smprate.toFixed(1);
|
||||
$('wdsize').innerHTML = ($('scope').width/smprate).toFixed(3);
|
||||
$('labdiv').innerHTML = 'Render ' + frend + ' Hz';
|
||||
frend = 0;
|
||||
}
|
||||
var rend = 1;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
$("butOnOff").onclick = function() {
|
||||
if(rend) {rend = 0; $("butOnOff").value = "Run";}
|
||||
else {rend = 1; $("butOnOff").value = "Stop";}
|
||||
}
|
||||
var gu;
|
||||
function wsping() {
|
||||
clearTimeout(wstt);
|
||||
ws.send('adc*');
|
||||
wstt = setTimeout(wsping, 100);
|
||||
}
|
||||
var scope_height = ctx.canvas.height;
|
||||
var scaling = scope_height / (65536 - zero_level);
|
||||
function draw() {
|
||||
var scope_width = ctx.canvas.width;
|
||||
ctx.fillStyle = 'rgba(0, 20, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, scope_width, scope_height);
|
||||
ctx.lineWidth = 1;
|
||||
ctx.beginPath();
|
||||
var data_start = scope_width/2;
|
||||
var timeData1 = data_ch1.slice();
|
||||
var data_max = timeData1.length - scope_width;
|
||||
if(scope_width > data_max) scope_width = data_max;
|
||||
var risingEdge = data_start;
|
||||
while(risingEdge < data_max && timeData1[risingEdge++] < trigger);
|
||||
while(risingEdge < data_max && timeData1[risingEdge++] > trigger);
|
||||
if(risingEdge >= data_max) {
|
||||
risingEdge = data_start;
|
||||
ctx.strokeStyle = 'rgb(0, 0, 255)';
|
||||
} else ctx.strokeStyle = 'rgb(0, 255, 0)';
|
||||
risingEdge -= data_start;
|
||||
for(var x = 0; x < scope_width; x++)
|
||||
ctx.lineTo(x, scope_height - timeData1[x + risingEdge] * scaling);
|
||||
ctx.stroke();
|
||||
frend++;
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
//var wsUri = 'ws://rtl871x1/web.cgi'
|
||||
var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = function(){
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('sys_debug=0');
|
||||
ws.send('adcz'); // drv deinit
|
||||
ws.send('adcx'); // mode Audio
|
||||
ws.send('adc1'); // decimation
|
||||
ws.send('adcd'); // xclk
|
||||
wstt = setTimeout(wsping,50);
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
clearTimeout(wstt);
|
||||
var wordarray = new Uint16Array(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;
|
||||
sttim = new Date().getTime();
|
||||
setInterval(function(){wsSmpRate()}, 1000);
|
||||
draw();
|
||||
}
|
||||
oldblkid = blkid + blksz;
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
if(rend) {
|
||||
if(data_ch1.length > smpbuffer) {
|
||||
data_ch1.shift();
|
||||
data_ch1.shift();
|
||||
}
|
||||
data_ch1.push([wordarray[i]-zero_level]);
|
||||
data_ch1.push([wordarray[i+1]-zero_level]);
|
||||
}
|
||||
cur_idx++;
|
||||
} }
|
||||
wstt = setTimeout(wsping, 5);
|
||||
} } }
|
||||
function convertArrayOfObjectsToCSV(value){
|
||||
var result, ctr, keys, columnDelimiter, lineDelimiter, data;
|
||||
data = value.data || null;
|
||||
if (data == null || !data.length) return null;
|
||||
columnDelimiter = value.columnDelimiter || ';';
|
||||
lineDelimiter = value.lineDelimiter || '\n';
|
||||
keys = Object.keys(data[1]);
|
||||
result = '';
|
||||
result += keys.join(columnDelimiter);
|
||||
result += lineDelimiter;
|
||||
data.forEach(function(item){
|
||||
ctr = 0;
|
||||
keys.forEach(function(key){
|
||||
if (ctr > 0)
|
||||
result += columnDelimiter;
|
||||
result += item[key];
|
||||
ctr++;
|
||||
});
|
||||
result += lineDelimiter;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
$("butSave").onclick = function() {
|
||||
var csv = convertArrayOfObjectsToCSV({data: datau});
|
||||
if (!csv.match(/^data:text\/csv/i)) {csv = 'data:text/csv;charset=utf-8,' + csv;}
|
||||
var encodedUri = encodeURI(csv);
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('href', encodedUri);
|
||||
link.setAttribute('download',"data.csv");
|
||||
link.click();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue