Add files via upload
This commit is contained in:
parent
950f71bc68
commit
8395c497ff
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"tools": {
|
||||||
|
"temperature": {
|
||||||
|
"label": "Temperature",
|
||||||
|
"path": "temperature.html"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"content-security-policy": "default-src 'self' 'unsafe-inline' 'unsafe-eval'"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
||||||
|
Copyright (c) 2010, Joe Walnes
|
||||||
|
Copyright (c) 2010-2013, Joe Walnes
|
||||||
|
2013-2014, Drew Noakes
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Temperature</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link href="../base1/cockpit.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="../base1/jquery.js"></script>
|
||||||
|
<script src="../base1/cockpit.js"></script>
|
||||||
|
<script type="text/javascript" src="smoothie.js"></script>
|
||||||
|
<script type="text/javascript" src="temperature.js"></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
tr {
|
||||||
|
font-size: 16pt
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body onresize="resize_canvas()">
|
||||||
|
<div align=center>
|
||||||
|
<table id=table style="width:100%;font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif">
|
||||||
|
<tr>
|
||||||
|
<th colspan="2" style="font-size:24pt;text-align:center">CPU Temperature</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="text-align:center;width:100%"><canvas id="smoothie-chart" height="300"></canvas></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="text-align:right;width:30%;padding:4px">Current Temperature [°C]:</th><td id="cur_temp" style="text-align:left;width: 70%"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="text-align:right;padding:4px">Average Temperature [°C](5m):</th><td id=avg_temp style="text-align:left"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,42 @@
|
||||||
|
window.onload = function () {
|
||||||
|
resize_canvas()
|
||||||
|
|
||||||
|
var chart = new SmoothieChart({, millisPerPixel: 200, maxValueScale: 1.1, minValueScale: 1.1, scaleSmoothing: 0.1, grid: { fillStyle: '#ffffff', millisPerLine: 5000, verticalSections: 8 }, labels: { fillStyle: '#0000ff', fontSize: 18, precision: 1 }, timestampFormatter: SmoothieChart.timeFormatter }),
|
||||||
|
canvas = document.getElementById('smoothie-chart'),
|
||||||
|
series = new TimeSeries();
|
||||||
|
average_array = []
|
||||||
|
|
||||||
|
chart.addTimeSeries(series, { lineWidth: 3.5, strokeStyle: '#ff0000' });
|
||||||
|
chart.streamTo(canvas, 500);
|
||||||
|
|
||||||
|
function run_proc(series,average_array) {
|
||||||
|
var proc = cockpit.spawn(["vcgencmd","measure_temp"]);
|
||||||
|
proc.done(function(data){
|
||||||
|
pt = parseFloat(data.match(/([0-9\.]+)/)[1]);
|
||||||
|
series.append(new Date().getTime(), pt);
|
||||||
|
document.getElementById("cur_temp").innerHTML = pt;
|
||||||
|
average_array.push(pt);
|
||||||
|
if(average_array.length > 5*60){
|
||||||
|
average_array.shift();
|
||||||
|
}
|
||||||
|
document.getElementById("avg_temp").innerHTML = average(average_array);
|
||||||
|
console.log(average_array);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//run_proc(series)
|
||||||
|
setInterval(function () { run_proc(series,average_array) }, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resize_canvas() {
|
||||||
|
document.getElementById("smoothie-chart").width = window.innerWidth - 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
function average(array) {
|
||||||
|
var sum = 0;
|
||||||
|
var count = array.length;
|
||||||
|
for (var i = 0; i < count; i++) {
|
||||||
|
sum = sum + array[i];
|
||||||
|
}
|
||||||
|
return sum / count;
|
||||||
|
}
|
Loading…
Reference in New Issue