Skip to content

Instantly share code, notes, and snippets.

View johnnyman727's full-sized avatar

Jon johnnyman727

View GitHub Profile
@johnnyman727
johnnyman727 / tessel-moosh.js
Created March 10, 2014 15:02
Stripped Down Mooshimeter Example
var tessel = require('tessel');
var blePort = tessel.port('a');
var bleDriver = require('../');
bluetooth = bleDriver.use(blePort, function(err) {
if (err) {
return console.log("Failed to connect");
}
else {
// Connect to moosh
@johnnyman727
johnnyman727 / intel-hex-parser.js
Last active August 29, 2015 13:57
JavaScript Intel Hex Parser For BlueGiga BLE Device Updates
var fs = require('fs');
function parseIntelHexData(path, callback) {
var hex = fs.readFileSync(path).toString();
console.log('loaded file');
// Split the file into lines
var hexLines = hex.split('\n');
// The last line is an empty string
hexLines.pop();
var tessel = require('tessel');
var https = require('https');
var querystring = require('querystring');
// Build the post string from an object
var post_data = querystring.stringify({
'accel-x' : '1.24353',
'accel-y': '-.543653',
'accel-z': '0.021234',
});
@johnnyman727
johnnyman727 / ibeacon.js
Created June 27, 2014 01:37
Use Tessel as an iBeacon device
var tessel = require('tessel');
var blePort = tessel.port['A'];
var bleLib = require('ble-ble113a');
var data = new Buffer('0201061aff4c000215e2c56db5dffb48d2b060d0f5a71096e000000000c6','hex');
var ble = bleLib.use(blePort, function(err) {
if (err) return console.log("Error connecting to slave", err);
ble.setAdvertisingData(data, function (e2){
if (e2) console.log("Error set adv", e2);
@johnnyman727
johnnyman727 / node-bliny.js
Created July 27, 2014 18:14
Blink the Tessel LED over WiFi
var http = require('http');
var state = 1;
function toggleLED() {
// Change the IP Address to your Tessel's IP Address!
var path = 'http://172.20.10.5:8080/green/' + state
console.log('getting at', path);
http.get(path, function(res) {
@johnnyman727
johnnyman727 / tessel-button.js
Created August 29, 2014 06:30
Make a POST when Tessel's Config button is pressed.
var tessel = require('tessel'),
http = require('http');
var options = {
method : 'POST',
host : 'YOUR_HOST_HERE',
port : 'YOUR_PORT_HERE',
path : 'YOUR_PATH_HERE'
};
@johnnyman727
johnnyman727 / listening-client.js
Created September 23, 2014 19:57
Simple MQTT Server. Tessel acts as an MQTT client sending temperature data to a host
var mqtt = require('mqtt')
// Make sure to change this to the IP address of your MQTT server
, host = '192.168.128.204' // or localhost
client = mqtt.createClient(1883, host, {keepalive: 10000});
// Subscribe to the temperature topic
client.subscribe('temperature');
// When a temperature is published, it will show up here
client.on('message', function (topic, message) {
@johnnyman727
johnnyman727 / for_fang.js
Created October 14, 2014 02:35
Many Modules
require('tesselate')(['ble-ble113a', 'climate-si7020', 'ambient-attx4', 'camera-vc0706'], function(tessel, modules) {
console.log('connected!');
modules.climate.readTemperature(message, function (err, temp) {
modules.climate.readHumidity(function (err, humid) {
console.log(temp + ":" + humid);
modules.ambient.getLightLevel(function (err, ldata) {
if (err)
throw err;
modules.ambient.getSoundLevel(function (err, sdata) {
@johnnyman727
johnnyman727 / sound-meter.js
Created November 5, 2014 17:25
Animates a strip of Neopixels according to how loud an environment is.
var tessel = require('tessel');
var ambientLib = require('ambient-attx4');
var animations = require('neopixel-animations');
var Neopixels = require('neopixels');
var neopixels = new Neopixels();
var ambient = ambientLib.use(tessel.port.A);
var numLEDs = 60;
var helpFactor = 10;

What I did to get the leaf project running on my Macbook Air (which has an Intel GPU):

  • git clone https://github.com/autumnai/collenchyma.git // Checkout the library for abstracting GPU/Native implementations
  • cd collenchyma; git remote add j https://github.com/johnnyman727/collenchyma.git; git fetch j; git checkout correct-commit // Check out commit that fixes OSX builds
  • Open Cargo.toml in a text editor and remove "cuda" from this line // Macbook Air's don't have NVidia GPUs so CUDA is useless
  • cd ../; git clone https://github.com/autumnai/collenchyma-blas.git; cd collenchyma-blas // Enter our BLAS Plugin directory
  • Open Cargo.toml in a text editor and add path = "../collenchyma" as a property to this line // Use our local version with fix for OSX
  • Once again, remove "cuda" fr