”2016-07-04”

This commit is contained in:
Martin Donnelly 2016-07-04 16:45:05 +01:00
parent 7fb8d179e6
commit 450cc64b0a
16 changed files with 476 additions and 2086 deletions

View File

@ -23,8 +23,6 @@ var BLUVIB = function(p) {
enable: '9FB70002-EF7D-40C8-9C1E-5052BC101EFA',
notify: '9FB70003-EF7D-40C8-9C1E-5052BC101EFA',
period: '9FB70004-EF7D-40C8-9C1E-5052BC101EFA'
};
this.$result = {temp: null, tempMax: null, tempMin: null};
@ -42,7 +40,8 @@ var BLUVIB = function(p) {
this.onNotification = function(d) {
this.readRaw('BluVib', d);
console.log(d);
//this.readRaw('BluVib', d);
};
@ -78,13 +77,17 @@ var BLUVIB = function(p) {
var configData = new Uint8Array(1);
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
configData[0] = 0x76;
configData[0] = 0x74;
/*
configData[1] = 0x01;
configData[2] = 0x01;
configData[3] = 0x01;
*/
ble.write(this.deviceID,
this.serviceDef.service,
this.serviceDef.enable,
configData.buffer,
function(m) { console.log('Started BluVib.',m); },
function(m) { console.log('Started BluVib.', m); },
this.onError);
}

View File

@ -1,8 +1,3 @@
body {
font-family: Ubuntu, "Helvetica Neue", Helvetica, arial, sans-serif;
}
#lightR, #projR { color: red !important; }
@ -17,7 +12,6 @@ body {
}
.h105 {
height: 100px;
}
@ -82,57 +76,6 @@ body {
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* Styles */
.time, .date, .temp {
font-family: 'Ubuntu Condensed', sans-serif;
font-size: 33px;
/*color: #ff0000;*/
}
.time {
font-size: 50px;
line-height: 1;
}
.time span.hour:after {
content: "\a";
white-space: pre;
}
.temp {
font-size: 70px;
}
.temp::after {
content: "°";
}
.wd-we {
font-size: 75%;
}
.mo {
font-size: 85%;
}
.mo.mo-1, .mo.mo-10 {
font-size: 70%;
}
.mo.mo-2 {
font-size: 65%;
}
.mo.mo-8 {
font-size: 80%;
}
.mo.mo-9 {
font-size: 55%;
}
.mo.mo-11, .mo.mo-12 {
font-size: 60%;
}
}
@ -258,3 +201,13 @@ color:#78909C;
{
color:#2196F3;
}
/* svg classes */
svg text {
font-family:'Ubuntu Condensed',sans-serif;
font-size:12;
fill: #bad649;
text-align:right;
}

View File

@ -1,9 +1,14 @@
@import "app/libs/mui/src/sass/mui/colors";
$mui-body-bg-color: mui-color('grey', '100');
$mui-body-bg-color: /*#003F5a*/ mui-color('grey', '800');
$mui-base-font-color: rgba(#FFF, 0.87) !default;
$mui-base-font-family: Ubuntu, "Helvetica Neue", Helvetica, Arial, Verdana, Tahoma !default;
$mui-panel-bg-color : /*#004c6d*/ mui-color('grey', '900');
//$mui-accent-color: #bad649;
$mui-accent-color: #004c6d;
$mui-accent-color: #00aeef;
$mui-btn-accent-font-color: #004c6d;
//$mui-accent-color-dark: mui-color('green', 'A100');
$mui-accent-color-dark: #004c6d;

File diff suppressed because one or more lines are too long

View File

@ -92,14 +92,21 @@
<!-- build:vendor -->
<script type="text/javascript" src="libs/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="libs/mui/packages/cdn/js/mui.js"></script>
<script type="text/javascript" src="libs/ejs/ejs.js"></script>
<script type="text/javascript"
src="libs/bluebird/js/browser/bluebird.js"></script>
<script type="text/javascript" src="libs/jsfft/complex_array.js"></script>
<script type="text/javascript" src="libs/jsfft/fft.js"></script>
<!-- endbuild -->
<!-- build:standards -->
<script type="text/javascript"
src="js/standards/bluetooth_company_identifiers.js"></script>
<script type="text/javascript" src="js/standards/capability.js"></script>
<script type="text/javascript" src="js/standards/generic_access.js"></script>
<script type="text/javascript" src="js/standards/deviceInformation.js"></script>
<script type="text/javascript" src="js/standards/battery.js"></script>
<script type="text/javascript" src="js/standards/button.js"></script>
<script type="text/javascript" src="js/mandecoder.js"></script>
@ -118,6 +125,12 @@
src="js/device/CC2650/cc2650_humidity.js"></script>
<!-- endbuild -->
<script type="text/javascript"
src="js/device/fmc/TSL.js"></script>
<script type="text/javascript"
src="js/device/sensorworks/bluvib.js"></script>
<!-- build:js -->
<script type="text/javascript" src="js/index.js"></script>
<!-- endbuild -->

View File

@ -81,10 +81,6 @@ CC2650_ACCEL = function(p) {
}
calcData = this.processData(data);
message = 'Gyro <br/>' + 'X: ' + calcData.gyro.x + '<br/>' + 'Y: ' + calcData.gyro.y + '<br/>' + 'Z: ' + calcData.gyro.z + '<br/>' + 'Accel <br/>' + 'X: ' + calcData.accel.x + '<br/>' + 'Y: ' + calcData.accel.y + '<br/>' + 'Z: ' + calcData.accel.z + '<br/>' + 'Mag <br/>' + 'X: ' + calcData.mag.x + '<br/>' + 'Y: ' + calcData.mag.y + '<br/>' + 'Z: ' + calcData.mag.z + '<br/>';
this.state = message;
this.$result[this.frames.gyroID + '-x'].text(gString(calcData.gyro.x));
this.$result[this.frames.gyroID + '-y'].text(gString(calcData.gyro.y));
this.$result[this.frames.gyroID + '-z'].text(gString(calcData.gyro.z));
@ -109,12 +105,11 @@ 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(this.state);
};
this.startService = function() {
this.maxLength = 500;
if (this.deviceID !== null) {
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
@ -154,8 +149,12 @@ CC2650_ACCEL = function(p) {
};
this.advancedGraph = function(mode, data, subID) {
this.advancedGraphFFT = function(mode, data, subID) {
var startX;
var _cdata;
var xstep;
var scalePos;
var lm;
var ceiling;
var elm;
@ -168,9 +167,27 @@ CC2650_ACCEL = function(p) {
var text1ID;
var lineID;
var max;
var yscale = 125;
var height = 125;
var yOffset;
var reducer = function(p, v) {
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
};
var parts = ['x', 'y', 'z'];
var _newData = {x: [],y: [],z: []};
var fnFillNewData = function(c_value, i) {
ceiling = reducer(c_value.real ,ceiling);
_newData[lm].push(c_value.real);
};
if (subID === 'gyro') {
height = 300;
yscale = 300;
}
_data = data || this.data;
@ -179,6 +196,111 @@ CC2650_ACCEL = function(p) {
// LineID = [this.frameID , _subID , '-line'].join('');
text1ID = [this.frameID, _subID, '-txt1'].join('');
text2ID = [this.frameID, _subID, '-txt2'].join('');
ceiling = 0;
if (_data.x.length > 0) {
max = 2;
for (var lineMode = 0; lineMode < parts.length; lineMode++) {
lm = parts[lineMode];
_cdata = new complex_array.ComplexArray(_data[lm]);
_cdata.FFT();
_cdata.forEach(fnFillNewData);
}
if (ceiling > 500) {
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 50) * 50) : max;
} else {
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 10) * 10) : max;
}
ceiling = max;
floor = ceiling * -1;
ceilingLimit = ceiling;
scalePos = (yscale / 2) / ceiling;
xstep = (680 - 46) / this.maxLength;
yOffset = ((height - (14 + 12)) / 2) + 12;
for (lineMode = 0; lineMode < parts.length; lineMode++) {
lm = parts[lineMode];
startX = 46 + (this.maxLength - _newData[lm].length) * xstep;
calcArray = [];
lineID = this.frameID + _subID + '-' + lm + '-line';
for (var x = 0; x < _newData[lm].length; x++) {
calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (yOffset - ((_newData[lm][x]) * scalePos)).toFixed(
2));
}
elm = document.getElementById(lineID);
elm.setAttribute('points', calcArray.join(' '));
}
elm = document.getElementById(text1ID);
elm.textContent = ceilingLimit;
elm = document.getElementById(text2ID);
elm.textContent = floor;
}
this.previousCeil = ceiling;
};
this.advancedGraph = function(mode, data, subID) {
var startX;
var xstep;
var scalePos;
var lm;
var ceiling;
var elm;
var text2ID;
var ceilingLimit;
var calcArray;
var floor;
var _subID;
var _data;
var text1ID;
var lineID;
var max;
var yscale = 125;
var height = 125;
var yOffset;
var reducer = function(p, v) {
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
};
var parts = ['x', 'y', 'z'];
_data = data || this.data;
_subID = subID || '';
text1ID = [this.frameID, _subID, '-txt1'].join('');
text2ID = [this.frameID, _subID, '-txt2'].join('');
if (mode === 'gyro') {
height = 300;
yscale = 300;
}
if (_data.x.length > 0) {
@ -186,10 +308,8 @@ CC2650_ACCEL = function(p) {
for (var lineMode = 0; lineMode < parts.length; lineMode++) {
lm = parts[lineMode];
ceiling = _data[lm].reduce(function(p, v) {
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
});
ceiling = _data[lm].reduce(reducer);
if (ceiling > 500) {
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 50) * 50) : max;
@ -203,23 +323,24 @@ CC2650_ACCEL = function(p) {
floor = ceiling * -1;
ceilingLimit = ceiling;
var scalePos = (124 / 2) / ceiling;
var scaleNeg = (124 / 2) / floor;
var xstep = (680 - 46) / 100;
scalePos = (yscale / 2) / ceiling;
//Var xstep = 2.34;
xstep = (680 - 46) / this.maxLength;
// YOffset should be about 71;
yOffset = ((height - (14 + 12)) / 2) + 12;
for (lineMode = 0; lineMode < parts.length; lineMode++) {
lm = parts[lineMode];
var startX = 46 + (100 - _data[lm].length) * xstep;
startX = 46 + (this.maxLength - _data[lm].length) * xstep;
calcArray = [];
lineID = this.frameID + _subID + '-' + lm + '-line';
for (var x = 0; x < _data[lm].length; x++) {
calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (71 - ((_data[lm][x]) * scalePos)).toFixed(
calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (yOffset - ((_data[lm][x]) * scalePos)).toFixed(
2));
}
@ -245,7 +366,7 @@ CC2650_ACCEL = function(p) {
// Nothing to animate yet
// return -1;
this.advancedGraph(0, this.data.gyro, 'gyro');
this.advancedGraphFFT(0, this.data.gyro, 'gyro');
this.advancedGraph(0, this.data.accel, 'accel');
this.advancedGraph(0, this.data.mag, 'mag');
// This.simpleGraph(this.data.temp, 'temp');
@ -265,7 +386,9 @@ CC2650_ACCEL = function(p) {
var _width = settings.width || 300;
var _height = settings.height || 150;
var _fill = settings.fill || 'blue';
var viewbox = [0,0,_width, _height].join(' ');
var svg = document.createElementNS(xmlns, 'svg');
svg.setAttribute('id', svgID);
@ -277,30 +400,31 @@ CC2650_ACCEL = function(p) {
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
svg.setAttributeNS(xmlns, 'viewBox', '0 0 700 150');
svg.setAttributeNS(xmlns, 'viewBox', viewbox);
// Svg.setAttributeNS(xmlns, 'style', 'width:700px;height:150px;');
svg = this.graphAddXAxis(svg, {y: 12, x2: 680, colour: '#004c6d', id: text1ID});
svg = this.graphAddXAxis(svg, {y: 136, x2: 680, colour: '#004c6d', id: text2ID});
svg = this.graphAddXAxis(svg, {y: 71, x2: 680, colour: '#004c6d', text: '0'});
svg = this.graphAddXAxis(svg, {y: _height - 14, x2: 680, colour: '#004c6d', id: text2ID});
svg = this.graphAddXAxis(svg, {y: ((_height - (14 + 12)) / 2) + 12, x2: 680, colour: '#004c6d', text: '0'});
return svg;
};
this.generateBlankGraph = function(subID) {
this.generateBlankGraph = function(subID, height) {
var _height = height || 150;
var _subID = subID || '';
var xlineID = this.frameID + _subID + '-x-line';
var ylineID = this.frameID + _subID + '-y-line';
var zlineID = this.frameID + _subID + '-z-line';
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150});
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: _height});
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;
@ -308,61 +432,81 @@ CC2650_ACCEL = function(p) {
this.insertFrame = function(mode) {
var _graph;
var row;
var elm;
var frame;
var title;
var modeID = mode + 'ID';
var height = 150;
this.frames[modeID] = this.frameID + '-' + mode;
var titles = {
gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'
};
var modes = ['gyro', 'accel', 'mag'];
console.log('FrameID: ', this.frames[modeID]);
title = [titles[mode], ' - ', this.deviceID].join(' ');
frame = $('<div />', {
frame = $('<div></div>', {
class: 'mui-panel', id: this.frames[modeID]
});
$('<div />', {class: 'mui-row'}).append($('<div />', {
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
})).appendTo(frame);
if (mode === 'gyro') {
height = 300;
}
if (mode === 'mag') {
elm = $('<div></div>', {class: 'mui-row'});
elm.append($('<div></div>', { class: 'mui-col-xs-8 mui--text-title mui-ellipsis-2', text: title}));
// Elm.append($('<div></div>', {class: 'mui-col-xs-4 mui--text-right'}).append(button));
frame.append(elm);
} else {
$('<div></div>', {class: 'mui-row'}).append($('<div></div>', {
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
})).appendTo(frame);
}
this.$frame.append(frame);
this.$id[modeID] = $('#' + this.frames[modeID]);
// Call the parent displayForm first...
var row = $('<div />', {class: 'mui-row'});
row = $('<div></div>', {class: 'mui-row'});
$('<div />', {
$('<div></div>', {
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'X'
}).appendTo(row);
$('<div />', {
$('<div></div>', {
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Y'
}).appendTo(row);
$('<div />', {
$('<div></div>', {
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Z'
}).appendTo(row);
this.$id[modeID].append(row);
row = $('<div />', {class: 'mui-row'});
row = $('<div></div>', {class: 'mui-row'});
$('<div />', {
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
$('<div></div>', {
class: 'mui-col-xs-4 mui--text-light mui--text-center',
text: '--',
id: this.frames[modeID] + '-x'
}).appendTo(row);
$('<div />', {
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
$('<div></div>', {
class: 'mui-col-xs-4 mui--text-light mui--text-center',
text: '--',
id: this.frames[modeID] + '-y'
}).appendTo(row);
$('<div />', {
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
$('<div></div>', {
class: 'mui-col-xs-4 mui--text-light mui--text-center',
text: '--',
id: this.frames[modeID] + '-z'
}).appendTo(row);
@ -373,9 +517,9 @@ CC2650_ACCEL = function(p) {
this.$result[this.frames[modeID] + '-y'] = $('#' + this.frames[modeID] + '-y');
this.$result[this.frames[modeID] + '-z'] = $('#' + this.frames[modeID] + '-z');
row = $('<div />', {class: 'mui-row'});
row = $('<div></div>', {class: 'mui-row'});
var _graph = this.generateBlankGraph(mode);
_graph = this.generateBlankGraph(mode, height);
row.append($('<div>', {class: 'mui-col-sm-12'}).append(_graph));
this.$id[modeID].append(row);

View File

@ -5,7 +5,7 @@
* Time: 10:13
*
*/
/* global CAPABILITY, inheritsFrom, capabilityManager, device */
/* global CAPABILITY, inheritsFrom, capabilityManager, EJS */
/* global ble */
/* jshint browser: true , devel: true*/
@ -84,73 +84,99 @@ var CC2650_BAR = function(p) {
};
this.animateGraph = function() {
this.simpleGraph(this.data.temp, 'temp');
this.simpleGraph(this.data.pressure, 'pressure');
/* This.simpleGraph(this.data.temp, 'temp');
this.simpleGraph(this.data.pressure, 'pressure');*/
var arcTemp = this.frameID + 'temp-arc';
var arcPressure = this.frameID + 'pressure-arc';
this.updateArc(this.data.temp, 'temp' , arcTemp, '°C', 50);
this.updateArc(this.data.pressure, 'pressure' , arcPressure, 'hPa');
};
this.insertFrame = function() {
var self = this;
var blankChart;
// Call the parent displayForm first...
this.superClass_.insertFrame.call(self);
var temp = this.frameID + '-t';
var pressure = this.frameID + '-p';
var row = $('<div />', {class: 'mui-row'});
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
var arcB = this.frameID + 'temp-arcB';
var arcTemp = this.frameID + 'temp-arc';
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Pressure:'}).appendTo(row);
var pressureArcB = this.frameID + 'pressure-arcB';
var arcPressure = this.frameID + 'pressure-arc';
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: pressure}).appendTo(row);
var settings = {data: {baseID: this.frameID}};
var html = new EJS({url: './partials/cc2650_barometer_dial.ejs'}).render(settings);
this.$id.append(row);
this.$id.append(html);
if (/ipad/i.test(device.model)) {
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)));
tabBody = $('<div>', {class: 'mui-row'});
document.getElementById(pressureArcB).setAttribute('d', this.describeArc(150, 150, 100, 0, 240));
document.getElementById(arcPressure).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(0)));
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('pressure'))) ;
this.$id.append(tabBody);
} else {
/* Var row = $('<div />', {class: 'mui-row'});
var tabBody = $('<ul>',
{class: 'mui-tabs__bar mui-tabs__bar--justified'});
$('<li>', {class: 'mui--is-active tabOnWhite'}).append($('<a>',
{
text: 'Temperature',
'data-mui-toggle': 'tab',
'data-mui-controls': (temp + '-pane')
})).appendTo(tabBody);
$('<li>', {class: 'tabOnWhite'}).append($('<a>',
{
text: 'Pressure',
'data-mui-toggle': 'tab',
'data-mui-controls': (pressure + '-pane')
})).appendTo(tabBody);
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
this.$id.append(tabBody);
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Pressure:'}).appendTo(row);
blankChart = this.generateBlankGraph('temp');
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: pressure}).appendTo(row);
this.$id.append($('<div>',
{class: 'mui-tabs__pane mui--is-active', id: (temp + '-pane')}).append(
blankChart));
this.$id.append(row);
blankChart = this.generateBlankGraph('pressure');
if (/ipad/i.test(device.model)) {
this.$id.append($('<div>',
{
class: 'mui-tabs__pane',
id: (pressure + '-pane')
}).append(blankChart));
}
tabBody = $('<div>', {class: 'mui-row'});
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('pressure'))) ;
this.$id.append(tabBody);
} else {
var tabBody = $('<ul>',
{class: 'mui-tabs__bar mui-tabs__bar--justified'});
$('<li>', {class: 'mui--is-active tabOnWhite'}).append($('<a>',
{
text: 'Temperature',
'data-mui-toggle': 'tab',
'data-mui-controls': (temp + '-pane')
})).appendTo(tabBody);
$('<li>', {class: 'tabOnWhite'}).append($('<a>',
{
text: 'Pressure',
'data-mui-toggle': 'tab',
'data-mui-controls': (pressure + '-pane')
})).appendTo(tabBody);
this.$id.append(tabBody);
blankChart = this.generateBlankGraph('temp');
this.$id.append($('<div>',
{class: 'mui-tabs__pane mui--is-active', id: (temp + '-pane')}).append(
blankChart));
blankChart = this.generateBlankGraph('pressure');
this.$id.append($('<div>',
{
class: 'mui-tabs__pane',
id: (pressure + '-pane')
}).append(blankChart));
}*/
this.$result.temp = $('#' + temp);
this.$result.pressure = $('#' + pressure);

View File

@ -5,7 +5,7 @@
* Time: 10:13
*
*/
/* global CAPABILITY, inheritsFrom, capabilityManager, device */
/* global CAPABILITY, inheritsFrom, capabilityManager, EJS */
/* global ble */
/* jshint browser: true , devel: true*/
@ -87,28 +87,55 @@ var CC2650_HUM = function(p) {
};
this.animateGraph = function() {
this.simpleGraph(this.data.temp, 'temp');
/*
This.simpleGraph(this.data.temp, 'temp');
this.simpleGraph(this.data.humidity, 'humidity');
};
*/
var arcTemp = this.frameID + 'temp-arc';
var arcHumidity = this.frameID + 'humidity-arc';
this.updateArc(this.data.temp, 'temp' , arcTemp, '°C', 50);
this.updateArc(this.data.humidity, 'humidity' , arcHumidity, '%RH', 100);
};
this.insertFrame = function() {
var self = this;
var blankChart;
// Call the parent displayForm first...
this.superClass_.insertFrame.call(self);
var temp = this.frameID + '-t';
var humidity = this.frameID + '-h';
var row = $('<div />', {class: 'mui-row'});
var arcB = this.frameID + 'temp-arcB';
var arcTemp = this.frameID + 'temp-arc';
var humidityArcB = this.frameID + 'humidity-arcB';
var arcHumidity = this.frameID + 'humidity-arc';
var settings = {data: {baseID: this.frameID}};
var html = new EJS({url: './partials/cc2650_humidity_dial.ejs'}).render(settings);
this.$id.append(html);
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(humidityArcB).setAttribute('d', this.describeArc(150, 150, 100, 0, 240));
document.getElementById(arcHumidity).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(0)));
/*
Var row = $('<div />', {class: 'mui-row'});
$('<div />',
{class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
$('<div />',
{class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
{class: 'mui-col-xs-3 mui--text-light', id: temp}).appendTo(row);
$('<div />',
{
class: 'mui-col-xs-3 mui--text-accent mui--text-right',
@ -116,7 +143,7 @@ var CC2650_HUM = function(p) {
}).appendTo(row);
$('<div />',
{class: 'mui-col-xs-3 mui--text-dark', id: humidity}).appendTo(row);
{class: 'mui-col-xs-3 mui--text-light', id: humidity}).appendTo(row);
this.$id.append(row);
@ -157,7 +184,7 @@ var CC2650_HUM = function(p) {
class: 'mui-tabs__pane',
id: (humidity + '-pane')
}).append(blankChart));
}
}*/
this.$result.temp = $('#' + temp);
this.$result.humidity = $('#' + humidity);

View File

@ -95,7 +95,7 @@ var CC2650_LUX = function(p) {
row);
$('<div />',
{class: 'mui-col-xs-8 mui--text-dark', id: lux}).appendTo(row);
{class: 'mui-col-xs-8 mui--text-light', id: lux}).appendTo(row);
this.$id.append(row);

View File

@ -5,7 +5,7 @@
* Time: 10:13
*
*/
/* global CAPABILITY, inheritsFrom, capabilityManager */
/* global CAPABILITY, inheritsFrom, capabilityManager, EJS */
/* global ble */
/* jshint browser: true , devel: true*/
@ -87,15 +87,17 @@ 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, '°C', 50);
this.updateArc(this.data.ambient, 'ambient' , arcAmbient, '°C', 50);
};
this.insertFrame = function() {
var liSetting;
var tabBody;
var blankChart;
var self = this;
// Console.log('Overloading...');
// Call the parent displayForm first...
@ -104,13 +106,33 @@ var CC2650_TMP = function(p) {
var temp = this.frameID + '-t';
var amb = this.frameID + '-a';
var row = $('<div />', {class: 'mui-row'});
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_dial.ejs'}).render(settings);
this.$id.append(html);
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 = $('<div />', {class: 'mui-row'});
$('<div />',
{class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
$('<div />',
{class: 'mui-col-xs-3 mui--text-dark mui--text-left', id: temp}).appendTo(row);
{class: 'mui-col-xs-3 mui--text-light mui--text-left', id: temp}).appendTo(row);
$('<div />',
{
class: 'mui-col-xs-3 mui--text-accent mui--text-right',
@ -118,7 +140,7 @@ var CC2650_TMP = function(p) {
}).appendTo(row);
$('<div />',
{class: 'mui-col-xs-3 mui--text-dark', id: amb}).appendTo(row);
{class: 'mui-col-xs-3 mui--text-light', id: amb}).appendTo(row);
this.$id.append(row);
@ -152,7 +174,7 @@ var CC2650_TMP = function(p) {
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (amb + '-pane')}).append(blankChart));
}
*/
this.$result.temp = $('#' + temp);

View File

@ -6,7 +6,7 @@
*
*/
/* global MANUFACTUREDECODER */
/* global */
/* jshint browser: true , devel: true*/
/**

View File

@ -45,12 +45,47 @@ var CAPABILITY = function(p) {
this.target = null;
this.$frame = null;
this.maxLength = 99;
this.previousCeil = 0;
capabilityManager.register({id: this.capabilityID, module: this});
};
CAPABILITY.prototype.arrayToAscii = function(a) {
var _a = [].slice.call(a);
_a = _a.map(function(num) {
return String.fromCharCode(num);
});
return _a.join('');
};
CAPABILITY.prototype.arrayToHex = function(a) {
var _a = [].slice.call(a);
_a = _a.map(function(num) {
return ('00' + num.toString(16)).slice(-2);
});
return _a.join(', ');
};
CAPABILITY.prototype.readRaw = function(id, data) {
var a = new Uint8Array(data);
console.log(id, a);
console.log(id, this.arrayToAscii(a));
console.log(id, this.arrayToHex(a));
console.log(data);
};
CAPABILITY.prototype.setFrame = function() {
this.$frame = (this.target !== null) ? $('#' + this.target) : null;
};
@ -114,7 +149,7 @@ CAPABILITY.prototype.storeData = function(data, alt) {
}
var target = alt || this.data;
if (target.length === 99) {
if (target.length === this.maxLength) {
target = target.slice(1);
}
@ -242,6 +277,79 @@ 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, suffix, limiter) {
var ceilingLimit;
var ceiling;
var _subID;
var _data;
var _limiter = limiter || null;
var _suffix = suffix || '';
var label;
_data = data || this.data;
_subID = subID || '';
label = '#' + this.frameID + _subID + '-label';
if (_data.length > 0) {
if (_limiter === null) {
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);
}
} else {
ceilingLimit = _limiter;
}
var latest = _data[_data.length - 1];
var scale = 100 / ceilingLimit;
var arcP = scale * latest;
document.getElementById(elmID).setAttribute('d', this.describeArc(150, 150, 100, 0, this.setArc(arcP)));
$(label).text(latest.toFixed(2) + _suffix);
}
};
CAPABILITY.prototype.simpleGraph = function(data, subID) {
var ceilingLimit;
@ -272,8 +380,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;
}