diff --git a/app/index.html b/app/index.html index 54414c6..c8fae5c 100644 --- a/app/index.html +++ b/app/index.html @@ -105,6 +105,8 @@ + + @@ -126,6 +128,8 @@ + diff --git a/app/js/device/CC2650/cc2650_accelerometer.js b/app/js/device/CC2650/cc2650_accelerometer.js index 9c5c7a4..64dbc71 100644 --- a/app/js/device/CC2650/cc2650_accelerometer.js +++ b/app/js/device/CC2650/cc2650_accelerometer.js @@ -81,10 +81,6 @@ CC2650_ACCEL = function(p) { } calcData = this.processData(data); - message = 'Gyro
' + 'X: ' + calcData.gyro.x + '
' + 'Y: ' + calcData.gyro.y + '
' + 'Z: ' + calcData.gyro.z + '
' + 'Accel
' + 'X: ' + calcData.accel.x + '
' + 'Y: ' + calcData.accel.y + '
' + 'Z: ' + calcData.accel.z + '
' + 'Mag
' + 'X: ' + calcData.mag.x + '
' + 'Y: ' + calcData.mag.y + '
' + 'Z: ' + calcData.mag.z + '
'; - - 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,8 +105,6 @@ 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() { @@ -156,6 +150,9 @@ CC2650_ACCEL = function(p) { }; this.advancedGraphFFT = function(mode, data, subID) { + + var startX; + var _cdata; var xstep; var scalePos; var lm; @@ -173,23 +170,25 @@ CC2650_ACCEL = function(p) { var yscale = 125; var height = 125; - var yOffset = 71; + 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; _subID = subID || ''; @@ -204,23 +203,13 @@ CC2650_ACCEL = function(p) { for (var lineMode = 0; lineMode < parts.length; lineMode++) { - lm = parts[lineMode]; - var data = new complex_array.ComplexArray(_data[lm]); + _cdata = new complex_array.ComplexArray(_data[lm]); + _cdata.FFT(); - data.FFT(); - - data.forEach(function(c_value, i) { - ceiling = reducer(c_value.real ,ceiling); - _newData[lm].push(c_value.real); - }); - - //Ceiling = _data[lm].reduce(reducer); - - console.log('ceiling:', ceiling); - + _cdata.forEach(fnFillNewData); } @@ -233,9 +222,6 @@ CC2650_ACCEL = function(p) { floor = ceiling * -1; ceilingLimit = ceiling; - console.log('ceiling:',ceiling); - - scalePos = (yscale / 2) / ceiling; @@ -243,14 +229,10 @@ CC2650_ACCEL = function(p) { yOffset = ((height - (14 + 12)) / 2) + 12; - - - //Var xstep = 2.34; - for (lineMode = 0; lineMode < parts.length; lineMode++) { lm = parts[lineMode]; - var startX = 46 + (this.maxLength - _newData[lm].length) * xstep; + startX = 46 + (this.maxLength - _newData[lm].length) * xstep; calcArray = []; @@ -282,6 +264,7 @@ CC2650_ACCEL = function(p) { this.advancedGraph = function(mode, data, subID) { + var startX; var xstep; var scalePos; var lm; @@ -299,20 +282,18 @@ CC2650_ACCEL = function(p) { var yscale = 125; var height = 125; - var yOffset = 71; + 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 || ''; - // LineID = [this.frameID , _subID , '-line'].join(''); text1ID = [this.frameID, _subID, '-txt1'].join(''); text2ID = [this.frameID, _subID, '-txt2'].join(''); @@ -321,16 +302,12 @@ CC2650_ACCEL = function(p) { yscale = 300; } - if (_data.x.length > 0) { max = 2; 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); @@ -350,20 +327,20 @@ CC2650_ACCEL = function(p) { xstep = (680 - 46) / this.maxLength; + // YOffset should be about 71; yOffset = ((height - (14 + 12)) / 2) + 12; - //Var xstep = 2.34; for (lineMode = 0; lineMode < parts.length; lineMode++) { lm = parts[lineMode]; - var startX = 46 + (this.maxLength - _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)); } @@ -443,7 +420,7 @@ CC2650_ACCEL = function(p) { var ylineID = this.frameID + _subID + '-y-line'; var zlineID = this.frameID + _subID + '-z-line'; - var svg = this.generateBlankGraphBase(_subID,{width: '700',height: height}); + var svg = this.generateBlankGraphBase(_subID,{width: '700',height: _height}); svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,99,1)'); svg = this.graphAddLine(svg, ylineID, 'rgba(46,255,0,1)'); @@ -453,19 +430,10 @@ CC2650_ACCEL = function(p) { }; - - - this.startCalibrate = function() { - console.log('Start calibrate'); - - alert('Mag Calibration: Wave device in a figure eight until done!'); - }; - this.insertFrame = function(mode) { var _graph; var row; - var button; var elm; var frame; var title; @@ -482,7 +450,7 @@ CC2650_ACCEL = function(p) { title = [titles[mode], ' - ', this.deviceID].join(' '); - frame = $('
', { + frame = $('
', { class: 'mui-panel', id: this.frames[modeID] }); @@ -492,22 +460,16 @@ CC2650_ACCEL = function(p) { if (mode === 'mag') { - elm = $('
', {class: 'mui-row'}); - button = $(' - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Sensor Toy
Devices
\ No newline at end of file