this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

added package json to device folder to reduce the payload size to Tessel

+1103 -1
+5
assets/js/device/node_modules/accel-mma84/.npmignore
··· 1 + node_modules 2 + build 3 + out 4 + *.log 5 +
+10
assets/js/device/node_modules/accel-mma84/COPYRIGHT
··· 1 + The Accelerometer Module project is copyright 2014 2 + Technical Machine, Inc. 3 + 4 + Licensed under the Apache License, Version 2.0 5 + <LICENSE-APACHE or 6 + http://www.apache.org/licenses/LICENSE-2.0> or the MIT 7 + license <LICENSE-MIT or http://opensource.org/licenses/MIT>, 8 + at your option. All files in the project carrying such 9 + notice may not be copied, modified, or distributed except 10 + according to those terms.
+201
assets/js/device/node_modules/accel-mma84/LICENSE-APACHE
··· 1 + Apache License 2 + Version 2.0, January 2004 3 + http://www.apache.org/licenses/ 4 + 5 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 + 7 + 1. Definitions. 8 + 9 + "License" shall mean the terms and conditions for use, reproduction, 10 + and distribution as defined by Sections 1 through 9 of this document. 11 + 12 + "Licensor" shall mean the copyright owner or entity authorized by 13 + the copyright owner that is granting the License. 14 + 15 + "Legal Entity" shall mean the union of the acting entity and all 16 + other entities that control, are controlled by, or are under common 17 + control with that entity. For the purposes of this definition, 18 + "control" means (i) the power, direct or indirect, to cause the 19 + direction or management of such entity, whether by contract or 20 + otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 + outstanding shares, or (iii) beneficial ownership of such entity. 22 + 23 + "You" (or "Your") shall mean an individual or Legal Entity 24 + exercising permissions granted by this License. 25 + 26 + "Source" form shall mean the preferred form for making modifications, 27 + including but not limited to software source code, documentation 28 + source, and configuration files. 29 + 30 + "Object" form shall mean any form resulting from mechanical 31 + transformation or translation of a Source form, including but 32 + not limited to compiled object code, generated documentation, 33 + and conversions to other media types. 34 + 35 + "Work" shall mean the work of authorship, whether in Source or 36 + Object form, made available under the License, as indicated by a 37 + copyright notice that is included in or attached to the work 38 + (an example is provided in the Appendix below). 39 + 40 + "Derivative Works" shall mean any work, whether in Source or Object 41 + form, that is based on (or derived from) the Work and for which the 42 + editorial revisions, annotations, elaborations, or other modifications 43 + represent, as a whole, an original work of authorship. For the purposes 44 + of this License, Derivative Works shall not include works that remain 45 + separable from, or merely link (or bind by name) to the interfaces of, 46 + the Work and Derivative Works thereof. 47 + 48 + "Contribution" shall mean any work of authorship, including 49 + the original version of the Work and any modifications or additions 50 + to that Work or Derivative Works thereof, that is intentionally 51 + submitted to Licensor for inclusion in the Work by the copyright owner 52 + or by an individual or Legal Entity authorized to submit on behalf of 53 + the copyright owner. For the purposes of this definition, "submitted" 54 + means any form of electronic, verbal, or written communication sent 55 + to the Licensor or its representatives, including but not limited to 56 + communication on electronic mailing lists, source code control systems, 57 + and issue tracking systems that are managed by, or on behalf of, the 58 + Licensor for the purpose of discussing and improving the Work, but 59 + excluding communication that is conspicuously marked or otherwise 60 + designated in writing by the copyright owner as "Not a Contribution." 61 + 62 + "Contributor" shall mean Licensor and any individual or Legal Entity 63 + on behalf of whom a Contribution has been received by Licensor and 64 + subsequently incorporated within the Work. 65 + 66 + 2. Grant of Copyright License. Subject to the terms and conditions of 67 + this License, each Contributor hereby grants to You a perpetual, 68 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 + copyright license to reproduce, prepare Derivative Works of, 70 + publicly display, publicly perform, sublicense, and distribute the 71 + Work and such Derivative Works in Source or Object form. 72 + 73 + 3. Grant of Patent License. Subject to the terms and conditions of 74 + this License, each Contributor hereby grants to You a perpetual, 75 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 + (except as stated in this section) patent license to make, have made, 77 + use, offer to sell, sell, import, and otherwise transfer the Work, 78 + where such license applies only to those patent claims licensable 79 + by such Contributor that are necessarily infringed by their 80 + Contribution(s) alone or by combination of their Contribution(s) 81 + with the Work to which such Contribution(s) was submitted. If You 82 + institute patent litigation against any entity (including a 83 + cross-claim or counterclaim in a lawsuit) alleging that the Work 84 + or a Contribution incorporated within the Work constitutes direct 85 + or contributory patent infringement, then any patent licenses 86 + granted to You under this License for that Work shall terminate 87 + as of the date such litigation is filed. 88 + 89 + 4. Redistribution. You may reproduce and distribute copies of the 90 + Work or Derivative Works thereof in any medium, with or without 91 + modifications, and in Source or Object form, provided that You 92 + meet the following conditions: 93 + 94 + (a) You must give any other recipients of the Work or 95 + Derivative Works a copy of this License; and 96 + 97 + (b) You must cause any modified files to carry prominent notices 98 + stating that You changed the files; and 99 + 100 + (c) You must retain, in the Source form of any Derivative Works 101 + that You distribute, all copyright, patent, trademark, and 102 + attribution notices from the Source form of the Work, 103 + excluding those notices that do not pertain to any part of 104 + the Derivative Works; and 105 + 106 + (d) If the Work includes a "NOTICE" text file as part of its 107 + distribution, then any Derivative Works that You distribute must 108 + include a readable copy of the attribution notices contained 109 + within such NOTICE file, excluding those notices that do not 110 + pertain to any part of the Derivative Works, in at least one 111 + of the following places: within a NOTICE text file distributed 112 + as part of the Derivative Works; within the Source form or 113 + documentation, if provided along with the Derivative Works; or, 114 + within a display generated by the Derivative Works, if and 115 + wherever such third-party notices normally appear. The contents 116 + of the NOTICE file are for informational purposes only and 117 + do not modify the License. You may add Your own attribution 118 + notices within Derivative Works that You distribute, alongside 119 + or as an addendum to the NOTICE text from the Work, provided 120 + that such additional attribution notices cannot be construed 121 + as modifying the License. 122 + 123 + You may add Your own copyright statement to Your modifications and 124 + may provide additional or different license terms and conditions 125 + for use, reproduction, or distribution of Your modifications, or 126 + for any such Derivative Works as a whole, provided Your use, 127 + reproduction, and distribution of the Work otherwise complies with 128 + the conditions stated in this License. 129 + 130 + 5. Submission of Contributions. Unless You explicitly state otherwise, 131 + any Contribution intentionally submitted for inclusion in the Work 132 + by You to the Licensor shall be under the terms and conditions of 133 + this License, without any additional terms or conditions. 134 + Notwithstanding the above, nothing herein shall supersede or modify 135 + the terms of any separate license agreement you may have executed 136 + with Licensor regarding such Contributions. 137 + 138 + 6. Trademarks. This License does not grant permission to use the trade 139 + names, trademarks, service marks, or product names of the Licensor, 140 + except as required for reasonable and customary use in describing the 141 + origin of the Work and reproducing the content of the NOTICE file. 142 + 143 + 7. Disclaimer of Warranty. Unless required by applicable law or 144 + agreed to in writing, Licensor provides the Work (and each 145 + Contributor provides its Contributions) on an "AS IS" BASIS, 146 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 + implied, including, without limitation, any warranties or conditions 148 + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 + PARTICULAR PURPOSE. You are solely responsible for determining the 150 + appropriateness of using or redistributing the Work and assume any 151 + risks associated with Your exercise of permissions under this License. 152 + 153 + 8. Limitation of Liability. In no event and under no legal theory, 154 + whether in tort (including negligence), contract, or otherwise, 155 + unless required by applicable law (such as deliberate and grossly 156 + negligent acts) or agreed to in writing, shall any Contributor be 157 + liable to You for damages, including any direct, indirect, special, 158 + incidental, or consequential damages of any character arising as a 159 + result of this License or out of the use or inability to use the 160 + Work (including but not limited to damages for loss of goodwill, 161 + work stoppage, computer failure or malfunction, or any and all 162 + other commercial damages or losses), even if such Contributor 163 + has been advised of the possibility of such damages. 164 + 165 + 9. Accepting Warranty or Additional Liability. While redistributing 166 + the Work or Derivative Works thereof, You may choose to offer, 167 + and charge a fee for, acceptance of support, warranty, indemnity, 168 + or other liability obligations and/or rights consistent with this 169 + License. However, in accepting such obligations, You may act only 170 + on Your own behalf and on Your sole responsibility, not on behalf 171 + of any other Contributor, and only if You agree to indemnify, 172 + defend, and hold each Contributor harmless for any liability 173 + incurred by, or claims asserted against, such Contributor by reason 174 + of your accepting any such warranty or additional liability. 175 + 176 + END OF TERMS AND CONDITIONS 177 + 178 + APPENDIX: How to apply the Apache License to your work. 179 + 180 + To apply the Apache License to your work, attach the following 181 + boilerplate notice, with the fields enclosed by brackets "[]" 182 + replaced with your own identifying information. (Don't include 183 + the brackets!) The text should be enclosed in the appropriate 184 + comment syntax for the file format. We also recommend that a 185 + file or class name and description of purpose be included on the 186 + same "printed page" as the copyright notice for easier 187 + identification within third-party archives. 188 + 189 + Copyright [yyyy] [name of copyright owner] 190 + 191 + Licensed under the Apache License, Version 2.0 (the "License"); 192 + you may not use this file except in compliance with the License. 193 + You may obtain a copy of the License at 194 + 195 + http://www.apache.org/licenses/LICENSE-2.0 196 + 197 + Unless required by applicable law or agreed to in writing, software 198 + distributed under the License is distributed on an "AS IS" BASIS, 199 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 + See the License for the specific language governing permissions and 201 + limitations under the License.
+25
assets/js/device/node_modules/accel-mma84/LICENSE-MIT
··· 1 + Copyright (c) 2013-2014 Technical Machine, Inc 2 + 3 + Permission is hereby granted, free of charge, to any 4 + person obtaining a copy of this software and associated 5 + documentation files (the "Software"), to deal in the 6 + Software without restriction, including without 7 + limitation the rights to use, copy, modify, merge, 8 + publish, distribute, sublicense, and/or sell copies of 9 + the Software, and to permit persons to whom the Software 10 + is furnished to do so, subject to the following 11 + conditions: 12 + 13 + The above copyright notice and this permission notice 14 + shall be included in all copies or substantial portions 15 + of the Software. 16 + 17 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 + PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 + SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 + IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 + DEALINGS IN THE SOFTWARE.
+68
assets/js/device/node_modules/accel-mma84/README.md
··· 1 + #Accelerometer 2 + Driver for the accel-mma84 Tessel accelerometer module ([MMA8452Q](http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf)). 3 + 4 + ##Installation 5 + ```sh 6 + npm install accel-mma84 7 + ``` 8 + 9 + ##Example 10 + ```js 11 + /********************************************* 12 + This basic accelerometer example logs a stream 13 + of x, y, and z data from the accelerometer 14 + *********************************************/ 15 + 16 + var tessel = require('tessel'); 17 + var accel = require('accel-mma84').use(tessel.port['A']); 18 + 19 + // Initialize the accelerometer. 20 + accel.on('ready', function () { 21 + // Stream accelerometer data 22 + accel.on('data', function (xyz) { 23 + console.log("x:", xyz[0].toFixed(2), 24 + "y:", xyz[1].toFixed(2), 25 + "z:", xyz[2].toFixed(2)); 26 + }); 27 + }); 28 + 29 + accel.on('error', function(err) { 30 + console.log('error connecting', err); 31 + }); 32 + 33 + setInterval(function(){}, 20000); 34 + ``` 35 + 36 + ##Methods 37 + 38 + ##### * `accel.availableOutputRates()` Logs the available interrupt rates in Hz. 39 + 40 + ##### * `accel.availableScaleRanges()` Logs the available accelerometer ranges (in units of Gs). 41 + 42 + ##### * `accel.enableDataInterrupts(trueOrFalse, callback(err))` Enables or disables data interrupts. Set the first param truthy to enable, falsy to disable. 43 + 44 + ##### * `accel.getAcceleration(callback(err, xyz))` Gets the acceleration from the device, outputs as array [x, y, z]. 45 + 46 + ##### * `accel.setOutputRate(rateInHz, callback(err))` Sets the output rate of the data (1.56-800 Hz). 47 + 48 + ##### * `accel.setScaleRange(scaleRange, callback(err))` Sets the accelerometer to read up to 2, 4, or 8 Gs of acceleration (smaller range = better precision). 49 + 50 + ##Events 51 + 52 + ##### * `accel.on('data', callback(xyz))` Emitted when data is available. `xyz` is an array in the form of [x, y, z]. 53 + 54 + ##### * `accel.on('error', callback(err))` Emitted upon error. 55 + 56 + ##### * `accel.on('ready', callback())` Emitted upon first successful communication between the Tessel and the module. 57 + 58 + ##Further Examples 59 + See the examples folder for code. 60 + 61 + * show-axes: Manipulate LEDs based on acceleration in the three axes. 62 + 63 + * change-rates: Change the polling rate. 64 + 65 + ## License 66 + 67 + MIT 68 + APACHE
+25
assets/js/device/node_modules/accel-mma84/examples/accelerometer.js
··· 1 + // Any copyright is dedicated to the Public Domain. 2 + // http://creativecommons.org/publicdomain/zero/1.0/ 3 + 4 + /********************************************* 5 + This basic accelerometer example logs a stream 6 + of x, y, and z data from the accelerometer 7 + *********************************************/ 8 + 9 + var tessel = require('tessel'); 10 + var accel = require('../').use(tessel.port['A']); // Replace '../' with 'accel-mma84' in your own code 11 + 12 + // Initialize the accelerometer. 13 + accel.on('ready', function () { 14 + // Stream accelerometer data 15 + accel.on('data', function (xyz) { 16 + console.log('x:', xyz[0].toFixed(2), 17 + 'y:', xyz[1].toFixed(2), 18 + 'z:', xyz[2].toFixed(2)); 19 + }); 20 + 21 + }); 22 + 23 + accel.on('error', function(err){ 24 + console.log('Error:', err); 25 + });
+39
assets/js/device/node_modules/accel-mma84/examples/change-rates.js
··· 1 + // Any copyright is dedicated to the Public Domain. 2 + // http://creativecommons.org/publicdomain/zero/1.0/ 3 + 4 + /********************************************* 5 + This more advanced accelerometer example logs 6 + a stream of x, y, and z data, then stops the 7 + stream, changes the polling rate, and resumes 8 + streaming from the accelerometer 9 + *********************************************/ 10 + 11 + var tessel = require('tessel'); 12 + var accel = require('../').use(tessel.port['A']); // Replace '../' with 'accel-mma84' in your own code 13 + 14 + // Initialize the accelerometer. 15 + accel.on('ready', function () { 16 + // Stream accelerometer data 17 + accel.on('data', function(xyz) { 18 + console.log('x:', xyz[0].toFixed(2), 19 + 'y:', xyz[1].toFixed(2), 20 + 'z:', xyz[2].toFixed(2)); 21 + }); 22 + //After two seconds, change stream rate, then stream again 23 + setTimeout(function () { 24 + console.log('Changing the output rate...'); 25 + accel.removeAllListeners('data'); 26 + // Setting the output data rate in Hz 27 + accel.setOutputRate(1.56, function rateSet() { 28 + accel.on('data', function (xyz) { 29 + console.log('slower x:', xyz[0].toFixed(2), 30 + 'slower y:', xyz[1].toFixed(2), 31 + 'slower z:', xyz[2].toFixed(2)); 32 + }); 33 + }); 34 + }, 2000); 35 + }); 36 + 37 + accel.on('error', function(err){ 38 + console.log('Error:', err); 39 + });
+59
assets/js/device/node_modules/accel-mma84/examples/show-axes.js
··· 1 + // Any copyright is dedicated to the Public Domain. 2 + // http://creativecommons.org/publicdomain/zero/1.0/ 3 + 4 + /********************************************* 5 + Demonstrates axes by turning on a different 6 + LED per axis (x, y, z) only when that axis 7 + has positive acceleration. Also prints +/- 8 + per axis to the console. 9 + *********************************************/ 10 + 11 + var tessel = require('tessel'); 12 + var accel = require('../').use(tessel.port['A']); // Replace '../' with 'accel-mma84' in your own code 13 + 14 + // Define vars 15 + var led1 = tessel.led[0].output(); 16 + var led2 = tessel.led[1].output(); 17 + var led3 = tessel.led[2].output(); 18 + 19 + var textOut = ''; 20 + 21 + accel.on('ready', function(){ 22 + accel.on('data', function(xyz){ 23 + // Refresh variables; 24 + var x = xyz[0]; 25 + var y = xyz[1]; 26 + var z = xyz[2]; 27 + 28 + textOut = ""; 29 + 30 + // Print which axes are positive and turn on corresponding LEDs 31 + if(x > 0) { 32 + led1.high(); 33 + textOut += 'x: + | '; 34 + } else { 35 + led1.low(); 36 + textOut += 'x: - | '; 37 + } 38 + if(y > 0) { 39 + led2.high(); 40 + textOut += 'y: + | '; 41 + } else { 42 + led2.low(); 43 + textOut += 'y: - | '; 44 + } 45 + if(z > 0) { 46 + led3.high(); 47 + textOut += 'z: +'; 48 + } else { 49 + led3.low(); 50 + textOut += 'z: -'; 51 + } 52 + 53 + console.log(textOut); 54 + }); 55 + }); 56 + 57 + accel.on('error', function(err){ 58 + console.log('Error:', err); 59 + });
+412
assets/js/device/node_modules/accel-mma84/index.js
··· 1 + // Copyright 2014 Technical Machine, Inc. See the COPYRIGHT 2 + // file at the top-level directory of this distribution. 3 + // 4 + // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 5 + // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 6 + // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 7 + // option. This file may not be copied, modified, or distributed 8 + // except according to those terms. 9 + 10 + var util = require('util'); 11 + var EventEmitter = require('events').EventEmitter; 12 + var queue = require('sync-queue'); 13 + 14 + // The SparkFun breakout board defaults to 1, set to 0 if SA0 jumper on the bottom of the board is set 15 + var I2C_ADDRESS = 0x1D; // 0x1D if SA0 is high, 0x1C if low 16 + 17 + // See the many application notes for more info on setting all of these registers: 18 + // http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MMA8452Q 19 + // MMA8452 registers 20 + var OUT_X_MSB = 0x01; 21 + var XYZ_DATA_CFG = 0x0E; 22 + var WHO_AM_I = 0x0D; 23 + var CTRL_REG1 = 0x2A; 24 + var CTRL_REG4 = 0x2D; 25 + 26 + function Accelerometer (hardware, callback) { 27 + var self = this; 28 + // Command Queue 29 + self.queue = new queue(); 30 + // Port assignment 31 + self.hardware = hardware; 32 + // Rate at which data is collected and is ready to be read 33 + self.outputRate = 12.5; 34 + // Sets full-scale range to +/-2, 4, or 8g. Used to calc real g values. 35 + self.scaleRange = 2; 36 + // Interrupt pin for the data ready event 37 + self.dataInterrupt = self.hardware.digital[1]; 38 + // Address for i2C 39 + // TODO: Account for manual address changes? 40 + self.i2c = hardware.I2C(I2C_ADDRESS); 41 + 42 + // Check that we can read the correct chip id 43 + self.queue.place(function one() { 44 + self._getChipID(function IDRead(err, c) { 45 + if (err) { 46 + err = new Error("Could not connect to MMA8452Q. No reponse on I2C lines. Error: "+err); 47 + return self._failProcedure(err); 48 + } 49 + // should always return 0x2A 50 + if (c !== 0x2A) { 51 + // This is the wrong chip 52 + err = new Error("Could not connect to MMA8452Q, received " + c.toString() + ". Expected 0x2A."); 53 + // Fail the init 54 + return self._failProcedure(err); 55 + } 56 + 57 + // Set the scale range to standard 58 + self.setScaleRange(self.scaleRange, function(err) { 59 + if (err) { 60 + return self._failProcedure(err, callback); 61 + } 62 + else { 63 + // Set the output rate to standard 64 + self.setOutputRate(self.outputRate, function(err) { 65 + if (err) { 66 + return self._failProcedure(err, callback); 67 + } 68 + else { 69 + // Emit the ready event 70 + setImmediate(function emitReady() { 71 + self.emit('ready'); 72 + self.queue.next(); 73 + }); 74 + // Call the callback with object 75 + if (callback) callback(null, self); 76 + 77 + return; 78 + } 79 + }); 80 + } 81 + }); 82 + 83 + // Set up an interrupt handler for data ready 84 + self.dataInterrupt.once('low', self._dataReady.bind(self)); 85 + }); 86 + }); 87 + 88 + self.on('newListener', function(event) { 89 + // If we have a new sample listener 90 + if (event == 'data' || event == 'sample') { 91 + // Enable interrupts at whatever rate was previously set. 92 + self.enableDataInterrupts(true, queueNext); 93 + } 94 + }); 95 + 96 + self.on('removeListener', function(event) { 97 + // If we have a new || event == 'sample' listener 98 + if (event == 'data' || event == 'sample') { 99 + // Disable interrupt. 100 + self.enableDataInterrupts(false, queueNext); 101 + } 102 + }); 103 + 104 + self.queue.next(); 105 + } 106 + 107 + util.inherits(Accelerometer, EventEmitter); 108 + 109 + Accelerometer.prototype._changeRegister = function(change, callback) { 110 + var self = this; 111 + 112 + // Put the accelerometer into standby 113 + self._modeStandby(function inStandby(err) { 114 + if (err) { 115 + return self._failProcedure(err, callback); 116 + } 117 + else { 118 + // Make whatever change was requested 119 + change( function setActive(err) { 120 + if (err) { 121 + return self._failProcedure(err, callback); 122 + } 123 + else { 124 + // Put the accelerometer back into active mode 125 + self._modeActive(callback); 126 + } 127 + }); 128 + } 129 + }); 130 + }; 131 + 132 + Accelerometer.prototype._dataReady = function() { 133 + var self = this; 134 + // Data is ready so grab the data 135 + self.getAcceleration(function(err, xyz) { 136 + // If we had an error, emit it 137 + if (err) { 138 + // Emitting error 139 + self.emit('error', err); 140 + } 141 + // If there was no error 142 + else { 143 + // Emit the data 144 + self.emit('data', xyz); // old-style, deprecated 145 + self.emit('sample', xyz); 146 + } 147 + 148 + self.dataInterrupt.once('low', self._dataReady.bind(self)); 149 + }); 150 + }; 151 + 152 + Accelerometer.prototype._failProcedure = function(err, callback) { 153 + var self = this; 154 + 155 + // Emit the error 156 + setImmediate(function emitErr() { 157 + self.emit('error', err); 158 + }); 159 + // Call the callback 160 + if (callback) callback(err); 161 + 162 + return; 163 + }; 164 + 165 + // Get the id of the chip 166 + Accelerometer.prototype._getChipID = function(callback) { 167 + this._readRegister(WHO_AM_I, function (err, c) { 168 + if (callback) callback(err, c); 169 + }); 170 + }; 171 + 172 + Accelerometer.prototype._getClosestOutputRate = function(requestedRate, callback) { 173 + 174 + // If a negative number is requested, stop output (0 hz) 175 + if (requestedRate < 0) requestedRate = 0; 176 + 177 + // If 0 hz is requested, return just that so that output will be stopped 178 + if (requestedRate === 0) { 179 + 180 + if (callback) callback(null, 0); 181 + 182 + return; 183 + } 184 + 185 + // Get the available rates 186 + var available = this.availableOutputRates(); 187 + // Iterate through each 188 + for (var i = 0; i < available.length; i++) { 189 + // The first available rate less than or equal to requested is a match 190 + if (available[i] <= requestedRate) { 191 + // Send the match back 192 + if (callback) callback(null, available[i]); 193 + return; 194 + } 195 + } 196 + 197 + // If there were no match, this number must be between 0 and 1.56. Use 1.56 198 + if (callback) callback(null, available[available.length-1]); 199 + }; 200 + 201 + // Sets the MMA8452 to active mode. Needs to be in this mode to output data 202 + Accelerometer.prototype._modeActive = function (callback) { 203 + var self = this; 204 + // Set the active bit to begin detection 205 + self._readRegister(CTRL_REG1, function (err, c) { 206 + if (err) { 207 + return _failProcedure(err); 208 + } 209 + else { 210 + return self._writeRegister(CTRL_REG1, c | (0x01), callback); 211 + } 212 + }); 213 + }; 214 + 215 + // Sets the MMA8452 to standby mode. It must be in standby to change most register settings 216 + Accelerometer.prototype._modeStandby = function (callback) { 217 + var self = this; 218 + // Clear the active bit to go into standby 219 + self._readRegister(CTRL_REG1, function (err, c) { 220 + if (err) { 221 + return self._failProcedure(err, callback); 222 + } 223 + else { 224 + return self._writeRegister(CTRL_REG1, c & ~(0x01), callback); 225 + } 226 + }); 227 + }; 228 + 229 + Accelerometer.prototype._readRegister = function (addressToRead, callback) { 230 + this._readRegisters(addressToRead, 1, function (err, regs) { 231 + callback(err, regs && regs[0]); 232 + }); 233 + }; 234 + 235 + Accelerometer.prototype._readRegisters = function (addressToRead, bytesToRead, callback) { 236 + this.i2c.transfer(new Buffer([addressToRead]), bytesToRead, callback); 237 + }; 238 + 239 + // Write a single byte to the register. 240 + Accelerometer.prototype._writeRegister = function (addressToWrite, dataToWrite, callback) { 241 + this.i2c.send(new Buffer([addressToWrite, dataToWrite]), callback); 242 + }; 243 + 244 + // Sets the accelerometer to read up to 2, 4, or 8 Gs of acceleration (smaller range = better precision) 245 + Accelerometer.prototype._unsafeSetScaleRange = function(scaleRange, callback) { 246 + var self = this; 247 + 248 + var fsr = scaleRange; 249 + if (fsr > 8) fsr = 8; //Easy error check 250 + fsr >>= 2; // Neat trick, see page 22. 00 = 2G, 01 = 4G, 10 = 8G 251 + 252 + // Go into standby to edit registers 253 + self._changeRegister(function change(complete) { 254 + if (err) { 255 + return complete(err); 256 + } 257 + else { 258 + // Write the new scale into the register 259 + self._writeRegister(XYZ_DATA_CFG, fsr, function wroteReg(err) { 260 + self.scaleRange = scaleRange; 261 + return complete(err); 262 + }); 263 + } 264 + }, function scaleSet(err) { 265 + if (callback) { 266 + callback(err); 267 + } 268 + setImmediate(self.queue.next); 269 + }); 270 + } 271 + 272 + // Sets the output rate of the data (1.56-800 Hz) 273 + Accelerometer.prototype._unsafeSetOutputRate = function (hz, callback) { 274 + var self = this; 275 + 276 + // Put accel into standby 277 + self._changeRegister( function setRegisters(finishChange) { 278 + // Find the closest available rate (rounded down) 279 + self._getClosestOutputRate(hz, function gotRequested(err, closest) { 280 + if (err) { 281 + return finishChange(new Error("Rate must be >= 1.56Hz")); 282 + } 283 + else { 284 + // Set our property 285 + self.outputRate = closest; 286 + 287 + // Get the binary representation of the rate (for the register) 288 + var bin = self.availableOutputRates().indexOf(closest); 289 + // If the binary rep could be found 290 + if (bin !== -1) { 291 + // Read the current register value 292 + self._readRegister(CTRL_REG1, function readComplete(err, regVal) { 293 + if (err) { 294 + return finishChange(err); 295 + } 296 + else { 297 + // Clear the three bits of output rate control (0b11000111 = 199) 298 + regVal &= 199; 299 + // Move the binary rep into place (bits 3:5) 300 + if (bin !== 0) regVal |= (bin << 3); 301 + // Write that value into the control register 302 + self._writeRegister(CTRL_REG1, regVal, finishChange); 303 + } 304 + }); 305 + } 306 + else { 307 + return finishChange(new Error("Invalid output rate.")); 308 + } 309 + } 310 + }) 311 + }, 312 + function rateSet(err) { 313 + if (callback) { 314 + callback(err); 315 + } 316 + setImmediate(self.queue.next); 317 + }); 318 + }; 319 + 320 + 321 + // Logs the available interrupt rates in Hz 322 + Accelerometer.prototype.availableOutputRates = function() { 323 + return [800, 400, 200, 100, 50, 12.5, 6.25, 1.56]; 324 + }; 325 + 326 + // Logs the available accelerometer ranges (in units of Gs) 327 + Accelerometer.prototype.availableScaleRanges = function() { 328 + // The higher the range, the less accurate the readings are 329 + return [2, 4, 8]; 330 + }; 331 + 332 + // Enables or disables data interrupts. Set the first param truthy to enable, false to disable. 333 + Accelerometer.prototype.enableDataInterrupts = function(enable, callback) { 334 + var self = this; 335 + 336 + // Don't call unnecessarily. 337 + if (this._dataInterrupts == !!enable) { 338 + return callback && callback(); 339 + } 340 + this._dataInterrupts = !!enable; 341 + 342 + self.queue.place(function queueEnable() { 343 + // We're going to change register 4 344 + self._changeRegister(function change(complete) { 345 + // Read the register first 346 + self._readRegister(CTRL_REG4, function(err, reg4) { 347 + if (err) { 348 + return complete(err); 349 + } 350 + else { 351 + // If we are enabling, set first bit to 1, else 0 352 + var regVal = (enable ? (reg4 |= 1) : (reg4 &= ~1)); 353 + // Write to the register 354 + self._writeRegister(CTRL_REG4, regVal, function(err) { 355 + return complete(err); 356 + }); 357 + } 358 + }); 359 + }, function intSet(err) { 360 + if (callback) { 361 + callback(err); 362 + } 363 + setImmediate(self.queue.next); 364 + }); 365 + }); 366 + }; 367 + 368 + // Gets the acceleration from the device, outputs as array [x, y, z] 369 + Accelerometer.prototype.getAcceleration = function (callback) { 370 + var self = this; 371 + 372 + self.queue.place( function readAccel() { 373 + self._readRegisters(OUT_X_MSB, 6, function (err, rawData) { 374 + if (err) throw err; 375 + // Loop to calculate 12-bit ADC and g value for each axis 376 + var out = []; 377 + for (var i = 0; i < 3 ; i++) { 378 + var gCount = (rawData[i*2] << 8) | rawData[(i*2)+1]; // Combine the two 8 bit registers into one 12-bit number 379 + 380 + gCount = (gCount >> 4); // The registers are left align, here we right align the 12-bit integer 381 + 382 + // If the number is negative, we have to make it so manually (no 12-bit data type) 383 + if (rawData[i*2] > 0x7F) { 384 + gCount = -(1 + 0xFFF - gCount); // Transform into negative 2's complement 385 + } 386 + 387 + out[i] = gCount / ((1<<12)/(2*self.scaleRange)); 388 + } 389 + 390 + callback(null, out); 391 + 392 + setImmediate(self.queue.next); 393 + }); 394 + }); 395 + }; 396 + 397 + // Queueing version of Accelerometer#_unsafeSetOutputRate 398 + Accelerometer.prototype.setOutputRate = function (hz, callback) { 399 + this.queue.place(this._unsafeSetOutputRate.bind(this, hz, callback)); 400 + }; 401 + 402 + // Queueing version of Accelerometer#_unsafeSetScaleRange 403 + Accelerometer.prototype.setScaleRange = function(scaleRange, callback) { 404 + this.queue.place(this._unsafeSetScaleRange.bind(this, scaleRange, callback)); 405 + }; 406 + 407 + function use (hardware, callback) { 408 + return new Accelerometer(hardware, callback); 409 + } 410 + 411 + exports.Accelerometer = Accelerometer; 412 + exports.use = use;
+26
assets/js/device/node_modules/accel-mma84/node_modules/sync-queue/LICENSE-MIT
··· 1 + Copyright (c) 2014, Technical Machine, Inc. 2 + All rights reserved. 3 + 4 + Redistribution and use in source and binary forms, with or without 5 + modification, are permitted provided that the following conditions are met: 6 + 7 + * Redistributions of source code must retain the above copyright notice, this 8 + list of conditions and the following disclaimer. 9 + 10 + * Redistributions in binary form must reproduce the above copyright notice, 11 + this list of conditions and the following disclaimer in the documentation 12 + and/or other materials provided with the distribution. 13 + 14 + * The name Michael Bostock may not be used to endorse or promote products 15 + derived from this software without specific prior written permission. 16 + 17 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 + DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, 21 + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+28
assets/js/device/node_modules/accel-mma84/node_modules/sync-queue/README.md
··· 1 + #Sync-Queue 2 + 3 + ## Install 4 + `npm install sync-queue` 5 + 6 + ## Usage 7 + 8 + ```.js 9 + var Queue = require('sync-queue') 10 + var queue = new Queue(); 11 + 12 + queue.place(function one() { 13 + console.log('I'm func one); 14 + 15 + setTimeout(function() { 16 + console.log("and I'm still finishing up..."); 17 + queue.next(); 18 + }, 1000); 19 + }) 20 + 21 + queue.place(function two() { 22 + console.log.bind(this, "I'm the last func."); 23 + queue.next(); 24 + }); 25 + ``` 26 + 27 + ## Description 28 + Use `place` to put things in the queue. They will start being executed automatically. Call `next` when you want the thing you put in the queue is finished.
+34
assets/js/device/node_modules/accel-mma84/node_modules/sync-queue/index.js
··· 1 + function queue() { 2 + 3 + // Create an empty array of commands 4 + var queue = []; 5 + // We're inactive to begin with 6 + queue.active = false; 7 + // Method for adding command chain to the queue 8 + queue.place = function (command) { 9 + // Push the command onto the command array 10 + queue.push(command); 11 + // If we're currently inactive, start processing 12 + if (!queue.active) queue.next(); 13 + }; 14 + // Method for calling the next command chain in the array 15 + queue.next = function () { 16 + // If this is the end of the queue 17 + if (!queue.length) { 18 + // We're no longer active 19 + queue.active = false; 20 + // Stop execution 21 + return; 22 + } 23 + // Grab the next command 24 + var command = queue.shift(); 25 + // We're active 26 + queue.active = true; 27 + // Call the command 28 + command(); 29 + }; 30 + 31 + return queue; 32 + } 33 + 34 + module.exports = queue;
+49
assets/js/device/node_modules/accel-mma84/node_modules/sync-queue/package.json
··· 1 + { 2 + "name": "sync-queue", 3 + "version": "0.0.1", 4 + "description": "Simple queue for completing tasks in series", 5 + "main": "index.js", 6 + "scripts": { 7 + "test": "echo \"Error: no test specified\" && exit 1" 8 + }, 9 + "repository": { 10 + "type": "git", 11 + "url": "git@github.com:technicalmachine/sync-queue.git" 12 + }, 13 + "contributors": [ 14 + { 15 + "name": "Tim Cameron Ryan", 16 + "email": "tim@technical.io" 17 + }, 18 + { 19 + "name": "Jon McKay", 20 + "email": "jon@technical.io" 21 + } 22 + ], 23 + "license": "MIT", 24 + "bugs": { 25 + "url": "https://github.com/technicalmachine/sync-queue/issues" 26 + }, 27 + "homepage": "https://github.com/technicalmachine/sync-queue", 28 + "_id": "sync-queue@0.0.1", 29 + "dist": { 30 + "shasum": "5c97127057f8c7168c3d75ee132800c0445e4fe4", 31 + "tarball": "http://registry.npmjs.org/sync-queue/-/sync-queue-0.0.1.tgz" 32 + }, 33 + "_from": "sync-queue@0.0.1", 34 + "_npmVersion": "1.4.3", 35 + "_npmUser": { 36 + "name": "johnnyman727", 37 + "email": "johnnyman727@gmail.com" 38 + }, 39 + "maintainers": [ 40 + { 41 + "name": "johnnyman727", 42 + "email": "johnnyman727@gmail.com" 43 + } 44 + ], 45 + "directories": {}, 46 + "_shasum": "5c97127057f8c7168c3d75ee132800c0445e4fe4", 47 + "_resolved": "https://registry.npmjs.org/sync-queue/-/sync-queue-0.0.1.tgz", 48 + "readme": "ERROR: No README data found!" 49 + }
+18
assets/js/device/node_modules/accel-mma84/node_modules/sync-queue/test/test.js
··· 1 + var Queue = require('../'); 2 + var queue = new Queue(); 3 + 4 + queue.place(function one() { 5 + console.log("I'm func one"); 6 + 7 + setTimeout(function() { 8 + console.log("and I'm still finishing up..."); 9 + queue.next(); 10 + }, 1000); 11 + }) 12 + 13 + queue.place(function two() { 14 + console.log("I'm the last func."); 15 + queue.next(); 16 + }); 17 + 18 + console.log('placed both...');
+56
assets/js/device/node_modules/accel-mma84/package.json
··· 1 + { 2 + "name": "accel-mma84", 3 + "version": "0.2.3", 4 + "description": "Library to run the MMA8452Q accelerometer.", 5 + "main": "index.js", 6 + "scripts": { 7 + "test": "tinytap -e 'tessel run {} ${ACCEL_PORT}' test/*.js" 8 + }, 9 + "dependencies": { 10 + "sync-queue": "0.0.1" 11 + }, 12 + "hardware": { 13 + "./examples": false 14 + }, 15 + "repository": { 16 + "type": "git", 17 + "url": "https://github.com/tessel/accel-mma84" 18 + }, 19 + "author": { 20 + "name": "Tim Cameron Ryan", 21 + "email": "tim@timryan.org" 22 + }, 23 + "license": "MIT", 24 + "devDependencies": { 25 + "tinytap": "~0.0.2" 26 + }, 27 + "bugs": { 28 + "url": "https://github.com/tessel/accel-mma84/issues" 29 + }, 30 + "homepage": "https://github.com/tessel/accel-mma84", 31 + "_id": "accel-mma84@0.2.3", 32 + "dist": { 33 + "shasum": "6bbf80f69115251e82d9ca76aaf7e0d69db1d8f3", 34 + "tarball": "http://registry.npmjs.org/accel-mma84/-/accel-mma84-0.2.3.tgz" 35 + }, 36 + "_from": "accel-mma84@*", 37 + "_npmVersion": "1.4.3", 38 + "_npmUser": { 39 + "name": "technicalmachine", 40 + "email": "team@technical.io" 41 + }, 42 + "maintainers": [ 43 + { 44 + "name": "tcr", 45 + "email": "id@timryan.org" 46 + }, 47 + { 48 + "name": "technicalmachine", 49 + "email": "team@technical.io" 50 + } 51 + ], 52 + "directories": {}, 53 + "_shasum": "6bbf80f69115251e82d9ca76aaf7e0d69db1d8f3", 54 + "_resolved": "https://registry.npmjs.org/accel-mma84/-/accel-mma84-0.2.3.tgz", 55 + "readme": "ERROR: No README data found!" 56 + }
+17
assets/js/device/node_modules/accel-mma84/test/test.js
··· 1 + /* test rig */ var t = 1, tmax = 5 2 + function ok (a, d) { console.log(a ? 'ok ' + (t++) + ' -' : 'not ok ' + (t++) + ' -', d); } 3 + console.log(t + '..' + tmax); 4 + 5 + /* script */ 6 + 7 + var tessel = require('tessel'); 8 + var accel = require('../').use(tessel.port[process.argv[2] || 'A']); 9 + 10 + accel.on('sample', function (xyz) { 11 + ok(Array.isArray(xyz), 'accelerometer data is array'); 12 + ok(xyz.length == 3, 'three samples'); 13 + ok(typeof xyz[0] == 'number', 'idx 0 is number'); 14 + ok(typeof xyz[1] == 'number', 'idx 1 is number'); 15 + ok(typeof xyz[2] == 'number', 'idx 2 is number'); 16 + process.exit(0); 17 + });
+13
assets/js/device/package.json
··· 1 + { 2 + "name": "accel_data", 3 + "version": "0.0.0", 4 + "description": "Tessel Accel Data to Node", 5 + "scripts": { 6 + "test": "echo \"Error: no test specified\" && exit 1" 7 + }, 8 + "author": "Kaushik", 9 + "license": "Public Domain", 10 + "dependencies": { 11 + "accel-mma84": "^0.2.3" 12 + } 13 + }
+18 -1
assets/js/gl.js
··· 53 53 spotLight.shadowCameraNear = 0.1; 54 54 spotLight.castShadow = true; 55 55 spotLight.shadowDarkness = 0.5; 56 - // spotLight.shadowCameraVisible = true; 56 + spotLight.shadowCameraVisible = true; 57 57 scene.add(spotLight); 58 58 59 59 onRenderFcts.push(function() { ··· 134 134 var render = function() { 135 135 requestAnimationFrame(render); 136 136 137 + // cube.rotation.x += 0.01; 138 + // cube.rotation.y += 0.01; 137 139 138 140 if (x_from_tessel !== prev_x) { 139 141 cube.rotation.x += x_from_tessel / 2; ··· 145 147 cube.rotation.y += y_from_tessel / 2; 146 148 prev_y = y_from_tessel; 147 149 } 150 + 151 + //var angle = Date.now()/1000 * Math.PI; 152 + // var angleX = prev_x/1000 * Math.PI; 153 + // var angleY = prev_y/1000 * Math.PI; 154 + 155 + // // if (angleX * 10000 * -1 <= 1.0){ 156 + // console.log(angleX * 10000 * -1); 157 + // spotLight.position.x += Math.cos(angleX*-0.1)*20; 158 + // // } 159 + // // if (angleY * 10000 <= 1.0){ 160 + // console.log(angleY * 10000); 161 + // spotLight.position.y += 10 + Math.sin(angleY*0.5)*6; 162 + // } 163 + 164 + //spotLight.position.z = Math.sin(angle*-0.1)*20; 148 165 149 166 150 167 lastTimeMsec = lastTimeMsec || nowMsec - 1000 / 60