diff --git a/sensortoy/sensortoy/app/css/app.css b/sensortoy/sensortoy/app/css/app.css index d5a2b20..a4231cd 100644 --- a/sensortoy/sensortoy/app/css/app.css +++ b/sensortoy/sensortoy/app/css/app.css @@ -208,6 +208,6 @@ color:#78909C; svg text { font-family:'Ubuntu Condensed',sans-serif; font-size:12; - fill: #004c6d; + fill: #bad649; text-align:right; } diff --git a/sensortoy/sensortoy/app/js/device/CC2650/cc2650_accelerometer.js b/sensortoy/sensortoy/app/js/device/CC2650/cc2650_accelerometer.js index befea5f..38b5d44 100644 --- a/sensortoy/sensortoy/app/js/device/CC2650/cc2650_accelerometer.js +++ b/sensortoy/sensortoy/app/js/device/CC2650/cc2650_accelerometer.js @@ -109,7 +109,7 @@ CC2650_ACCEL = function(p) { this.data.mag.y = this.storeData(calcData.mag.y, this.data.mag.y); this.data.mag.z = this.storeData(calcData.mag.z, this.data.mag.z); - console.log(JSON.stringify(this.data)); + // console.log(JSON.stringify(this.data)); // Console.log(this.state); }; diff --git a/sensortoy/sensortoy/app/js/device/CC2650/cc2650_thermopile.js b/sensortoy/sensortoy/app/js/device/CC2650/cc2650_thermopile.js index 257f5e6..335ed4e 100644 --- a/sensortoy/sensortoy/app/js/device/CC2650/cc2650_thermopile.js +++ b/sensortoy/sensortoy/app/js/device/CC2650/cc2650_thermopile.js @@ -87,10 +87,49 @@ var CC2650_TMP = function(p) { }; this.animateGraph = function() { - this.simpleGraph(this.data.temp, 'temp'); - this.simpleGraph(this.data.ambient, 'ambient'); + // This.simpleGraph(this.data.temp, 'temp'); + // debugger; + var arcTemp = this.frameID + 'temp-arc'; + var arcAmbient = this.frameID + 'ambient-arc'; + this.updateArc(this.data.temp, 'temp' , arcTemp); + + this.updateArc(this.data.ambient, 'ambient' , arcAmbient); + + //This.simpleGraph(this.data.ambient, 'ambient'); }; + this.updateArc = function(data, subID, elmID) { + + + var ceilingLimit; + var _subID; + var _data; + var label; + + _data = data || this.data; + + _subID = subID || ''; + + if (_data.length > 0) { + + ceilingLimit = 50; + + var latest = _data[_data.length - 1]; + var scale = 100 / ceilingLimit; + var arcP = scale * latest; + // Var xstep = (280 - 46) / 100; + + label = this.frameID + subID + '-label'; + document.getElementById(elmID).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(arcP))); + // document.getElementById(label).innerText(latest.toFixed(2) + 'ºc'); + } + + + + }; + + + this.insertFrame = function() { var liSetting; @@ -105,13 +144,27 @@ var CC2650_TMP = function(p) { var temp = this.frameID + '-t'; var amb = this.frameID + '-a'; + + var arcB = this.frameID + 'temp-arcB'; + var arcTemp = this.frameID + 'temp-arc'; + + var ambientArcB = this.frameID + 'ambient-arcB'; + var arcAmbient = this.frameID + 'ambient-arc'; + var settings = {data: {baseID: this.frameID}}; - var html = new EJS({url: './partials/cc2650_thermopile.ejs'}).render(settings); + var html = new EJS({url: './partials/cc2650_thermopile_dial.ejs'}).render(settings); - this.$id.append(html); + this.$id.append(html); + +debugger; + document.getElementById(arcB).setAttribute('d', this.describeArc(150, 150, 100, 0, 240)); + document.getElementById(arcTemp).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(0))); + + document.getElementById(ambientArcB).setAttribute('d', this.describeArc(150, 150, 100, 0, 240)); + document.getElementById(arcAmbient).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(0))); - /*var row = $('
', {class: 'mui-row'}); + /*Var row = $('
', {class: 'mui-row'}); $('
', {class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row); diff --git a/sensortoy/sensortoy/app/js/standards/capability.js b/sensortoy/sensortoy/app/js/standards/capability.js index 64a9919..5020b2c 100644 --- a/sensortoy/sensortoy/app/js/standards/capability.js +++ b/sensortoy/sensortoy/app/js/standards/capability.js @@ -271,6 +271,41 @@ CAPABILITY.prototype.setArc = function(percent) { return (240 / 100) * percent; }; +CAPABILITY.prototype.updateArc = function(data, subID, elmID) { + + + var ceilingLimit; + var ceiling; + var _subID; + var _data; + + _data = data || this.data; + + _subID = subID || ''; + + if (_data.length > 0) { + + ceiling = _data.reduce(function(p, v) { + return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v)); + }); + + ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 10) * 10); + if (ceilingLimit > 1000) { + ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 50) * 50); + } + + var latest = _data[_data.length-1]; + var scale = 100 / ceilingLimit; + var arcP = scale * latest; + // Var xstep = (280 - 46) / 100; + + document.getElementById(elmID).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(arcP))); + } + + + }; + + CAPABILITY.prototype.simpleGraph = function(data, subID) { var ceilingLimit; diff --git a/sensortoy/sensortoy/app/partials/cc2650_thermopile_dial.ejs b/sensortoy/sensortoy/app/partials/cc2650_thermopile_dial.ejs index cdabd76..0111acb 100644 --- a/sensortoy/sensortoy/app/partials/cc2650_thermopile_dial.ejs +++ b/sensortoy/sensortoy/app/partials/cc2650_thermopile_dial.ejs @@ -17,7 +17,7 @@
- + @@ -28,11 +28,11 @@ - - + + - --ºc + --ºc @@ -52,12 +52,12 @@ -->
- -- + text-anchor="end">-- @@ -65,5 +65,28 @@ - + --> + + + + + + + + + + + + + + + + + + + --ºc + + + +
diff --git a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock index 637083f..2e83069 100644 Binary files a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock and b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock differ diff --git a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin index a18124d..84a4002 100644 Binary files a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin and b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileHashes.bin differ diff --git a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin index 6fe67e3..fb0510d 100644 Binary files a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin and b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin differ diff --git a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin index 4f95e30..caf6976 100644 Binary files a/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin and b/sensortoy/sensortoy/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin differ diff --git a/sensortoy/sensortoy/platforms/android/assets/www/css/app.css b/sensortoy/sensortoy/platforms/android/assets/www/css/app.css index d5a2b20..a4231cd 100644 --- a/sensortoy/sensortoy/platforms/android/assets/www/css/app.css +++ b/sensortoy/sensortoy/platforms/android/assets/www/css/app.css @@ -208,6 +208,6 @@ color:#78909C; svg text { font-family:'Ubuntu Condensed',sans-serif; font-size:12; - fill: #004c6d; + fill: #bad649; text-align:right; } diff --git a/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_accelerometer.js b/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_accelerometer.js index fcf1382..38b5d44 100644 --- a/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_accelerometer.js +++ b/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_accelerometer.js @@ -109,7 +109,7 @@ CC2650_ACCEL = function(p) { this.data.mag.y = this.storeData(calcData.mag.y, this.data.mag.y); this.data.mag.z = this.storeData(calcData.mag.z, this.data.mag.z); - console.log(JSON.stringify(this.data)); + // console.log(JSON.stringify(this.data)); // Console.log(this.state); }; @@ -298,9 +298,9 @@ CC2650_ACCEL = function(p) { var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150}); - svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)'); - svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)'); - svg = this.graphAddLine(svg, zlineID, 'rgba(0,0,255,0.5)'); + svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,99,1)'); + svg = this.graphAddLine(svg, ylineID, 'rgba(46,255,0,1)'); + svg = this.graphAddLine(svg, zlineID, 'rgba(0,191,255,1)'); return svg; diff --git a/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_barometer.js b/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_barometer.js index 2afb6b5..fd37cb6 100644 --- a/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_barometer.js +++ b/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_barometer.js @@ -99,13 +99,7 @@ var CC2650_BAR = function(p) { var temp = this.frameID + '-t'; var pressure = this.frameID + '-p'; - - var settings = {data: {baseID: this.frameID}}; - var html = new EJS({url: './partials/cc2650_barometer.ejs'}).render(settings); - - this.$id.append(html); - - /* var row = $('
', {class: 'mui-row'}); + var row = $('
', {class: 'mui-row'}); $('
', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row); @@ -156,7 +150,7 @@ var CC2650_BAR = function(p) { class: 'mui-tabs__pane', id: (pressure + '-pane') }).append(blankChart)); - }*/ + } this.$result.temp = $('#' + temp); this.$result.pressure = $('#' + pressure); diff --git a/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_thermopile.js b/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_thermopile.js index 257f5e6..335ed4e 100644 --- a/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_thermopile.js +++ b/sensortoy/sensortoy/platforms/android/assets/www/js/device/CC2650/cc2650_thermopile.js @@ -87,10 +87,49 @@ var CC2650_TMP = function(p) { }; this.animateGraph = function() { - this.simpleGraph(this.data.temp, 'temp'); - this.simpleGraph(this.data.ambient, 'ambient'); + // This.simpleGraph(this.data.temp, 'temp'); + // debugger; + var arcTemp = this.frameID + 'temp-arc'; + var arcAmbient = this.frameID + 'ambient-arc'; + this.updateArc(this.data.temp, 'temp' , arcTemp); + + this.updateArc(this.data.ambient, 'ambient' , arcAmbient); + + //This.simpleGraph(this.data.ambient, 'ambient'); }; + this.updateArc = function(data, subID, elmID) { + + + var ceilingLimit; + var _subID; + var _data; + var label; + + _data = data || this.data; + + _subID = subID || ''; + + if (_data.length > 0) { + + ceilingLimit = 50; + + var latest = _data[_data.length - 1]; + var scale = 100 / ceilingLimit; + var arcP = scale * latest; + // Var xstep = (280 - 46) / 100; + + label = this.frameID + subID + '-label'; + document.getElementById(elmID).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(arcP))); + // document.getElementById(label).innerText(latest.toFixed(2) + 'ºc'); + } + + + + }; + + + this.insertFrame = function() { var liSetting; @@ -105,13 +144,27 @@ var CC2650_TMP = function(p) { var temp = this.frameID + '-t'; var amb = this.frameID + '-a'; + + var arcB = this.frameID + 'temp-arcB'; + var arcTemp = this.frameID + 'temp-arc'; + + var ambientArcB = this.frameID + 'ambient-arcB'; + var arcAmbient = this.frameID + 'ambient-arc'; + var settings = {data: {baseID: this.frameID}}; - var html = new EJS({url: './partials/cc2650_thermopile.ejs'}).render(settings); + var html = new EJS({url: './partials/cc2650_thermopile_dial.ejs'}).render(settings); - this.$id.append(html); + this.$id.append(html); + +debugger; + document.getElementById(arcB).setAttribute('d', this.describeArc(150, 150, 100, 0, 240)); + document.getElementById(arcTemp).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(0))); + + document.getElementById(ambientArcB).setAttribute('d', this.describeArc(150, 150, 100, 0, 240)); + document.getElementById(arcAmbient).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(0))); - /*var row = $('
', {class: 'mui-row'}); + /*Var row = $('
', {class: 'mui-row'}); $('
', {class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row); diff --git a/sensortoy/sensortoy/platforms/android/assets/www/js/standards/capability.js b/sensortoy/sensortoy/platforms/android/assets/www/js/standards/capability.js index 156d349..5020b2c 100644 --- a/sensortoy/sensortoy/platforms/android/assets/www/js/standards/capability.js +++ b/sensortoy/sensortoy/platforms/android/assets/www/js/standards/capability.js @@ -242,6 +242,70 @@ CAPABILITY.prototype.animateGraph = function() { }; +CAPABILITY.prototype.polarToCartesian = function(centerX, centerY, radius, angleInDegrees) { + var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0; + + return { + x: centerX + (radius * Math.cos(angleInRadians)), + y: centerY + (radius * Math.sin(angleInRadians)) + }; +}; + + +CAPABILITY.prototype.describeArc = function(x, y, radius, startAngle, endAngle) { + + var start = this.polarToCartesian(x, y, radius, endAngle); + var end = this.polarToCartesian(x, y, radius, startAngle); + + var arcSweep = endAngle - startAngle <= 180 ? '0' : '1'; + + var d = [ + 'M', start.x, start.y, + 'A', radius, radius, 0, arcSweep, 0, end.x, end.y + ].join(' '); + + return d; + }; + +CAPABILITY.prototype.setArc = function(percent) { + return (240 / 100) * percent; +}; + +CAPABILITY.prototype.updateArc = function(data, subID, elmID) { + + + var ceilingLimit; + var ceiling; + var _subID; + var _data; + + _data = data || this.data; + + _subID = subID || ''; + + if (_data.length > 0) { + + ceiling = _data.reduce(function(p, v) { + return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v)); + }); + + ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 10) * 10); + if (ceilingLimit > 1000) { + ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 50) * 50); + } + + var latest = _data[_data.length-1]; + var scale = 100 / ceilingLimit; + var arcP = scale * latest; + // Var xstep = (280 - 46) / 100; + + document.getElementById(elmID).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(arcP))); + } + + + }; + + CAPABILITY.prototype.simpleGraph = function(data, subID) { var ceilingLimit; @@ -272,8 +336,8 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) { var calcArray = []; -/* - var ceilingLimit = Math.floor(ceiling / 10) * 10; + /* + Var ceilingLimit = Math.floor(ceiling / 10) * 10; if (ceilingLimit < ceiling) { ceilingLimit = Math.floor((ceiling + (ceiling * 0.25)) / 10) * 10; } diff --git a/sensortoy/sensortoy/platforms/android/assets/www/partials/cc2650_thermopile_dial.ejs b/sensortoy/sensortoy/platforms/android/assets/www/partials/cc2650_thermopile_dial.ejs new file mode 100644 index 0000000..0111acb --- /dev/null +++ b/sensortoy/sensortoy/platforms/android/assets/www/partials/cc2650_thermopile_dial.ejs @@ -0,0 +1,92 @@ +
+
Temp:
+
-- +
+
Ambient:
+
-- +
+
+ +
+ + + + + + + + + + + + + + + + + --ºc + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + --ºc + + + + +