Skip to content

Commit

Permalink
Fixed graphing (removed rate calc), removed AlwaysRefresh
Browse files Browse the repository at this point in the history
  • Loading branch information
DDrew73 committed Oct 17, 2016
1 parent f65215b commit ff0dced
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
16 changes: 9 additions & 7 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,20 @@
var holder = new ComponentHolder();

var refreshCounter = 0;
var alwaysRedraw = false;

//var alwaysRedraw = false;
var okayToRefresh = function() {
if (alwaysRedraw) {
return true;
} else {
//if (alwaysRedraw) {
// return true;
//} else {
if (refreshCounter % 20 == 0) {
refreshCounter = 1;
return true;
} else {
refreshCounter += 1;
return false;
}
}
//}
}

// if we get an "info" emit from the socket server then console.log the data we receive
Expand Down Expand Up @@ -385,12 +386,13 @@
addCompConfig();

$("#scanOnce").on("click",function() {
alwaysRedraw = true;
//alwaysRedraw = true;
refreshCounter = 0;
socket.emit("d","hello");
});

$("#scanCon").on("click",function() {
alwaysRedraw = false;
//alwaysRedraw = false;
refreshCounter = 0;
socket.emit("s","hello");
scanningConfig();
Expand Down
22 changes: 14 additions & 8 deletions public/toastboard.js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ Graph.prototype.clear = function() {
Graph.prototype.addData = function(reading) {
var lastReading = this.readings.slice(-1)[0]
var hz;
if (lastReading != undefined && lastReading.time != undefined && lastReading.time.length > 0) {
var lastTimestamp = lastReading.time[0];
var msBetween = reading.time[0] - lastTimestamp;
hz = 1 / (1 - (msBetween / 1000));
hz = hz.toFixed(2);
}
this.sampleRate = hz + " Hz";

//debug commenting
// if (lastReading != undefined && lastReading.time != undefined && lastReading.time.length > 0) {
// var lastTimestamp = lastReading.time[0];
// var msBetween = reading.time[0] - lastTimestamp;
// hz = 1 / (1 - (msBetween / 1000));
// hz = hz.toFixed(2);
// }
// this.sampleRate = hz + " Hz";

this.sampleRate = " ";


this.readings.push(reading);
this.voltageData.push({voltage:reading.data[0],second:reading.time[0]});

Expand Down Expand Up @@ -90,7 +96,7 @@ Graph.prototype.drawGraph = function(component_type) {
xAxis = d3.svg.axis()
.scale(xRange)
.tickSize(5)
.tickFormat(function(d) { return d + "s";}),
.tickFormat(function(d) { return d + "ms";}),
yAxis = d3.svg.axis()
.scale(yRange)
.ticks(5)
Expand Down

0 comments on commit ff0dced

Please sign in to comment.